Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I'm using specs for ECS.
- #[derive(Component, Debug, Clone)]
- #[storage(DenseVecStorage)]
- pub struct Navigator {
- destination: Destination,
- path: PathState
- }
- impl Navigator {
- // Is `navigate` the correct thing to write?
- // It borrows itself mutably to assign the destination and path.
- // This will only be called from systems.
- // But the problem is I do not want the destination to be mutated from
- // outside without setting `path` to `PathState::Finding`.
- pub fn navigate(&mut self, destination: Destination) {
- self.destination = destination;
- self.path = PathState::Finding;
- }
- pub fn destination(&self) -> Destination {
- self.destination
- }
- pub fn arrived(&self) -> bool {
- self.path == PathState::Arrived
- }
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement