Task Infrastructure — Task Enum, Queue, Events, Executor
This commit is contained in:
@@ -3,11 +3,13 @@ use crate::constants::TILE_SIZE;
|
||||
use crate::constants::*;
|
||||
use crate::entities::cargo::{CarryVisualState, HaulSlot};
|
||||
use crate::entities::shared_components::Ambulatory;
|
||||
use crate::entities::tasks::{Task, TaskQueue, TaskState};
|
||||
use crate::game::SpawnDelay;
|
||||
use crate::world::VisibleGameEntity;
|
||||
use bevy::prelude::*;
|
||||
use bevy_rand::prelude::*;
|
||||
use rand::RngExt;
|
||||
use smallvec::smallvec;
|
||||
|
||||
#[derive(Bundle)]
|
||||
pub struct Dorf {
|
||||
@@ -17,6 +19,8 @@ pub struct Dorf {
|
||||
visibility: Visibility,
|
||||
haul_slot: HaulSlot,
|
||||
carry_visual: CarryVisualState,
|
||||
task_queue: TaskQueue,
|
||||
task_state: TaskState,
|
||||
}
|
||||
|
||||
impl Dorf {
|
||||
@@ -25,6 +29,7 @@ impl Dorf {
|
||||
let run_speed = 6.;
|
||||
let normal_sprite = asset_server.load("dorf.png");
|
||||
let carry_sprite = asset_server.load("dorf.png");
|
||||
let origin = (position / TILE_SIZE).as_ivec3();
|
||||
|
||||
Dorf {
|
||||
ambulatory: Ambulatory {
|
||||
@@ -47,6 +52,14 @@ impl Dorf {
|
||||
visibility: Visibility::Hidden,
|
||||
haul_slot: HaulSlot::default(),
|
||||
carry_visual: CarryVisualState::new(normal_sprite, carry_sprite),
|
||||
task_queue: TaskQueue {
|
||||
tasks: smallvec![Task::Idle {
|
||||
target: origin,
|
||||
wander_radius: 10,
|
||||
origin,
|
||||
}],
|
||||
},
|
||||
task_state: TaskState::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user