Add biome revisions readable content and visible projectile outcomes
This commit is contained in:
@@ -70,9 +70,10 @@ type ResourceLayout struct {
|
||||
Resources []p.Entity `json:"resources"`
|
||||
}
|
||||
type World struct {
|
||||
Projectiles map[string]*Projectile `json:"projectiles,omitempty"`
|
||||
Areas map[string]*CombatArea `json:"areas,omitempty"`
|
||||
CombatSequence uint64 `json:"combatSequence"`
|
||||
ProjectileVisuals []p.ProjectileVisual `json:"projectileVisuals,omitempty"`
|
||||
Projectiles map[string]*Projectile `json:"projectiles,omitempty"`
|
||||
Areas map[string]*CombatArea `json:"areas,omitempty"`
|
||||
CombatSequence uint64 `json:"combatSequence"`
|
||||
|
||||
ResourceLayouts map[string]ResourceLayout `json:"resourceLayouts,omitempty"`
|
||||
|
||||
@@ -636,6 +637,13 @@ func (w *World) Advance(now time.Time, dt float64) {
|
||||
playedDT := math.Max(0, dt)
|
||||
w.now = now
|
||||
w.Tick++
|
||||
kept := w.ProjectileVisuals[:0]
|
||||
for _, v := range w.ProjectileVisuals {
|
||||
if w.Age()-v.At <= 2 {
|
||||
kept = append(kept, v)
|
||||
}
|
||||
}
|
||||
w.ProjectileVisuals = kept
|
||||
dt = math.Max(0, math.Min(dt, 0.25))
|
||||
if w.Phase == "won" || w.Phase == "lost" {
|
||||
return
|
||||
@@ -798,6 +806,12 @@ func (w *World) Snapshot(id string, known map[string]bool) p.Snapshot {
|
||||
visible := func(pos p.Vec3) bool {
|
||||
return allowed[Key(ChunkCoord(pos.X, w.Balance.ChunkSize), ChunkCoord(pos.Z, w.Balance.ChunkSize))]
|
||||
}
|
||||
s.ProjectileVisuals = []p.ProjectileVisual{}
|
||||
for _, v := range w.ProjectileVisuals {
|
||||
if w.Age()-v.At <= 2 && (visible(v.Position) || visible(v.Destination)) {
|
||||
s.ProjectileVisuals = append(s.ProjectileVisuals, v)
|
||||
}
|
||||
}
|
||||
for _, other := range w.Characters {
|
||||
if other.View.Entity.ID != id && other.Online && other.View.Entity.State != "dead" && visible(other.View.Entity.Position) {
|
||||
s.Entities = append(s.Entities, other.View.Entity)
|
||||
|
||||
Reference in New Issue
Block a user