Split entity manager

This commit is contained in:
hodasemi 2024-08-25 09:11:52 +02:00
parent 6893b8d285
commit 15d93ea74b
24 changed files with 57 additions and 51 deletions

View file

@ -19,7 +19,7 @@ members = [
"scene_update_macros",
"transaction_derive",
"map",
"rpg_components",
"rpg_components", "entity_manager",
]
[workspace.dependencies]

11
entity_manager/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "entity_manager"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = { workspace = true }
assetpath = { workspace = true }
serde = { workspace = true }
engine = { path = "../engine" }

View file

@ -3,7 +3,16 @@ use std::{collections::HashMap, time::Duration};
use anyhow::Result;
use engine::prelude::*;
use crate::{AnimationData, AnimationType};
use crate::entityparser::AnimationData;
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug, Serialize, Deserialize)]
pub enum AnimationType {
Move,
Idle,
Cast,
Attack,
// Add more as you need
}
#[derive(PartialEq, Clone, Serialize, Deserialize, Debug)]
struct AnimationLockInfo {

View file

@ -1,14 +1,12 @@
use std::collections::HashMap;
use assetpath::AssetPath;
use crate::HitBox;
use anyhow::Result;
use assetpath::AssetPath;
use engine::prelude::*;
use super::{entity_info::EntityInfo, entity_tags::EntityTags, entityparser::EntityParser};
use crate::{animation_info::AnimationInfo, hitbox::HitBox};
use crate::game::content::prelude::*;
use super::{entity_info::EntityInfo, entity_tags::EntityTags, entityparser::EntityParser};
pub struct EntityManager {
entity_directory: AssetPath,

View file

@ -5,7 +5,9 @@ use assetpath::AssetPath;
use anyhow::Result;
use engine::prelude::*;
use super::{super::prelude::*, entity_tags::EntityTags};
use crate::animation_info::AnimationType;
use super::entity_tags::EntityTags;
use std::collections::HashMap;
use std::{fmt::Display, str::FromStr, time::Duration};

13
entity_manager/src/lib.rs Normal file
View file

@ -0,0 +1,13 @@
mod animation_info;
mod entity_info;
mod entity_manager;
mod entity_tags;
mod entityparser;
mod hitbox;
pub use animation_info::*;
pub use entity_info::EntityInfo;
pub use entity_manager::EntityManager;
pub use entity_tags::EntityTags;
pub use entityparser::*;
pub use hitbox::*;

View file

@ -23,6 +23,7 @@ lua-wrapper = { path = "../lua-wrapper" }
controllable_thread = { path = "../controllable_thread" }
map = { path = "../map" }
rpg_components = { path = "../rpg_components" }
entity_manager = { path = "../entity_manager" }
[features]
wayland = []

View file

@ -7,6 +7,7 @@ pub mod selfcast;
use anyhow::Result;
use cgmath::Vector2;
use engine::prelude::*;
use entity_manager::*;
use rpg_components::components::character_status::CharacterStatus;
use rpg_components::components::level::{Level, LevelUpEvent};
use rpg_components::components::npc_type::{NPCBoss, NPCElite, NPCNormal, NPCType};

View file

@ -1,4 +1,5 @@
use engine::prelude::*;
use entity_manager::*;
use rpg_components::{
components::{abilityloader::AbilityLoader, statistics::Statistics},
damage_type::DamageType,

View file

@ -2,6 +2,7 @@
use anyhow::Result;
use engine::prelude::*;
use entity_manager::*;
use rpg_components::{
components::{abilityloader::AbilityLoader, statistics::Statistics},
items::ability_book::AbilityBook,

View file

@ -4,6 +4,7 @@ use crate::Result;
use engine::prelude::*;
use cgmath::{vec2, InnerSpace, Vector2, Vector3};
use entity_manager::*;
use rpg_components::ability_type::AbilityType;
use rpg_components::components::ability_slots::AbilitySlots;
use rpg_components::components::character_status::CharacterStatus;

View file

@ -2,6 +2,7 @@ use std::{collections::HashSet, time::Duration};
use cgmath::{vec2, Deg, InnerSpace, Matrix2, Vector2};
use engine::prelude::*;
use entity_manager::*;
use rpg_components::{
components::{abilityloader::AbilityLoader, statistics::Statistics},
damage_type::DamageType,

View file

@ -3,6 +3,7 @@ use crate::*;
use anyhow::Result;
use cgmath::Vector3;
use engine::prelude::*;
use entity_manager::*;
use rpg_components::{
components::{level::Level, npc_type::NPCType},
items::Loot,

View file

@ -1,7 +1,3 @@
pub mod animation_info;
pub mod hitbox;
pub mod movement;
mod ability_location_info;
pub mod ai;
mod aoe;
@ -11,34 +7,15 @@ mod entity_faction;
mod ghost;
pub mod health_bar;
mod loot_stash;
pub mod movement;
mod npc_name;
pub use self::{ai::*, aoe_arc::AreaOfEffectArc};
pub use self::{
ability_location_info::*,
animation_info::AnimationInfo,
aoe::*,
damage_number::*,
entity_faction::*,
ghost::*,
health_bar::*,
hitbox::{CollisionEventType, HitBox},
loot_stash::*,
movement::Movement,
npc_name::NPCName,
ability_location_info::*, aoe::*, damage_number::*, entity_faction::*, ghost::*, health_bar::*,
loot_stash::*, movement::Movement, npc_name::NPCName,
};
use serde::{Deserialize, Serialize};
pub const MOVEMENT_MAX_THRESHOLD: f32 = 0.8;
pub const MOVEMENT_MIN_THRESHOLD: f32 = 0.4;
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug, Serialize, Deserialize)]
pub enum AnimationType {
Move,
Idle,
Cast,
Attack,
// Add more as you need
}

View file

@ -1,8 +1,8 @@
use cgmath;
use cgmath::Vector2;
use engine::prelude::*;
use entity_manager::*;
use super::super::prelude::*;
use super::{MOVEMENT_MAX_THRESHOLD, MOVEMENT_MIN_THRESHOLD};
use std::time::Duration;

View file

@ -1,6 +1,7 @@
use std::{collections::HashMap, str::FromStr};
use cgmath::{vec2, Deg, Rad, Vector2, Vector3};
use entity_manager::*;
use crate::*;

View file

@ -2,6 +2,7 @@ use anyhow::Result;
use assetpath::AssetPath;
use cgmath::{vec2, Vector2};
use engine::prelude::*;
use entity_manager::*;
use rpg_components::{
ability_type::AbilityType,
components::{

View file

@ -1,7 +1,2 @@
pub mod hero;
pub mod entity_info;
pub mod entity_manager;
pub mod entity_tags;
pub mod entityparser;
pub mod npc;

View file

@ -10,9 +10,9 @@ use anyhow::Result;
use assetpath::AssetPath;
use cgmath::{vec3, Deg, InnerSpace, Vector3, Zero};
use engine::prelude::*;
use entity_manager::*;
use rpg_components::{
components::{
ability_slots::AbilitySlots,
attributes::Attributes,
character_status::CharacterStatus,
level::Level,

View file

@ -2,11 +2,4 @@ pub use super::abilities::prelude::*;
pub use super::components::*;
pub use super::lightning::{Lightning, LightningMarker};
pub use super::objects::hero::{Hero, MainUser};
pub use super::objects::{
entity_manager::EntityManager,
entity_tags::EntityTags,
entityparser::{
AnimationData, EntityParser, SOUND_CREATE_KEY, SOUND_DESTROY_KEY, SOUND_MOVE_KEY,
},
npc::{NPCAbilitySlot, NPCFactory, NPCSettings},
};
pub use super::objects::npc::{NPCAbilitySlot, NPCFactory, NPCSettings};

View file

@ -6,6 +6,7 @@ use assetpath::AssetPath;
// use lua_wrapper::LuaFunction;
use anyhow::Result;
use entity_manager::*;
use lua_wrapper::LuaFunction;
use rpg_components::config::abilities::AbilitySettings;
use rpg_components::config::attributes::AttributeSettings;
@ -20,11 +21,9 @@ use std::{fs::create_dir_all, path::Path, sync::Arc};
// game
use crate::game::configloader::*;
use crate::game::content::prelude::*;
use crate::loader::settings::*;
use cgmath::Vector3;
use promise::Promise;
use super::handle::{StrongHandle, WeakHandle};