mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
update rodio again
This commit is contained in:
parent
067570672d
commit
48c765d3be
4 changed files with 54 additions and 172 deletions
|
@ -12,7 +12,9 @@ pub(crate) struct InterestTracker {
|
|||
|
||||
impl InterestTracker {
|
||||
pub(crate) fn new(radius_hysteresis: f64) -> Self {
|
||||
assert!(radius_hysteresis > 0.0);
|
||||
unsafe {
|
||||
std::hint::assert_unchecked(radius_hysteresis > 0.0);
|
||||
}
|
||||
Self {
|
||||
radius_hysteresis,
|
||||
x: 0.0,
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
use crate::WorldSync;
|
||||
use crate::modules::{Module, ModuleCtx};
|
||||
use noita_api::noita::world::ParticleWorldState;
|
||||
use shared::world_sync::ProxyToWorldSync;
|
||||
use shared::NoitaOutbound;
|
||||
use shared::world_sync::{ChunkCoord, NoitaWorldUpdate, ProxyToWorldSync, WorldSyncToProxy};
|
||||
impl Module for WorldSync {
|
||||
fn on_world_update(&mut self, _ctx: &mut ModuleCtx) -> eyre::Result<()> {
|
||||
std::hint::black_box(unsafe {
|
||||
self.particle_world_state.assume_init_ref().encode_world()
|
||||
})?;
|
||||
std::hint::black_box(unsafe {
|
||||
self.particle_world_state.assume_init_ref().decode_world()
|
||||
})?;
|
||||
//TODO
|
||||
fn on_world_update(&mut self, ctx: &mut ModuleCtx) -> eyre::Result<()> {
|
||||
let mut update = NoitaWorldUpdate {
|
||||
coord: ChunkCoord(0, 0),
|
||||
runs: vec![],
|
||||
};
|
||||
unsafe {
|
||||
self.particle_world_state
|
||||
.assume_init_ref()
|
||||
.encode_world(ChunkCoord(0, 0), &mut update)?
|
||||
};
|
||||
let msg = NoitaOutbound::WorldSyncToProxy(WorldSyncToProxy::Updates(vec![update]));
|
||||
ctx.net.send(&msg)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +23,12 @@ impl WorldSync {
|
|||
pub fn handle_remote(&mut self, msg: ProxyToWorldSync) -> eyre::Result<()> {
|
||||
match msg {
|
||||
ProxyToWorldSync::Updates(updates) => {
|
||||
for _chunk in updates {
|
||||
//TODO
|
||||
for chunk in updates {
|
||||
unsafe {
|
||||
self.particle_world_state
|
||||
.assume_init_ref()
|
||||
.decode_world(chunk)?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,15 +36,26 @@ impl WorldSync {
|
|||
}
|
||||
}
|
||||
trait WorldData {
|
||||
unsafe fn encode_world(&self) -> eyre::Result<()>;
|
||||
unsafe fn decode_world(&self) -> eyre::Result<()>;
|
||||
unsafe fn encode_world(
|
||||
&self,
|
||||
coord: ChunkCoord,
|
||||
chunk: &mut NoitaWorldUpdate,
|
||||
) -> eyre::Result<()>;
|
||||
unsafe fn decode_world(&self, chunk: NoitaWorldUpdate) -> eyre::Result<()>;
|
||||
}
|
||||
impl WorldData for ParticleWorldState {
|
||||
unsafe fn encode_world(&self) -> eyre::Result<()> {
|
||||
//TODO
|
||||
unsafe fn encode_world(
|
||||
&self,
|
||||
coord: ChunkCoord,
|
||||
chunk: &mut NoitaWorldUpdate,
|
||||
) -> eyre::Result<()> {
|
||||
chunk.coord = coord;
|
||||
let runs = &mut chunk.runs;
|
||||
runs.clear();
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn decode_world(&self) -> eyre::Result<()> {
|
||||
unsafe fn decode_world(&self, chunk: NoitaWorldUpdate) -> eyre::Result<()> {
|
||||
std::hint::black_box(chunk);
|
||||
//TODO
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue