Skip to content

Commit cf8ce59

Browse files
committed
surely fix last not working
1 parent 0bc21fc commit cf8ce59

File tree

8 files changed

+228
-144
lines changed

8 files changed

+228
-144
lines changed

ewext/noita_api/src/lua.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,37 @@ impl<
625625
}
626626
}
627627

628+
impl<
629+
T0: LuaGetValue,
630+
T1: LuaGetValue,
631+
T2: LuaGetValue,
632+
T3: LuaGetValue,
633+
T4: LuaGetValue,
634+
T5: LuaGetValue,
635+
T6: LuaGetValue,
636+
> LuaGetValue for (T0, T1, T2, T3, T4, T5, T6)
637+
{
638+
fn get(lua: LuaState, index: i32) -> eyre::Result<Self>
639+
where
640+
Self: Sized,
641+
{
642+
let prev = <(T0, T1, T2, T3, T4, T5)>::get(lua, index - T6::size_on_stack())?;
643+
Ok((
644+
prev.0,
645+
prev.1,
646+
prev.2,
647+
prev.3,
648+
prev.4,
649+
prev.5,
650+
T6::get(lua, index)?,
651+
))
652+
}
653+
654+
fn size_on_stack() -> i32 {
655+
<(T0, T1, T2, T3, T4, T5)>::size_on_stack() + T6::size_on_stack()
656+
}
657+
}
658+
628659
impl LuaGetValue for (bool, bool, bool, f64, f64, f64, f64, f64, f64, f64, f64) {
629660
fn get(lua: LuaState, index: i32) -> eyre::Result<Self> {
630661
Ok((

ewext/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,10 @@ pub unsafe extern "C" fn luaopen_ewext0(lua: *mut lua_State) -> c_int {
473473
.as_mut()
474474
.ok_or_eyre("No entity sync module loaded")?;
475475
#[allow(clippy::type_complexity)]
476-
let (entity_killed, x, y, file, entity_responsible): (
476+
let (entity_killed, wait_on_kill, drops_gold, x, y, file, entity_responsible): (
477477
Option<EntityID>,
478+
Option<bool>,
479+
Option<bool>,
478480
Option<f64>,
479481
Option<f64>,
480482
Option<Cow<'_, str>>,
@@ -483,11 +485,15 @@ pub unsafe extern "C" fn luaopen_ewext0(lua: *mut lua_State) -> c_int {
483485
let entity_killed =
484486
entity_killed.ok_or_eyre("Expected to have a valid entity_killed")?;
485487
let file = file.ok_or_eyre("Expected to have a valid file")?;
488+
let wait_on_kill = wait_on_kill.ok_or_eyre("Expected to have a valid pos")?;
489+
let drops_gold = drops_gold.ok_or_eyre("Expected to have a valid pos")?;
486490
let x = x.ok_or_eyre("Expected to have a valid pos")?;
487491
let y = y.ok_or_eyre("Expected to have a valid pos")?;
488492
let pos = WorldPos::from_f64(x, y);
489493
entity_sync.cross_death_notify(
490494
entity_killed,
495+
wait_on_kill,
496+
drops_gold,
491497
pos,
492498
file.to_string(),
493499
entity_responsible,

ewext/src/modules/entity_sync.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,20 @@ impl EntitySync {
281281
pub(crate) fn cross_death_notify(
282282
&mut self,
283283
entity_killed: EntityID,
284+
wait_on_kill: bool,
285+
drops_gold: bool,
284286
pos: WorldPos,
285287
file: String,
286288
entity_responsible: Option<EntityID>,
287289
) -> eyre::Result<()> {
288-
self.local_diff_model
289-
.death_notify(entity_killed, pos, file, entity_responsible);
290+
self.local_diff_model.death_notify(
291+
entity_killed,
292+
wait_on_kill,
293+
drops_gold,
294+
pos,
295+
file,
296+
entity_responsible,
297+
);
290298
Ok(())
291299
}
292300

@@ -346,14 +354,15 @@ impl Module for EntitySync {
346354
let (pos, data) = &self.spawn_once[i];
347355
if pos.contains(x, y, 512 + 256) {
348356
match data {
349-
shared::SpawnOnce::Enemy(file, offending_peer) => {
357+
shared::SpawnOnce::Enemy(file, drops_gold, offending_peer) => {
350358
if let Ok(Some(entity)) =
351359
noita_api::raw::entity_load(file.into(), Some(x), Some(y))
352360
{
361+
diff_model::init_remote_entity(entity, None, None, *drops_gold)?;
353362
if let Some(damage) =
354363
entity.try_get_first_component::<DamageModelComponent>(None)?
355364
{
356-
damage.set_wait_for_kill_flag_on_death(false)?; //TODO deal with this better
365+
damage.set_wait_for_kill_flag_on_death(false)?;
357366
damage.set_ui_report_damage(false)?;
358367
damage.set_hp(f32::MIN_POSITIVE as f64)?;
359368
let responsible_entity = offending_peer
@@ -394,7 +403,7 @@ impl Module for EntitySync {
394403
}
395404
}
396405
}
397-
shared::SpawnOnce::BrokenWand(_file) => {
406+
shared::SpawnOnce::BrokenWand => {
398407
todo!()
399408
}
400409
}

0 commit comments

Comments
 (0)