-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(entity): Entity state, queues (#5)
* feat(entity): entity actions queue, state machine * chore(entity): cago fmt * remove useless functions * cargo fmt * Rename EntityCommand to EntityAction
- Loading branch information
1 parent
7388f7b
commit 2823fb3
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
target | ||
Cargo.lock | ||
.idea | ||
logs/ | ||
.idea/ | ||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use super::entity_actions_queue::EntityAction; | ||
use super::entity_actions_queue::EntityActionsQueue; | ||
use super::entity_state::EntityState; | ||
use super::grid::GridPoint; | ||
|
||
pub struct Entity { | ||
pub position: GridPoint, | ||
pub actions: EntityActionsQueue, | ||
pub state: EntityState, | ||
} | ||
|
||
impl Entity { | ||
pub fn new(position: GridPoint) -> Entity { | ||
Entity { | ||
position, | ||
actions: EntityActionsQueue::new(), | ||
state: EntityState::Idle, | ||
} | ||
} | ||
pub fn add_action(&mut self, action: EntityAction) { | ||
self.actions.push_back(action); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use super::grid::GridPoint; | ||
use std::collections::VecDeque; | ||
pub enum EntityAction { | ||
GoTo { destination: GridPoint }, | ||
} | ||
|
||
pub type EntityActionsQueue = VecDeque<EntityAction>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[derive(PartialEq, Copy, Clone, Debug)] | ||
pub enum EntityState { | ||
Idle, | ||
Moving, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters