blob: d6f1ccb948f71b3ad724ed4393a4c133c46689e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package main
import (
"age_of_empires/ecs"
"age_of_empires/physics"
"log/slog"
)
type Order interface {
Update(e *Entity, g *Game)
}
func (e *Entity) UpdateOrder(g *Game) {
if !e.Order.IsEnabled || e.Order.Value == nil {
return
}
e.Order.Value.Update(e, g)
}
func (e *Entity) MainAction(g *Game, destination physics.Point, entityAtDestination *Entity, moveMap physics.MoveMap) {
if entityAtDestination != nil && entityAtDestination.ResourceSource.IsEnabled && e.ResourceGatherer.IsEnabled {
Gather(e, entityAtDestination, g)
return
}
if e.Move.IsEnabled {
if e.Order.IsEnabled {
e.Order.Value = nil
}
physics.StartMove(&e.Move, e.Position, destination, moveMap)
return
}
if e.Spawn.IsEnabled {
slog.Info("Setting spawn target")
e.Spawn.Value.SpawnTarget = ecs.C(destination)
return
}
}
|