diff --git a/common/src/comp/presence.rs b/common/src/comp/presence.rs index a57620e3cc..7148d220a7 100644 --- a/common/src/comp/presence.rs +++ b/common/src/comp/presence.rs @@ -34,9 +34,9 @@ impl Component for Presence { #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum PresenceKind { Spectator, - // Note: we don't know if this character ID is valid and associated with the respective player - // until it the character has loaded successfully. The ID should only be trusted and included - // in the mapping when the variant changed to `Character`. + // Note: we don't know if this character ID is valid and associated with the player until the + // character has loaded successfully. The ID should only be trusted and included in the + // mapping when the variant is changed to `Character`. LoadingCharacter(CharacterId), Character(CharacterId), Possessor, diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 3654097a05..0503ad7f1f 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -18,7 +18,7 @@ use common::{ outcome::Outcome, resources::{Secs, Time}, rtsim::RtSimVehicle, - uid::Uid, + uid::{IdMaps, Uid}, util::Dir, vol::IntoFullVolIterator, ViewDistances, @@ -140,7 +140,7 @@ pub fn handle_create_npc(server: &mut Server, pos: Pos, mut npc: NpcBuilder) -> entity }; - // TODO: rtsim entity added here + // Rtsim entity added to IdMaps below. let entity = if let Some(rtsim_entity) = npc.rtsim_entity { entity.with(rtsim_entity).with(RepositionOnChunkLoad { needs_ground: false, @@ -157,6 +157,14 @@ pub fn handle_create_npc(server: &mut Server, pos: Pos, mut npc: NpcBuilder) -> let new_entity = entity.build(); + if let Some(rtsim_entity) = npc.rtsim_entity { + server + .state() + .ecs() + .write_resource::() + .add_rtsim(rtsim_entity, new_entity); + } + // Add to group system if a pet if let comp::Alignment::Owned(owner_uid) = npc.alignment { let state = server.state();