mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add RtsimEntity mapping if it is included as a component on a newly
created npc. Also, improve wording of a comment.
This commit is contained in:
parent
01df87bdb4
commit
42ba445ea2
@ -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,
|
||||
|
@ -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::<IdMaps>()
|
||||
.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();
|
||||
|
Loading…
Reference in New Issue
Block a user