ashscript_types/
actions.rs

1use hexx::Hex;
2use uuid::Uuid;
3
4use crate::{objects::Attackable, resource::Resource};
5
6// REMINDER: These are intents that the server validates and wants executed
7
8#[derive(Default)]
9pub struct ActionsByKind {
10    pub unit_move: Vec<UnitMove>,
11    pub unit_attack: Vec<UnitAttack>,
12    pub turret_attack: Vec<TurretAttack>,
13    pub factory_spawn_unit: Vec<FactorySpawnUnit>,
14    pub unit_spawn_unit: Vec<UnitSpawnUnit>,
15    pub resource_transfer: Vec<ResourceTransfer>,
16}
17
18impl ActionsByKind {
19    pub fn new() -> Self {
20        Self {
21            ..Default::default()
22        }
23    }
24}
25
26pub struct UnitMove {
27    pub from: Hex,
28    pub to: Hex,
29    pub cost: u32,
30}
31pub struct UnitAttack {
32    pub attacker_hex: Hex,
33    pub target_hex: Hex,
34    pub target_kind: Attackable,
35    pub cost: u32,
36    pub damage: u32,
37}
38
39pub struct TurretAttack {
40    pub turret_hex: Hex,
41    pub target_hex: Hex,
42    pub target_kind: Attackable,
43    pub damage: u32,
44    pub cost: u32,
45}
46
47pub struct FactorySpawnUnit {
48    pub factory_id: Uuid,
49    pub unit_id: u32,
50    pub out: Hex,
51}
52
53pub struct UnitSpawnUnit {
54    pub parent_id: Uuid,
55    pub child_id: Uuid,
56    pub out: Hex,
57}
58
59pub struct ResourceTransfer {
60    pub resource: Resource,
61    pub amount: u32,
62    pub from_id: Uuid,
63    pub to_id: Uuid,
64}
65
66pub struct ObjectDestroyed {
67    pub id: Uuid,
68}