aboutsummaryrefslogtreecommitdiff
path: root/order.go
blob: f8ef06d6db70b04f84b9ee7c52f67a7d9c09592e (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

package main

import "age_of_empires/physics"

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 !e.Selection.IsEnabled || !e.Selection.Value.IsSelected {
		return
	}
	if entityAtDestination != nil && entityAtDestination.ResourceSource.IsEnabled {
		Gather(e, entityAtDestination, g)
		return
	}
	physics.StartMove(&e.Move, e.Position, destination, moveMap)
}