Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mubelotix committed Jan 4, 2024
1 parent d6de431 commit c066c85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 20 additions & 2 deletions minecraft-server/src/entities/monsters/zombies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,25 @@ pub async fn sleep_ticks(server_msg_rcvr: &mut BroadcastReceiver<ServerMessage>,
}
}

const ZOOMBIE_SPEED: f64 = 0.2; // Arbitrary value
const ZOMBIE_SPEED: f64 = 0.2; // Arbitrary value

struct ZombieTask {
newton_task: NewtonTask<Zombie>,
target: Option<Eid>,
}

impl ZombieTask {
async fn init(h: Handler<Zombie>) -> Option<ZombieTask> {
let Some(newton_task) = NewtonTask::new(h).await else { return None; };
Some(ZombieTask {
newton_task,
})
}

async fn tick(&mut self, h: Handler<Zombie>) {
self.newton_task.tick(h).await;
}
}

pub async fn zombie_ai_task<T: EntityDescendant + ZombieDescendant>(h: Handler<T>, mut server_msg_rcvr: BroadcastReceiver<ServerMessage>) where AnyEntity: TryAsEntityRef<T> {
loop {
Expand Down Expand Up @@ -65,7 +83,7 @@ pub async fn zombie_ai_task<T: EntityDescendant + ZombieDescendant>(h: Handler<T
y: target_position.y - self_position.y,
z: target_position.z - self_position.z,
};
translation.set_norm(ZOOMBIE_SPEED);
translation.set_norm(ZOMBIE_SPEED);

let authorized_translation = h.world.try_move(&target_object, &translation).await;

Expand Down
4 changes: 4 additions & 0 deletions minecraft-server/src/entities/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ pub use super::*;

mod newton;
pub use newton::*;

pub trait EntityTask {
async fn init();
}

0 comments on commit c066c85

Please sign in to comment.