2024-07-06 13:33:58 +02:00
|
|
|
use crate::{
|
|
|
|
activities::{house, overworld, Activity},
|
|
|
|
State
|
|
|
|
};
|
2024-07-07 00:52:19 +02:00
|
|
|
use comfy::{EngineContext, IVec2};
|
2024-07-06 20:23:25 +00:00
|
|
|
use std::ops::Sub;
|
|
|
|
|
2024-07-06 20:45:05 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Ghost {
|
|
|
|
/// current electric charge of the Ghost
|
|
|
|
pub charge: f32,
|
|
|
|
/// max electric charge of the Ghost
|
2024-07-07 00:52:19 +02:00
|
|
|
pub max_charge: f32,
|
|
|
|
pub overworld_pos: IVec2,
|
2024-07-06 20:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Ghost {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
charge: 1000.0,
|
2024-07-07 00:52:19 +02:00
|
|
|
max_charge: 1000.0,
|
|
|
|
overworld_pos: IVec2::ZERO,
|
2024-07-06 20:45:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-06 20:23:25 +00:00
|
|
|
#[repr(i32)]
|
|
|
|
pub enum ZLayer {
|
|
|
|
MapMax = -1,
|
|
|
|
Human = 0,
|
|
|
|
Ghost = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ZLayer> for i32 {
|
|
|
|
fn from(value: ZLayer) -> Self {
|
|
|
|
// safe because #[repr(i32)]
|
|
|
|
value as i32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Sub<i32> for ZLayer {
|
|
|
|
type Output = i32;
|
|
|
|
|
|
|
|
fn sub(self, other: i32) -> Self::Output {
|
|
|
|
i32::from(self) - other
|
|
|
|
}
|
|
|
|
}
|
2024-07-05 23:10:25 +02:00
|
|
|
|
2024-07-06 20:23:25 +00:00
|
|
|
pub fn update(state: &mut State, engine: &mut EngineContext<'_>) {
|
2024-07-06 13:33:58 +02:00
|
|
|
match state.activity {
|
|
|
|
Activity::House => house::update(state, engine),
|
|
|
|
Activity::Overworld => overworld::update(state, engine)
|
|
|
|
}
|
2024-07-05 23:16:53 +02:00
|
|
|
}
|
2024-07-05 23:10:25 +02:00
|
|
|
|
2024-07-06 20:23:25 +00:00
|
|
|
pub fn draw(state: &State, engine: &EngineContext<'_>) {
|
2024-07-06 13:33:58 +02:00
|
|
|
match state.activity {
|
|
|
|
Activity::House => house::draw(state, engine),
|
|
|
|
Activity::Overworld => overworld::draw(state, engine)
|
|
|
|
}
|
2024-07-06 20:45:05 +00:00
|
|
|
crate::ui::draw(state, engine);
|
2024-07-05 23:10:25 +02:00
|
|
|
}
|