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

Commit c066c85

Browse files
committed
temp
1 parent d6de431 commit c066c85

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

minecraft-server/src/entities/monsters/zombies.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,25 @@ pub async fn sleep_ticks(server_msg_rcvr: &mut BroadcastReceiver<ServerMessage>,
3434
}
3535
}
3636

37-
const ZOOMBIE_SPEED: f64 = 0.2; // Arbitrary value
37+
const ZOMBIE_SPEED: f64 = 0.2; // Arbitrary value
38+
39+
struct ZombieTask {
40+
newton_task: NewtonTask<Zombie>,
41+
target: Option<Eid>,
42+
}
43+
44+
impl ZombieTask {
45+
async fn init(h: Handler<Zombie>) -> Option<ZombieTask> {
46+
let Some(newton_task) = NewtonTask::new(h).await else { return None; };
47+
Some(ZombieTask {
48+
newton_task,
49+
})
50+
}
51+
52+
async fn tick(&mut self, h: Handler<Zombie>) {
53+
self.newton_task.tick(h).await;
54+
}
55+
}
3856

3957
pub async fn zombie_ai_task<T: EntityDescendant + ZombieDescendant>(h: Handler<T>, mut server_msg_rcvr: BroadcastReceiver<ServerMessage>) where AnyEntity: TryAsEntityRef<T> {
4058
loop {
@@ -65,7 +83,7 @@ pub async fn zombie_ai_task<T: EntityDescendant + ZombieDescendant>(h: Handler<T
6583
y: target_position.y - self_position.y,
6684
z: target_position.z - self_position.z,
6785
};
68-
translation.set_norm(ZOOMBIE_SPEED);
86+
translation.set_norm(ZOMBIE_SPEED);
6987

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

minecraft-server/src/entities/tasks/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ pub use super::*;
22

33
mod newton;
44
pub use newton::*;
5+
6+
pub trait EntityTask {
7+
async fn init();
8+
}

0 commit comments

Comments
 (0)