mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
fix world sync???, disable gui on end fight death, have streaming keep alive
This commit is contained in:
parent
a7cb7760df
commit
e64bf606d3
4 changed files with 40 additions and 49 deletions
|
@ -102,7 +102,6 @@ pub(crate) enum WorldNetMessage {
|
|||
chunk: ChunkCoord,
|
||||
chunk_data: Option<ChunkData>,
|
||||
listeners: FxHashSet<OmniPeerId>,
|
||||
priority: u8,
|
||||
},
|
||||
TransferFailed {
|
||||
chunk: ChunkCoord,
|
||||
|
@ -473,8 +472,13 @@ impl WorldManager {
|
|||
}
|
||||
|
||||
fn emit_got_authority(&mut self, chunk: ChunkCoord, source: OmniPeerId, priority: u8) {
|
||||
let auth = self.authority_map.get(&chunk).cloned();
|
||||
self.authority_map.insert(chunk, (source, priority));
|
||||
let chunk_data = self.chunk_storage.get(&chunk).cloned();
|
||||
let chunk_data = if auth.map(|a| a.0 != source).unwrap_or(true) {
|
||||
self.chunk_storage.get(&chunk).cloned()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.emit_msg(
|
||||
Destination::Peer(source),
|
||||
WorldNetMessage::GotAuthority {
|
||||
|
@ -593,25 +597,12 @@ impl WorldManager {
|
|||
chunk_data,
|
||||
priority,
|
||||
} => {
|
||||
if self.chunk_state.get(&chunk) != Some(&ChunkState::UnloadPending) {
|
||||
if let Some(chunk_data) = chunk_data {
|
||||
self.inbound_model.apply_chunk_data(chunk, &chunk_data);
|
||||
self.outbound_model.apply_chunk_data(chunk, &chunk_data);
|
||||
}
|
||||
self.chunk_state
|
||||
.insert(chunk, ChunkState::authority(priority));
|
||||
self.last_request_priority.remove(&chunk);
|
||||
let chunk_data = self.outbound_model.get_chunk_data(chunk);
|
||||
self.emit_msg(
|
||||
Destination::Host,
|
||||
WorldNetMessage::UpdateStorage { chunk, chunk_data },
|
||||
);
|
||||
} else {
|
||||
let chunk_data = self.outbound_model.get_chunk_data(chunk);
|
||||
self.emit_msg(
|
||||
Destination::Host,
|
||||
WorldNetMessage::UpdateStorage { chunk, chunk_data },
|
||||
);
|
||||
self.chunk_state
|
||||
.insert(chunk, ChunkState::authority(priority));
|
||||
self.last_request_priority.remove(&chunk);
|
||||
if let Some(chunk_data) = chunk_data {
|
||||
self.inbound_model.apply_chunk_data(chunk, &chunk_data);
|
||||
self.outbound_model.apply_chunk_data(chunk, &chunk_data);
|
||||
}
|
||||
}
|
||||
WorldNetMessage::UpdateStorage { chunk, chunk_data } => {
|
||||
|
@ -773,10 +764,9 @@ impl WorldManager {
|
|||
WorldNetMessage::RequestAuthorityTransfer { chunk },
|
||||
);
|
||||
} else {
|
||||
let chunk_data = self.outbound_model.get_chunk_data(chunk);
|
||||
self.emit_msg(
|
||||
Destination::Host,
|
||||
WorldNetMessage::RelinquishAuthority { chunk, chunk_data },
|
||||
WorldNetMessage::RelinquishAuthority { chunk, chunk_data: None },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -785,7 +775,6 @@ impl WorldManager {
|
|||
let state = self.chunk_state.get(&chunk);
|
||||
if let Some(ChunkState::Authority {
|
||||
listeners,
|
||||
priority,
|
||||
..
|
||||
}) = state
|
||||
{
|
||||
|
@ -796,10 +785,14 @@ impl WorldManager {
|
|||
chunk,
|
||||
chunk_data,
|
||||
listeners: listeners.clone(),
|
||||
priority: *priority,
|
||||
},
|
||||
);
|
||||
self.chunk_state.insert(chunk, ChunkState::UnloadPending);
|
||||
let chunk_data = self.outbound_model.get_chunk_data(chunk);
|
||||
self.emit_msg(
|
||||
Destination::Host,
|
||||
WorldNetMessage::UpdateStorage { chunk, chunk_data },
|
||||
);
|
||||
} else {
|
||||
self.emit_msg(
|
||||
Destination::Peer(source),
|
||||
|
@ -811,11 +804,11 @@ impl WorldManager {
|
|||
chunk,
|
||||
chunk_data,
|
||||
listeners,
|
||||
priority,
|
||||
} => {
|
||||
info!("Transfer ok");
|
||||
if let Some(chunk_data) = chunk_data {
|
||||
self.inbound_model.apply_chunk_data(chunk, &chunk_data);
|
||||
self.outbound_model.apply_chunk_data(chunk, &chunk_data);
|
||||
}
|
||||
for listener in listeners.iter() {
|
||||
self.emit_msg(
|
||||
|
@ -827,17 +820,11 @@ impl WorldManager {
|
|||
chunk,
|
||||
ChunkState::Authority {
|
||||
listeners,
|
||||
priority,
|
||||
priority: self.last_request_priority.remove(&chunk).unwrap_or(0),
|
||||
new_authority: None,
|
||||
stop_sending: false,
|
||||
},
|
||||
);
|
||||
self.last_request_priority.remove(&chunk);
|
||||
let chunk_data = self.outbound_model.get_chunk_data(chunk);
|
||||
self.emit_msg(
|
||||
Destination::Host,
|
||||
WorldNetMessage::UpdateStorage { chunk, chunk_data },
|
||||
);
|
||||
}
|
||||
WorldNetMessage::TransferFailed { chunk } => {
|
||||
warn!("Transfer failed, requesting authority normally");
|
||||
|
@ -925,4 +912,4 @@ impl Drop for WorldManager {
|
|||
|
||||
impl SaveStateEntry for FxHashMap<ChunkCoord, ChunkData> {
|
||||
const FILENAME: &'static str = "world_chunks";
|
||||
}
|
||||
}
|
|
@ -128,6 +128,8 @@ function end_fight.on_world_update()
|
|||
end
|
||||
local collision = EntityGetFirstComponentIncludingDisabled(entity, "PlayerCollisionComponent")
|
||||
local suck = EntityGetFirstComponentIncludingDisabled(entity, "MaterialSuckerComponent")
|
||||
local gui = EntityGetFirstComponentIncludingDisabled(entity, "InventoryGuiComponent")
|
||||
EntitySetComponentIsEnabled(entity, gui, false)
|
||||
EntitySetComponentIsEnabled(entity, suck, false)
|
||||
EntitySetComponentIsEnabled(entity, collision, false)
|
||||
for _, child in ipairs(EntityGetAllChildren(entity) or {}) do
|
||||
|
|
|
@ -593,6 +593,8 @@
|
|||
<Base file="mods/quant.ew/files/resource/entities/chunk_loader.xml">
|
||||
</Base>
|
||||
</Entity>-->
|
||||
<StreamingKeepAliveComponent>
|
||||
</StreamingKeepAliveComponent>
|
||||
|
||||
<Entity name="cursor">
|
||||
<SpriteComponent
|
||||
|
|
|
@ -54,11 +54,11 @@ local function target()
|
|||
else
|
||||
ComponentSetValue2(audio_n, "z", ComponentGetValue2(audio, "z"))
|
||||
end
|
||||
local keep_alive = EntityGetFirstComponent(camera_target.entity, "StreamingKeepAliveComponent")
|
||||
--local keep_alive = EntityGetFirstComponent(camera_target.entity, "StreamingKeepAliveComponent")
|
||||
EntityRemoveComponent(camera_target.entity, audio)
|
||||
if keep_alive ~= nil then
|
||||
EntityRemoveComponent(camera_target.entity, keep_alive)
|
||||
end
|
||||
--if keep_alive ~= nil then
|
||||
-- EntityRemoveComponent(camera_target.entity, keep_alive)
|
||||
--end
|
||||
EntityRemoveComponent(camera_target.entity, inventory_target)
|
||||
camera_target = cam_target
|
||||
end
|
||||
|
@ -104,17 +104,17 @@ local function target()
|
|||
inventory_target = EntityAddComponent2(cam_target.entity, "InventoryGuiComponent")
|
||||
end
|
||||
local audio = EntityGetFirstComponent(camera_target.entity, "AudioListenerComponent")
|
||||
local keep_alive = EntityGetFirstComponent(camera_target.entity, "StreamingKeepAliveComponent")
|
||||
--local keep_alive = EntityGetFirstComponent(camera_target.entity, "StreamingKeepAliveComponent")
|
||||
if audio ~= nil then
|
||||
local audio_n = EntityAddComponent2(cam_target.entity, "AudioListenerComponent")
|
||||
ComponentSetValue2(audio_n, "z", ComponentGetValue2(audio, "z"))
|
||||
EntityRemoveComponent(camera_target.entity, audio)
|
||||
if camera_target.entity ~= ctx.my_player.entity and keep_alive ~= nil and not EntityHasTag(camera_target.entity, "ew_notplayer") then
|
||||
EntityRemoveComponent(camera_target.entity, keep_alive)
|
||||
end
|
||||
if cam_target.entity ~= ctx.my_player.entity and not EntityHasTag(cam_target, "ew_notplayer") then
|
||||
EntityAddComponent2(cam_target.entity, "StreamingKeepAliveComponent")
|
||||
end
|
||||
--if camera_target.entity ~= ctx.my_player.entity and keep_alive ~= nil and not EntityHasTag(camera_target.entity, "ew_notplayer") then
|
||||
-- EntityRemoveComponent(camera_target.entity, keep_alive)
|
||||
--end
|
||||
--if cam_target.entity ~= ctx.my_player.entity and not EntityHasTag(cam_target, "ew_notplayer") then
|
||||
-- EntityAddComponent2(cam_target.entity, "StreamingKeepAliveComponent")
|
||||
--end
|
||||
end
|
||||
end
|
||||
camera_target = cam_target
|
||||
|
@ -252,13 +252,13 @@ function spectate.on_world_update()
|
|||
if peer_id ~= ctx.my_id then
|
||||
local audio = EntityGetFirstComponent(data.entity, "AudioListenerComponent")
|
||||
local inv_target = EntityGetFirstComponent(data.entity, "InventoryGuiComponent")
|
||||
local keep_alive = EntityGetFirstComponent(data.entity, "StreamingKeepAliveComponent")
|
||||
--local keep_alive = EntityGetFirstComponent(data.entity, "StreamingKeepAliveComponent")
|
||||
if audio ~= nil then
|
||||
EntityRemoveComponent(data.entity, audio)
|
||||
end
|
||||
if keep_alive ~= nil and not EntityHasTag(data.entity, "ew_notplayer") then
|
||||
EntityRemoveComponent(data.entity, keep_alive)
|
||||
end
|
||||
--if keep_alive ~= nil and not EntityHasTag(data.entity, "ew_notplayer") then
|
||||
-- EntityRemoveComponent(data.entity, keep_alive)
|
||||
--end
|
||||
if inv_target ~= nil then
|
||||
EntityRemoveComponent(data.entity, inv_target)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue