mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Rename retrieve_entity_internal to lookup_entity
This commit is contained in:
@ -77,8 +77,7 @@ impl WorldSyncExt for specs::World {
|
|||||||
|
|
||||||
/// Get an entity from a UID
|
/// Get an entity from a UID
|
||||||
fn entity_from_uid(&self, uid: Uid) -> Option<specs::Entity> {
|
fn entity_from_uid(&self, uid: Uid) -> Option<specs::Entity> {
|
||||||
self.read_resource::<UidAllocator>()
|
self.read_resource::<UidAllocator>().lookup_entity(uid)
|
||||||
.retrieve_entity_internal(uid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_entity_package<P: CompPacket>(
|
fn apply_entity_package<P: CompPacket>(
|
||||||
@ -119,7 +118,7 @@ impl WorldSyncExt for specs::World {
|
|||||||
package.comp_updates.into_iter().for_each(|(uid, update)| {
|
package.comp_updates.into_iter().for_each(|(uid, update)| {
|
||||||
if let Some(entity) = self
|
if let Some(entity) = self
|
||||||
.read_resource::<UidAllocator>()
|
.read_resource::<UidAllocator>()
|
||||||
.retrieve_entity_internal(uid.into())
|
.lookup_entity(uid.into())
|
||||||
{
|
{
|
||||||
let force_update = player_entity == Some(entity);
|
let force_update = player_entity == Some(entity);
|
||||||
match update {
|
match update {
|
||||||
@ -143,7 +142,7 @@ fn create_entity_with_uid(specs_world: &mut specs::World, entity_uid: u64) -> sp
|
|||||||
let entity_uid = Uid::from(entity_uid);
|
let entity_uid = Uid::from(entity_uid);
|
||||||
let existing_entity = specs_world
|
let existing_entity = specs_world
|
||||||
.read_resource::<UidAllocator>()
|
.read_resource::<UidAllocator>()
|
||||||
.retrieve_entity_internal(entity_uid);
|
.lookup_entity(entity_uid);
|
||||||
|
|
||||||
match existing_entity {
|
match existing_entity {
|
||||||
Some(entity) => entity,
|
Some(entity) => entity,
|
||||||
|
@ -725,9 +725,7 @@ pub fn may_harm(
|
|||||||
if let Some(Alignment::Owned(uid)) = alignment {
|
if let Some(Alignment::Owned(uid)) = alignment {
|
||||||
// return original entity
|
// return original entity
|
||||||
// if can't get owner
|
// if can't get owner
|
||||||
uid_allocator
|
uid_allocator.lookup_entity(uid).unwrap_or(entity)
|
||||||
.retrieve_entity_internal(uid)
|
|
||||||
.unwrap_or(entity)
|
|
||||||
} else {
|
} else {
|
||||||
entity
|
entity
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ impl Link for Mounting {
|
|||||||
this: &LinkHandle<Self>,
|
this: &LinkHandle<Self>,
|
||||||
(uid_allocator, is_mounts, is_riders, is_volume_rider): &mut Self::CreateData<'_>,
|
(uid_allocator, is_mounts, is_riders, is_volume_rider): &mut Self::CreateData<'_>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
let entity = |uid: Uid| uid_allocator.retrieve_entity_internal(uid);
|
let entity = |uid: Uid| uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
if this.mount == this.rider {
|
if this.mount == this.rider {
|
||||||
// Forbid self-mounting
|
// Forbid self-mounting
|
||||||
@ -99,7 +99,7 @@ impl Link for Mounting {
|
|||||||
this: &LinkHandle<Self>,
|
this: &LinkHandle<Self>,
|
||||||
(uid_allocator, entities, healths, bodies, is_mounts, is_riders, character_states): &mut Self::PersistData<'_>,
|
(uid_allocator, entities, healths, bodies, is_mounts, is_riders, character_states): &mut Self::PersistData<'_>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let entity = |uid: Uid| uid_allocator.retrieve_entity_internal(uid);
|
let entity = |uid: Uid| uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
if let Some((mount, rider)) = entity(this.mount).zip(entity(this.rider)) {
|
if let Some((mount, rider)) = entity(this.mount).zip(entity(this.rider)) {
|
||||||
let is_alive = |entity| {
|
let is_alive = |entity| {
|
||||||
@ -128,7 +128,7 @@ impl Link for Mounting {
|
|||||||
this: &LinkHandle<Self>,
|
this: &LinkHandle<Self>,
|
||||||
(uid_allocator, is_mounts, is_riders, positions, force_update, terrain): &mut Self::DeleteData<'_>,
|
(uid_allocator, is_mounts, is_riders, positions, force_update, terrain): &mut Self::DeleteData<'_>,
|
||||||
) {
|
) {
|
||||||
let entity = |uid: Uid| uid_allocator.retrieve_entity_internal(uid);
|
let entity = |uid: Uid| uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
let mount = entity(this.mount);
|
let mount = entity(this.mount);
|
||||||
let rider = entity(this.rider);
|
let rider = entity(this.rider);
|
||||||
@ -228,9 +228,7 @@ impl VolumePos {
|
|||||||
comp::Ori::default(),
|
comp::Ori::default(),
|
||||||
*terrain.get(self.pos).ok()?,
|
*terrain.get(self.pos).ok()?,
|
||||||
)),
|
)),
|
||||||
Volume::Entity(uid) => uid_allocator
|
Volume::Entity(uid) => uid_allocator.lookup_entity(uid).and_then(|entity| {
|
||||||
.retrieve_entity_internal(uid)
|
|
||||||
.and_then(|entity| {
|
|
||||||
let collider = colliders.get(entity)?;
|
let collider = colliders.get(entity)?;
|
||||||
let (pos, ori) = read_pos_and_ori(entity)?;
|
let (pos, ori) = read_pos_and_ori(entity)?;
|
||||||
|
|
||||||
@ -258,9 +256,7 @@ impl VolumePos {
|
|||||||
) -> Option<Block> {
|
) -> Option<Block> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Volume::Terrain => Some(*terrain.get(self.pos).ok()?),
|
Volume::Terrain => Some(*terrain.get(self.pos).ok()?),
|
||||||
Volume::Entity(uid) => uid_allocator
|
Volume::Entity(uid) => uid_allocator.lookup_entity(uid).and_then(|entity| {
|
||||||
.retrieve_entity_internal(uid)
|
|
||||||
.and_then(|entity| {
|
|
||||||
let collider = colliders.get(entity)?;
|
let collider = colliders.get(entity)?;
|
||||||
|
|
||||||
let voxel_colliders_manifest = VOXEL_COLLIDER_MANIFEST.read();
|
let voxel_colliders_manifest = VOXEL_COLLIDER_MANIFEST.read();
|
||||||
@ -330,7 +326,7 @@ impl Link for VolumeMounting {
|
|||||||
colliders,
|
colliders,
|
||||||
): &mut Self::CreateData<'_>,
|
): &mut Self::CreateData<'_>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
let entity = |uid: Uid| uid_allocator.retrieve_entity_internal(uid.into());
|
let entity = |uid: Uid| uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
let riders = match this.pos.kind {
|
let riders = match this.pos.kind {
|
||||||
Volume::Terrain => &mut *terrain_riders,
|
Volume::Terrain => &mut *terrain_riders,
|
||||||
@ -375,7 +371,7 @@ impl Link for VolumeMounting {
|
|||||||
colliders,
|
colliders,
|
||||||
): &mut Self::PersistData<'_>,
|
): &mut Self::PersistData<'_>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let entity = |uid: Uid| uid_allocator.retrieve_entity_internal(uid.into());
|
let entity = |uid: Uid| uid_allocator.lookup_entity(uid);
|
||||||
let is_alive =
|
let is_alive =
|
||||||
|entity| entities.is_alive(entity) && healths.get(entity).map_or(true, |h| !h.is_dead);
|
|entity| entities.is_alive(entity) && healths.get(entity).map_or(true, |h| !h.is_dead);
|
||||||
let riders = match this.pos.kind {
|
let riders = match this.pos.kind {
|
||||||
@ -407,7 +403,7 @@ impl Link for VolumeMounting {
|
|||||||
this: &LinkHandle<Self>,
|
this: &LinkHandle<Self>,
|
||||||
(terrain_riders, volume_riders, is_rider, uid_allocator): &mut Self::DeleteData<'_>,
|
(terrain_riders, volume_riders, is_rider, uid_allocator): &mut Self::DeleteData<'_>,
|
||||||
) {
|
) {
|
||||||
let entity = |uid: Uid| uid_allocator.retrieve_entity_internal(uid.into());
|
let entity = |uid: Uid| uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
let riders = match this.pos.kind {
|
let riders = match this.pos.kind {
|
||||||
Volume::Terrain => Some(&mut **terrain_riders),
|
Volume::Terrain => Some(&mut **terrain_riders),
|
||||||
|
@ -55,9 +55,7 @@ impl UidAllocator {
|
|||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn retrieve_entity_internal(&self, id: Uid) -> Option<Entity> {
|
pub fn lookup_entity(&self, id: Uid) -> Option<Entity> { self.mapping.get(&id).copied() }
|
||||||
self.mapping.get(&id).copied()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
@ -238,9 +238,13 @@ fn retrieve_action(
|
|||||||
EcsAccessError::EcsPointerNotAvailable,
|
EcsAccessError::EcsPointerNotAvailable,
|
||||||
))?
|
))?
|
||||||
};
|
};
|
||||||
let player = world.uid_allocator.retrieve_entity_internal(e).ok_or(
|
let player =
|
||||||
RetrieveError::EcsAccessError(EcsAccessError::EcsEntityNotFound(e)),
|
world
|
||||||
)?;
|
.uid_allocator
|
||||||
|
.lookup_entity(e)
|
||||||
|
.ok_or(RetrieveError::EcsAccessError(
|
||||||
|
EcsAccessError::EcsEntityNotFound(e),
|
||||||
|
))?;
|
||||||
|
|
||||||
Ok(RetrieveResult::GetPlayerName(
|
Ok(RetrieveResult::GetPlayerName(
|
||||||
world
|
world
|
||||||
@ -263,9 +267,13 @@ fn retrieve_action(
|
|||||||
EcsAccessError::EcsPointerNotAvailable,
|
EcsAccessError::EcsPointerNotAvailable,
|
||||||
))?
|
))?
|
||||||
};
|
};
|
||||||
let player = world.uid_allocator.retrieve_entity_internal(e).ok_or(
|
let player =
|
||||||
RetrieveError::EcsAccessError(EcsAccessError::EcsEntityNotFound(e)),
|
world
|
||||||
)?;
|
.uid_allocator
|
||||||
|
.lookup_entity(e)
|
||||||
|
.ok_or(RetrieveError::EcsAccessError(
|
||||||
|
EcsAccessError::EcsEntityNotFound(e),
|
||||||
|
))?;
|
||||||
Ok(RetrieveResult::GetEntityHealth(
|
Ok(RetrieveResult::GetEntityHealth(
|
||||||
world
|
world
|
||||||
.health
|
.health
|
||||||
|
@ -96,7 +96,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
let same_group = |uid: Uid| {
|
let same_group = |uid: Uid| {
|
||||||
read_data
|
read_data
|
||||||
.uid_allocator
|
.uid_allocator
|
||||||
.retrieve_entity_internal(uid)
|
.lookup_entity(uid)
|
||||||
.and_then(|e| read_data.groups.get(e))
|
.and_then(|e| read_data.groups.get(e))
|
||||||
.map_or(false, |owner_group| {
|
.map_or(false, |owner_group| {
|
||||||
Some(owner_group) == read_data.groups.get(target)
|
Some(owner_group) == read_data.groups.get(target)
|
||||||
@ -166,9 +166,7 @@ fn activate_aura(
|
|||||||
Alignment::Owned(uid) => Some(uid),
|
Alignment::Owned(uid) => Some(uid),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.and_then(|uid| {
|
.and_then(|uid| read_data.uid_allocator.lookup_entity(*uid))
|
||||||
read_data.uid_allocator.retrieve_entity_internal(*uid)
|
|
||||||
})
|
|
||||||
.and_then(|owner| read_data.char_states.get(owner))
|
.and_then(|owner| read_data.char_states.get(owner))
|
||||||
.map_or(false, CharacterState::is_sitting))
|
.map_or(false, CharacterState::is_sitting))
|
||||||
},
|
},
|
||||||
@ -185,9 +183,7 @@ fn activate_aura(
|
|||||||
// when we will add this.
|
// when we will add this.
|
||||||
let may_harm = || {
|
let may_harm = || {
|
||||||
let owner = match source {
|
let owner = match source {
|
||||||
BuffSource::Character { by } => {
|
BuffSource::Character { by } => read_data.uid_allocator.lookup_entity(by),
|
||||||
read_data.uid_allocator.retrieve_entity_internal(by)
|
|
||||||
},
|
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
combat::may_harm(
|
combat::may_harm(
|
||||||
|
@ -97,7 +97,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
let beam_owner = beam_segment
|
let beam_owner = beam_segment
|
||||||
.owner
|
.owner
|
||||||
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid));
|
.and_then(|uid| read_data.uid_allocator.lookup_entity(uid));
|
||||||
|
|
||||||
// Note: rayon makes it difficult to hold onto a thread-local RNG, if grabbing
|
// Note: rayon makes it difficult to hold onto a thread-local RNG, if grabbing
|
||||||
// this becomes a bottleneck we can look into alternatives.
|
// this becomes a bottleneck we can look into alternatives.
|
||||||
|
@ -275,10 +275,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.for_each(|(buff_id, buff, uid, aura_key)| {
|
.for_each(|(buff_id, buff, uid, aura_key)| {
|
||||||
let replace = if let Some(aura_entity) = read_data
|
let replace =
|
||||||
.uid_allocator
|
if let Some(aura_entity) = read_data.uid_allocator.lookup_entity(*uid) {
|
||||||
.retrieve_entity_internal((*uid).into())
|
|
||||||
{
|
|
||||||
if let Some(aura) = read_data
|
if let Some(aura) = read_data
|
||||||
.auras
|
.auras
|
||||||
.get(aura_entity)
|
.get(aura_entity)
|
||||||
@ -504,10 +502,7 @@ fn execute_effect(
|
|||||||
ModifierKind::Fractional => health.maximum() * amount,
|
ModifierKind::Fractional => health.maximum() * amount,
|
||||||
};
|
};
|
||||||
let damage_contributor = by.and_then(|uid| {
|
let damage_contributor = by.and_then(|uid| {
|
||||||
read_data
|
read_data.uid_allocator.lookup_entity(uid).map(|entity| {
|
||||||
.uid_allocator
|
|
||||||
.retrieve_entity_internal(uid)
|
|
||||||
.map(|entity| {
|
|
||||||
DamageContributor::new(uid, read_data.groups.get(entity).cloned())
|
DamageContributor::new(uid, read_data.groups.get(entity).cloned())
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -48,9 +48,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
for event in controller.events.drain(..) {
|
for event in controller.events.drain(..) {
|
||||||
match event {
|
match event {
|
||||||
ControlEvent::Mount(mountee_uid) => {
|
ControlEvent::Mount(mountee_uid) => {
|
||||||
if let Some(mountee_entity) = read_data
|
if let Some(mountee_entity) =
|
||||||
.uid_allocator
|
read_data.uid_allocator.lookup_entity(mountee_uid)
|
||||||
.retrieve_entity_internal(mountee_uid)
|
|
||||||
{
|
{
|
||||||
server_emitter.emit(ServerEvent::Mount(entity, mountee_entity));
|
server_emitter.emit(ServerEvent::Mount(entity, mountee_entity));
|
||||||
}
|
}
|
||||||
@ -80,9 +79,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
server_emitter.emit(ServerEvent::DisableLantern(entity))
|
server_emitter.emit(ServerEvent::DisableLantern(entity))
|
||||||
},
|
},
|
||||||
ControlEvent::Interact(npc_uid, subject) => {
|
ControlEvent::Interact(npc_uid, subject) => {
|
||||||
if let Some(npc_entity) =
|
if let Some(npc_entity) = read_data.uid_allocator.lookup_entity(npc_uid) {
|
||||||
read_data.uid_allocator.retrieve_entity_internal(npc_uid)
|
|
||||||
{
|
|
||||||
server_emitter
|
server_emitter
|
||||||
.emit(ServerEvent::NpcInteract(entity, npc_entity, subject));
|
.emit(ServerEvent::NpcInteract(entity, npc_entity, subject));
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
for (entity, is_mount, body) in (&entities, &is_mounts, bodies.maybe()).join() {
|
for (entity, is_mount, body) in (&entities, &is_mounts, bodies.maybe()).join() {
|
||||||
// ...find the rider...
|
// ...find the rider...
|
||||||
let Some((inputs_and_actions, rider)) = uid_allocator
|
let Some((inputs_and_actions, rider)) = uid_allocator
|
||||||
.retrieve_entity_internal(is_mount.rider)
|
.lookup_entity(is_mount.rider)
|
||||||
.and_then(|rider| {
|
.and_then(|rider| {
|
||||||
controllers
|
controllers
|
||||||
.get_mut(rider)
|
.get_mut(rider)
|
||||||
@ -138,7 +138,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
common::mounting::Volume::Terrain => Vec3::zero(),
|
common::mounting::Volume::Terrain => Vec3::zero(),
|
||||||
common::mounting::Volume::Entity(uid) => {
|
common::mounting::Volume::Entity(uid) => {
|
||||||
if let Some(v) = uid_allocator
|
if let Some(v) = uid_allocator
|
||||||
.retrieve_entity_internal(uid.into())
|
.lookup_entity(uid)
|
||||||
.and_then(|e| velocities.get(e))
|
.and_then(|e| velocities.get(e))
|
||||||
{
|
{
|
||||||
v.0
|
v.0
|
||||||
@ -172,7 +172,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
match is_volume_rider.pos.kind {
|
match is_volume_rider.pos.kind {
|
||||||
common::mounting::Volume::Entity(uid) => {
|
common::mounting::Volume::Entity(uid) => {
|
||||||
if let Some(controller) = uid_allocator
|
if let Some(controller) = uid_allocator
|
||||||
.retrieve_entity_internal(uid.into())
|
.lookup_entity(uid)
|
||||||
.and_then(|e| controllers.get_mut(e))
|
.and_then(|e| controllers.get_mut(e))
|
||||||
{
|
{
|
||||||
controller.inputs = inputs;
|
controller.inputs = inputs;
|
||||||
|
@ -85,7 +85,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
{
|
{
|
||||||
let projectile_owner = projectile
|
let projectile_owner = projectile
|
||||||
.owner
|
.owner
|
||||||
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid));
|
.and_then(|uid| read_data.uid_allocator.lookup_entity(uid));
|
||||||
|
|
||||||
if physics.on_surface().is_none() && rng.gen_bool(0.05) {
|
if physics.on_surface().is_none() && rng.gen_bool(0.05) {
|
||||||
server_emitter.emit(ServerEvent::Sound {
|
server_emitter.emit(ServerEvent::Sound {
|
||||||
@ -104,7 +104,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
.and_then(|e| read_data.groups.get(e))
|
.and_then(|e| read_data.groups.get(e))
|
||||||
.map_or(false, |owner_group|
|
.map_or(false, |owner_group|
|
||||||
Some(owner_group) == read_data.uid_allocator
|
Some(owner_group) == read_data.uid_allocator
|
||||||
.retrieve_entity_internal(other)
|
.lookup_entity(other)
|
||||||
.and_then(|e| read_data.groups.get(e))
|
.and_then(|e| read_data.groups.get(e))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
let projectile = &mut *projectile;
|
let projectile = &mut *projectile;
|
||||||
|
|
||||||
let entity_of = |uid: Uid| read_data.uid_allocator.retrieve_entity_internal(uid);
|
let entity_of = |uid: Uid| read_data.uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
// Don't hit if there is terrain between the projectile and where the entity was
|
// Don't hit if there is terrain between the projectile and where the entity was
|
||||||
// supposed to be hit by it.
|
// supposed to be hit by it.
|
||||||
|
@ -91,7 +91,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
let shockwave_owner = shockwave
|
let shockwave_owner = shockwave
|
||||||
.owner
|
.owner
|
||||||
.and_then(|uid| read_data.uid_allocator.retrieve_entity_internal(uid));
|
.and_then(|uid| read_data.uid_allocator.lookup_entity(uid));
|
||||||
|
|
||||||
if rng.gen_bool(0.05) {
|
if rng.gen_bool(0.05) {
|
||||||
server_emitter.emit(ServerEvent::Sound {
|
server_emitter.emit(ServerEvent::Sound {
|
||||||
|
@ -65,7 +65,7 @@ pub fn aim_projectile(speed: f32, pos: Vec3<f32>, tgt: Vec3<f32>) -> Option<Dir>
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_entity_by_id(uid: Uid, read_data: &ReadData) -> Option<EcsEntity> {
|
pub fn get_entity_by_id(uid: Uid, read_data: &ReadData) -> Option<EcsEntity> {
|
||||||
read_data.uid_allocator.retrieve_entity_internal(uid)
|
read_data.uid_allocator.lookup_entity(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates whether the agent should continue chase or let the target escape.
|
/// Calculates whether the agent should continue chase or let the target escape.
|
||||||
|
@ -246,7 +246,7 @@ fn position_mut<T>(
|
|||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.read_resource::<UidAllocator>()
|
.read_resource::<UidAllocator>()
|
||||||
.retrieve_entity_internal(is_rider.mount)
|
.lookup_entity(is_rider.mount)
|
||||||
})
|
})
|
||||||
.map(Ok)
|
.map(Ok)
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
@ -263,7 +263,7 @@ fn position_mut<T>(
|
|||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
.read_resource::<UidAllocator>()
|
.read_resource::<UidAllocator>()
|
||||||
.retrieve_entity_internal(uid.into())?),
|
.lookup_entity(uid)?),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -569,7 +569,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
|
|||||||
state
|
state
|
||||||
.ecs()
|
.ecs()
|
||||||
.read_resource::<UidAllocator>()
|
.read_resource::<UidAllocator>()
|
||||||
.retrieve_entity_internal((*entity_uid).into())
|
.lookup_entity(*entity_uid)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.and_then(|killer| state.entity_as_actor(killer)),
|
.and_then(|killer| state.entity_as_actor(killer)),
|
||||||
@ -742,10 +742,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3<f32>, explosion: Explosion, o
|
|||||||
let settings = server.settings();
|
let settings = server.settings();
|
||||||
let server_eventbus = ecs.read_resource::<EventBus<ServerEvent>>();
|
let server_eventbus = ecs.read_resource::<EventBus<ServerEvent>>();
|
||||||
let time = ecs.read_resource::<Time>();
|
let time = ecs.read_resource::<Time>();
|
||||||
let owner_entity = owner.and_then(|uid| {
|
let owner_entity = owner.and_then(|uid| ecs.read_resource::<UidAllocator>().lookup_entity(uid));
|
||||||
ecs.read_resource::<UidAllocator>()
|
|
||||||
.retrieve_entity_internal(uid)
|
|
||||||
});
|
|
||||||
|
|
||||||
let explosion_volume = 6.25 * explosion.radius;
|
let explosion_volume = 6.25 * explosion.radius;
|
||||||
let mut emitter = server_eventbus.emitter();
|
let mut emitter = server_eventbus.emitter();
|
||||||
|
@ -860,7 +860,7 @@ impl StateExt for State {
|
|||||||
.map_group(|_| group_info.map_or_else(|| "???".to_string(), |i| i.name.clone()));
|
.map_group(|_| group_info.map_or_else(|| "???".to_string(), |i| i.name.clone()));
|
||||||
|
|
||||||
let uid_allocator = ecs.read_resource::<UidAllocator>();
|
let uid_allocator = ecs.read_resource::<UidAllocator>();
|
||||||
let entity_from_uid = |uid| uid_allocator.retrieve_entity_internal(uid);
|
let entity_from_uid = |uid| uid_allocator.lookup_entity(uid);
|
||||||
|
|
||||||
if msg.chat_type.uid().map_or(true, |sender| {
|
if msg.chat_type.uid().map_or(true, |sender| {
|
||||||
entity_from_uid(sender).map_or(false, |e| {
|
entity_from_uid(sender).map_or(false, |e| {
|
||||||
|
@ -102,17 +102,13 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
// The entity that is moving, if riding it's the mount, otherwise it's itself
|
// The entity that is moving, if riding it's the mount, otherwise it's itself
|
||||||
let moving_entity = is_rider
|
let moving_entity = is_rider
|
||||||
.and_then(|is_rider| {
|
.and_then(|is_rider| read_data.uid_allocator.lookup_entity(is_rider.mount))
|
||||||
read_data
|
|
||||||
.uid_allocator
|
|
||||||
.retrieve_entity_internal(is_rider.mount)
|
|
||||||
})
|
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
is_volume_rider.and_then(|is_volume_rider| {
|
is_volume_rider.and_then(|is_volume_rider| {
|
||||||
match is_volume_rider.pos.kind {
|
match is_volume_rider.pos.kind {
|
||||||
Volume::Terrain => None,
|
Volume::Terrain => None,
|
||||||
Volume::Entity(uid) => {
|
Volume::Entity(uid) => {
|
||||||
read_data.uid_allocator.retrieve_entity_internal(uid.into())
|
read_data.uid_allocator.lookup_entity(uid)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -244,11 +244,7 @@ fn target_if_attacked(bdata: &mut BehaviorData) -> bool {
|
|||||||
&& health.last_change.amount < 0.0 =>
|
&& health.last_change.amount < 0.0 =>
|
||||||
{
|
{
|
||||||
if let Some(by) = health.last_change.damage_by() {
|
if let Some(by) = health.last_change.damage_by() {
|
||||||
if let Some(attacker) = bdata
|
if let Some(attacker) = bdata.read_data.uid_allocator.lookup_entity(by.uid()) {
|
||||||
.read_data
|
|
||||||
.uid_allocator
|
|
||||||
.retrieve_entity_internal(by.uid())
|
|
||||||
{
|
|
||||||
// If target is dead or invulnerable (for now, this only
|
// If target is dead or invulnerable (for now, this only
|
||||||
// means safezone), untarget them and idle.
|
// means safezone), untarget them and idle.
|
||||||
if is_dead_or_invulnerable(attacker, bdata.read_data) {
|
if is_dead_or_invulnerable(attacker, bdata.read_data) {
|
||||||
|
@ -33,7 +33,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
loot_owner.expired()
|
loot_owner.expired()
|
||||||
|| match loot_owner.owner() {
|
|| match loot_owner.owner() {
|
||||||
LootOwnerKind::Player(uid) => uid_allocator
|
LootOwnerKind::Player(uid) => uid_allocator
|
||||||
.retrieve_entity_internal(uid)
|
.lookup_entity(uid)
|
||||||
.map_or(true, |entity| !entities.is_alive(entity)),
|
.map_or(true, |entity| !entities.is_alive(entity)),
|
||||||
LootOwnerKind::Group(group) => group_manager.group_info(group).is_none(),
|
LootOwnerKind::Group(group) => group_manager.group_info(group).is_none(),
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
})
|
})
|
||||||
.filter_map(|(pet_entity, pet_pos, owner_uid)| {
|
.filter_map(|(pet_entity, pet_pos, owner_uid)| {
|
||||||
uid_allocator
|
uid_allocator
|
||||||
.retrieve_entity_internal(owner_uid)
|
.lookup_entity(owner_uid)
|
||||||
.and_then(|owner_entity| {
|
.and_then(|owner_entity| {
|
||||||
match (positions.get(owner_entity), physics.get(owner_entity)) {
|
match (positions.get(owner_entity), physics.get(owner_entity)) {
|
||||||
(Some(position), Some(physics)) => {
|
(Some(position), Some(physics)) => {
|
||||||
|
@ -382,7 +382,7 @@ impl<'a> Widget for Group<'a> {
|
|||||||
let mut total_buff_count = 0;
|
let mut total_buff_count = 0;
|
||||||
for (i, &uid) in group_members.iter().copied().enumerate() {
|
for (i, &uid) in group_members.iter().copied().enumerate() {
|
||||||
self.show.group = true;
|
self.show.group = true;
|
||||||
let entity = uid_allocator.retrieve_entity_internal(uid);
|
let entity = uid_allocator.lookup_entity(uid);
|
||||||
let stats = entity.and_then(|entity| stats.get(entity));
|
let stats = entity.and_then(|entity| stats.get(entity));
|
||||||
let skill_set = entity.and_then(|entity| skill_sets.get(entity));
|
let skill_set = entity.and_then(|entity| skill_sets.get(entity));
|
||||||
let health = entity.and_then(|entity| healths.get(entity));
|
let health = entity.and_then(|entity| healths.get(entity));
|
||||||
|
@ -1251,7 +1251,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
for (i, &uid) in group_members.iter().copied().enumerate() {
|
for (i, &uid) in group_members.iter().copied().enumerate() {
|
||||||
let entity = uid_allocator.retrieve_entity_internal(uid);
|
let entity = uid_allocator.lookup_entity(uid);
|
||||||
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
||||||
let stats = entity.and_then(|entity| stats.get(entity));
|
let stats = entity.and_then(|entity| stats.get(entity));
|
||||||
let name = if let Some(stats) = stats {
|
let name = if let Some(stats) = stats {
|
||||||
@ -1324,7 +1324,7 @@ impl<'a> Widget for Map<'a> {
|
|||||||
.map(|info| info.player_alias.as_str())
|
.map(|info| info.player_alias.as_str())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
uid_allocator
|
uid_allocator
|
||||||
.retrieve_entity_internal(uid)
|
.lookup_entity(uid)
|
||||||
.and_then(|entity| stats.get(entity))
|
.and_then(|entity| stats.get(entity))
|
||||||
.map(|stats| stats.name.as_str())
|
.map(|stats| stats.name.as_str())
|
||||||
})
|
})
|
||||||
|
@ -773,7 +773,7 @@ impl<'a> Widget for MiniMap<'a> {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
for (i, &uid) in group_members.iter().copied().enumerate() {
|
for (i, &uid) in group_members.iter().copied().enumerate() {
|
||||||
let entity = uid_allocator.retrieve_entity_internal(uid);
|
let entity = uid_allocator.lookup_entity(uid);
|
||||||
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
||||||
|
|
||||||
if let Some(member_pos) = member_pos {
|
if let Some(member_pos) = member_pos {
|
||||||
|
@ -1055,7 +1055,7 @@ impl FigureMgr {
|
|||||||
let mount_transform_pos = (|| -> Option<_> {
|
let mount_transform_pos = (|| -> Option<_> {
|
||||||
if let Some(is_rider) = is_rider {
|
if let Some(is_rider) = is_rider {
|
||||||
let mount = is_rider.mount;
|
let mount = is_rider.mount;
|
||||||
let mount = uid_allocator.retrieve_entity_internal(mount)?;
|
let mount = uid_allocator.lookup_entity(mount)?;
|
||||||
let body = *bodies.get(mount)?;
|
let body = *bodies.get(mount)?;
|
||||||
let meta = self.states.get_mut(&body, &mount)?;
|
let meta = self.states.get_mut(&body, &mount)?;
|
||||||
Some((meta.mount_transform, meta.mount_world_pos))
|
Some((meta.mount_transform, meta.mount_world_pos))
|
||||||
|
@ -288,8 +288,7 @@ impl ParticleMgr {
|
|||||||
let ecs = scene_data.state.ecs();
|
let ecs = scene_data.state.ecs();
|
||||||
if target
|
if target
|
||||||
.and_then(|target| {
|
.and_then(|target| {
|
||||||
ecs.read_resource::<UidAllocator>()
|
ecs.read_resource::<UidAllocator>().lookup_entity(target)
|
||||||
.retrieve_entity_internal(target)
|
|
||||||
})
|
})
|
||||||
.and_then(|entity| {
|
.and_then(|entity| {
|
||||||
ecs.read_storage::<Body>()
|
ecs.read_storage::<Body>()
|
||||||
|
Reference in New Issue
Block a user