pub struct ReplicaTable {
pub entities: BTreeMap<EntityId, ReplicaEntity>,
pub precision: f32,
pub spawn_ticks: BTreeMap<EntityId, u64>,
pub datagram_frames: BTreeMap<EntityId, u64>,
pub stream_tick: u64,
}Expand description
A client’s table of the entities it has been told about.
Fields§
§entities: BTreeMap<EntityId, ReplicaEntity>§precision: f32§spawn_ticks: BTreeMap<EntityId, u64>The tick of the stream frame that spawned each entity: a datagram
update names it (see crate::datagram). Set only by
ReplicaTable::apply_stream.
datagram_frames: BTreeMap<EntityId, u64>The last datagram applied to each entity (see crate::datagram).
stream_tick: u64The tick of the last stream frame applied with
ReplicaTable::apply_stream. A client on an unreliable transport
acks each datagram with it, so the server knows which spawns it had.
Implementations§
Source§impl ReplicaTable
impl ReplicaTable
Sourcepub fn apply_datagram(
&mut self,
datagram: &[u8],
) -> Result<DatagramSummary, DecodeError>
pub fn apply_datagram( &mut self, datagram: &[u8], ) -> Result<DatagramSummary, DecodeError>
Apply one datagram. It changes nothing it cannot apply exactly (see
DatagramSummary::skipped). An error means the bytes are not a
datagram; the table then may hold part of it.
Source§impl ReplicaTable
impl ReplicaTable
pub fn new() -> Self
pub fn pos(&self, id: EntityId) -> Option<[f32; 3]>
Sourcepub fn apply(&mut self, frame: &[u8]) -> Result<FrameSummary, DecodeError>
pub fn apply(&mut self, frame: &[u8]) -> Result<FrameSummary, DecodeError>
Apply one frame. On an error the table may hold part of the frame; the caller should treat the connection as broken.
Sourcepub fn apply_stream(
&mut self,
frame: &[u8],
tick: u64,
) -> Result<FrameSummary, DecodeError>
pub fn apply_stream( &mut self, frame: &[u8], tick: u64, ) -> Result<FrameSummary, DecodeError>
Apply one frame from the stream of a subscription that also gets datagrams, with the tick its header carries. The table records the tick each entity spawned at and the tick of the last stream frame, which datagrams and their acks name. A full frame starts that record over, so frames the server dropped before the client got them, or an earlier connection, leave nothing behind.