-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
289 additions
and
195 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ version.workspace = true | |
edition.workspace = true | ||
|
||
[dependencies] | ||
pumpkin-core = { path = "../pumpkin-core"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,4 @@ | ||
use entity_type::EntityType; | ||
use pose::EntityPose; | ||
use pumpkin_core::math::{ | ||
get_section_cord, position::WorldPosition, vector2::Vector2, vector3::Vector3, | ||
}; | ||
|
||
pub mod entity_type; | ||
pub mod pose; | ||
|
||
pub type EntityId = i32; | ||
|
||
pub struct Entity { | ||
pub entity_id: EntityId, | ||
pub entity_type: EntityType, | ||
pub pos: Vector3<f64>, | ||
pub block_pos: WorldPosition, | ||
pub chunk_pos: Vector2<i32>, | ||
|
||
pub yaw: f32, | ||
pub head_yaw: f32, | ||
pub pitch: f32, | ||
// TODO: Change this in diffrent poses | ||
pub standing_eye_height: f32, | ||
pub pose: EntityPose, | ||
} | ||
|
||
impl Entity { | ||
pub fn new(entity_id: EntityId, entity_type: EntityType, standing_eye_height: f32) -> Self { | ||
Self { | ||
entity_id, | ||
entity_type, | ||
pos: Vector3::new(0.0, 0.0, 0.0), | ||
block_pos: WorldPosition(Vector3::new(0, 0, 0)), | ||
chunk_pos: Vector2::new(0, 0), | ||
yaw: 0.0, | ||
head_yaw: 0.0, | ||
pitch: 0.0, | ||
standing_eye_height, | ||
pose: EntityPose::Standing, | ||
} | ||
} | ||
|
||
pub fn set_pos(&mut self, x: f64, y: f64, z: f64) { | ||
if self.pos.x != x || self.pos.y != y || self.pos.z != z { | ||
self.pos = Vector3::new(x, y, z); | ||
let i = x.floor() as i32; | ||
let j = y.floor() as i32; | ||
let k = z.floor() as i32; | ||
|
||
let block_pos = self.block_pos.0; | ||
if i != block_pos.x || j != block_pos.y || k != block_pos.z { | ||
self.block_pos = WorldPosition(Vector3::new(i, j, k)); | ||
|
||
if get_section_cord(i) != self.chunk_pos.x | ||
|| get_section_cord(k) != self.chunk_pos.z | ||
{ | ||
self.chunk_pos = | ||
Vector2::new(get_section_cord(block_pos.x), get_section_cord(block_pos.z)); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.