rust/lib-hwengine-future/src/ai/action.rs
author unC0Rr
Tue, 17 Dec 2024 15:44:21 +0100
branchtransitional_engine
changeset 16049 db18f1a30b0c
parent 16040 6c5b3c576fc6
permissions -rw-r--r--
Implement passing of available ammo to rust AI
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16040
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     1
#[derive(Clone)]
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     2
pub enum Direction {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     3
    Left,
16049
db18f1a30b0c Implement passing of available ammo to rust AI
unC0Rr
parents: 16040
diff changeset
     4
    Right,
16040
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     5
}
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     6
#[derive(Clone)]
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     7
pub enum Action {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     8
    Walk(Direction),
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
     9
    LongJump,
16049
db18f1a30b0c Implement passing of available ammo to rust AI
unC0Rr
parents: 16040
diff changeset
    10
    HighJump(usize),
16040
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    11
}
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    12
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    13
pub struct Actions {
16049
db18f1a30b0c Implement passing of available ammo to rust AI
unC0Rr
parents: 16040
diff changeset
    14
    actions: Vec<Action>,
16040
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    15
}
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    16
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    17
impl Actions {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    18
    pub fn new() -> Self {
16049
db18f1a30b0c Implement passing of available ammo to rust AI
unC0Rr
parents: 16040
diff changeset
    19
        Self { actions: vec![] }
16040
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    20
    }
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    21
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    22
    pub fn push(&mut self, action: Action) {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    23
        self.actions.push(action)
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    24
    }
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    25
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    26
    pub fn pop(&mut self) -> Option<Action> {
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    27
        self.actions.pop()
6c5b3c576fc6 Add some progress on rust AI
unC0Rr
parents:
diff changeset
    28
    }
16049
db18f1a30b0c Implement passing of available ammo to rust AI
unC0Rr
parents: 16040
diff changeset
    29
}