Skip to content

Commit

Permalink
fix egg duping enemys
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Jan 23, 2025
1 parent cf8ce59 commit be5717e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ewext/src/modules/entity_sync/diff_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use shared::{
},
GameEffectData, NoitaOutbound, PeerId, SpawnOnce, WorldPos,
};
use std::borrow::Cow;
use std::mem;
use std::num::NonZero;
pub(crate) static DES_TAG: &str = "ew_des";
Expand Down Expand Up @@ -907,6 +908,7 @@ impl RemoteDiffModel {
EntityUpdate::Init(entity_entry, gid) => {
if let Some(ent) = self.waiting_for_lid.remove(&gid) {
self.tracked.insert(current_lid, ent);
let _ = init_remote_entity(ent, Some(current_lid), Some(gid), false);
}
self.lid_to_gid.insert(current_lid, gid);
self.entity_infos.insert(current_lid, *entity_entry);
Expand Down Expand Up @@ -1510,7 +1512,7 @@ pub fn init_remote_entity(
}

for pb2 in entity.iter_all_components_of_type::<PhysicsBody2Component>(None)? {
pb2.set_destroy_body_if_entity_destroyed(true)?; //TODO why??
pb2.set_destroy_body_if_entity_destroyed(true)?;
}

for expl in entity.iter_all_components_of_type::<ExplodeOnDamageComponent>(None)? {
Expand Down Expand Up @@ -1556,6 +1558,18 @@ pub fn init_remote_entity(
ghost.set_die_if_no_home(false)?;
}

if entity.has_tag("egg_item") {
if let Some(explosion) =
entity.try_get_first_component_including_disabled::<ExplodeOnDamageComponent>(None)?
{
explosion.object_set_value::<Cow<'_, str>>(
"config_explosion",
"load_this_entity",
"".into(),
)?
}
}

entity
.iter_all_components_of_type_including_disabled::<VariableStorageComponent>(None)?
.for_each(|var| {
Expand Down
1 change: 1 addition & 0 deletions quant.ew/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ function OnProjectileFired(
or n == "data/entities/projectiles/deck/black_hole_giga.xml"
or n == "data/entities/projectiles/deck/white_hole.xml"
or n == "data/entities/projectiles/deck/white_hole_giga.xml"
or string.sub(n, 31) == "data/entities/items/pickup/egg_"
or EntityHasTag(projectile_id, "ew_projectile_position_sync")
then
local body = EntityGetFirstComponentIncludingDisabled(projectile_id, "PhysicsBody2Component")
Expand Down

0 comments on commit be5717e

Please sign in to comment.