Remove unused packet variant, move peer UUID to start of packet
This commit is contained in:
parent
fee5fb3c95
commit
fe967d70b9
5 changed files with 18 additions and 66 deletions
|
|
@ -40,7 +40,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn spawner<T: NetworkDecodable + Component>(
|
||||
fn incoming_network_entity<T: NetworkDecodable + Component>(
|
||||
mut inbound: MessageReader<InboundPacket>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
|
|
@ -59,7 +59,7 @@ fn new_peer<T: NetworkEncodable + Component>(
|
|||
) -> Result {
|
||||
let peer = peers.get(add.entity)?;
|
||||
for component in components {
|
||||
outbound.write(Packet::create(component.encode(), peer.id));
|
||||
outbound.write(Packet::create(peer.id, component.encode()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -72,13 +72,13 @@ fn new_entity<T: NetworkEncodable + Component>(
|
|||
) {
|
||||
if let Ok(component) = components.get(add.entity) {
|
||||
for peer in peers {
|
||||
outbound.write(Packet::create(component.encode(), peer.id));
|
||||
outbound.write(Packet::create(peer.id, component.encode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn distribution_plugin<T: Networked>(app: &mut App) {
|
||||
app.add_systems(FixedUpdate, spawner::<T>)
|
||||
app.add_systems(FixedUpdate, incoming_network_entity::<T>)
|
||||
.add_observer(new_peer::<T>)
|
||||
.add_observer(new_entity::<T>);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue