diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-09-25 23:05:48 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-09-25 23:07:14 +0200 |
| commit | b457ffe1fbb7799beba0bc4b53bc3bf1309ae799 (patch) | |
| tree | 91ecf7fc13aa6c490daa60afc874491ca214c3f0 /spawn.go | |
| parent | 7e94ae0184b94f247c16a775b4d6b0172e8b3027 (diff) | |
Get time from Game
Diffstat (limited to 'spawn.go')
| -rw-r--r-- | spawn.go | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,10 +1,11 @@ package main import ( - "age_of_empires/ecs" - "age_of_empires/physics" "log/slog" "time" + + "age_of_empires/ecs" + "age_of_empires/physics" ) type spawnRequest struct { @@ -31,14 +32,14 @@ func (spawn *Spawn) AddRequest(g *Game) { return } g.ResourceAmount -= spawn.UnitResourceCost - spawn.Requests = append(spawn.Requests, spawnRequest{start: time.Now()}) + spawn.Requests = append(spawn.Requests, spawnRequest{start: g.Now()}) } func UpdateSpawn(g *Game, spawn *ecs.Component[Spawn], position ecs.Component[physics.Point]) { if !spawn.IsEnabled || !position.IsEnabled { return } - now := time.Now() + now := g.Now() if len(spawn.Value.Requests) == 0 || now.Sub(spawn.Value.Requests[0].start) < time.Duration(spawn.Value.UnitSpawnDuration) { return } |
