/// <summary> /// Removes any acked or expired outgoing events. /// </summary> private void CleanOutgoingEvents(SequenceId ackedEventId) { if (ackedEventId.IsValid == false) { return; } // Stop attempting to send acked events foreach (RailEvent evnt in outgoingEvents) { if (evnt.EventId <= ackedEventId) { evnt.Attempts = 0; } } // Clean out any events with zero attempts left while (outgoingEvents.Count > 0) { if (outgoingEvents.Peek().Attempts > 0) { break; } RailPool.Free(outgoingEvents.Dequeue()); } }
/// <summary> /// Stores a value. Will not replace a stored value with an older one. /// </summary> public bool Store(T value) { int index = TickToIndex(value.Tick); bool store = false; if (latestIdx < 0) { store = true; } else { T latest = data[latestIdx]; if (value.Tick >= latest.Tick) { store = true; } } if (store) { RailPool.SafeReplace(ref data[index], value); latestIdx = index; } return(store); }
private void Reset() { this.tick = Tick.INVALID; this.entityId = EntityId.INVALID; RailPool.SafeReplace(ref this.state, null); this.IsFrozen = false; }
private void Reset() { Tick = Tick.INVALID; EntityId = EntityId.INVALID; RailPool.SafeReplace(ref state, null); IsFrozen = false; }
private void OnPacketReceived(RailPacketFromServer packet) { if (Room == null) { foreach (RailStateDelta delta in packet.Deltas) { RailPool.Free(delta); } } else { foreach (RailStateDelta delta in packet.Deltas) { if (Room.ProcessDelta(delta) == false) { RailPool.Free(delta); } } } foreach (RailEvent @event in packet.Events) { @event.Free(); } }
/// <summary> /// Clears the buffer, freeing all contents. /// </summary> public void Clear() { for (int i = 0; i < data.Length; i++) { RailPool.SafeReplace(ref data[i], null); } latestIdx = -1; }
public void Store(T val) { if (data.Count >= capacity) { RailPool.Free(data.Dequeue()); } data.Enqueue(val); Latest = val; }
/// <summary> /// Clears the buffer, freeing all contents. /// </summary> public void Clear() { foreach (T val in data) { RailPool.Free(val); } data.Clear(); Latest = null; }
/// <summary> /// Discards all elements added as pending, regardless whether they have been sent or not. /// </summary> public void Clear() { // Everything in sent is also in pending, so only free pending foreach (T value in pending) { RailPool.Free(value); } pending.Clear(); sent.Clear(); }
private void ProcessCommandUpdate(RailServerPeer peer, RailCommandUpdate update) { if (Room.TryGet(update.EntityId, out RailEntityServer entity)) { bool canReceive = entity.Controller == peer && entity.IsRemoving == false; if (canReceive) { foreach (RailCommand command in update.Commands) { entity.ReceiveCommand(command); } } else // Can't send commands to that entity, so dump them { foreach (RailCommand command in update.Commands) { RailPool.Free(command); } } } }
private void Reset() { tick = Tick.INVALID; RailPool.SafeReplace(ref state, null); }
public void Free() { RailPool.Free(this); }