only add RepositionOnChunkLoad to rtsim npcs and don't add Waypoint if it doesn't exist

This commit is contained in:
Isse
2023-04-12 09:24:07 +02:00
parent 3582d86c70
commit 6be4a2b33f
3 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
client::Client, events::player::handle_exit_ingame, persistence::PersistedComponents, sys, client::Client, events::player::handle_exit_ingame, persistence::PersistedComponents, sys,
CharacterUpdater, Server, StateExt, CharacterUpdater, Server, StateExt, presence::RepositionOnChunkLoad,
}; };
use common::{ use common::{
character::CharacterId, character::CharacterId,
@ -131,7 +131,7 @@ pub fn handle_create_npc(server: &mut Server, pos: Pos, mut npc: NpcBuilder) ->
}; };
let entity = if let Some(rtsim_entity) = npc.rtsim_entity { let entity = if let Some(rtsim_entity) = npc.rtsim_entity {
entity.with(rtsim_entity) entity.with(rtsim_entity).with(RepositionOnChunkLoad)
} else { } else {
entity entity
}; };

View File

@ -295,7 +295,6 @@ impl StateExt for State {
.with(comp::Combo::default()) .with(comp::Combo::default())
.with(comp::Auras::default()) .with(comp::Auras::default())
.with(comp::Stance::default()) .with(comp::Stance::default())
.with(RepositionOnChunkLoad)
} }
fn create_object(&mut self, pos: comp::Pos, object: comp::object::Body) -> EcsEntityBuilder { fn create_object(&mut self, pos: comp::Pos, object: comp::object::Body) -> EcsEntityBuilder {

View File

@ -251,7 +251,9 @@ impl<'a> System<'a> for Sys {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for (entity, new_pos) in repositioned { for (entity, new_pos) in repositioned {
let _ = waypoints.insert(entity, Waypoint::new(new_pos, *time)); if let Some(waypoint) = waypoints.get_mut(entity) {
*waypoint = Waypoint::new(new_pos, *time);
}
reposition_on_load.remove(entity); reposition_on_load.remove(entity);
} }