ashscript_types/
intents.rs

1use hexx::Hex;
2
3use crate::{objects::{Attackable}, resource::Resource, unit::UnitBody};
4
5// REMINDER: These are player-generated intents
6
7pub type Intents = Vec<Intent>;
8
9pub enum Intent {
10    UnitMove(UnitMove),
11    UnitAttack(UnitAttack),
12    TurretAttack(TurretAttack),
13    FactorySpawnUnit(FactorySpawnUnit),
14    UnitSpawnUnit(UnitSpawnUnit),
15    ResourceTransfer(ResourceTransfer),
16}
17
18#[derive(enum_map::Enum, Hash, Eq, PartialEq, Clone, Copy, Debug)]
19pub enum IntentName {
20    UnitMove,
21    UnitAttack,
22    TurretAttack,
23    FactorySpawnUnit,
24    ResourceTransfer,
25}
26
27
28/// A unit moving from one hex to another
29pub struct UnitMove {
30    pub from: Hex,
31    pub to: Hex,
32}
33
34/// A unit attacking an attackable target
35pub struct UnitAttack {
36    pub attacker_hex: Hex,
37    pub target_hex: Hex,
38    pub target_kind: Attackable,
39}
40
41/// A turret attacking an attackable target
42pub struct TurretAttack {
43    pub turret_hex: Hex,
44    pub target_hex: Hex,
45    pub target_kind: Attackable,
46}
47
48/// The spawning of a unit from a factory
49pub struct FactorySpawnUnit {
50    pub factory_hex: Hex,
51    pub body: UnitBody,
52    pub name: String,
53    /// If out hexes are not provided the engine will choose the first empty one in a clockwise direction
54    /// If out hexes are provided, sucessfully spawned units will be outputed to the first empty hex 
55    pub out: Option<Vec<Hex>>,
56}
57
58/// The spawning of a unit from a unit
59pub struct UnitSpawnUnit {
60    pub unit_hex: Hex,
61    pub body: UnitBody,
62    pub name: String,
63    /// If out hexes are not provided the engine will choose the first empty one in a clockwise direction
64    /// If out hexes are provided, sucessfully spawned units will be outputed to the first empty hex 
65    pub out: Option<Vec<Hex>>,
66}
67
68/// A resource transfer from one storable object to another
69pub struct ResourceTransfer {
70    pub resource: Resource,
71    pub amount: u32,
72    pub from_hex: Hex,
73    pub to_hex: Hex,
74}