internal void ReceiveCommand(RailCommand command) { if (this.incomingCommands.Store(command)) { command.IsNewCommand = true; } else { RailPool.Free(command); } }
private void UpdateControlled(Tick localTick) { RailDebug.Assert(this.Controller != null); if (this.outgoingCommands.Count < RailConfig.COMMAND_BUFFER_COUNT) { RailCommand command = RailCommand.Create(); command.ClientTick = localTick; command.IsNewCommand = true; this.UpdateControlGeneric(command); this.outgoingCommands.Enqueue(command); } }
private void CleanCommands(Tick ackTick) { if (ackTick.IsValid == false) { return; } while (this.outgoingCommands.Count > 0) { RailCommand command = this.outgoingCommands.Peek(); if (command.ClientTick > ackTick) { break; } RailPool.Free(this.outgoingCommands.Dequeue()); } }
internal static RailCommandUpdate Decode(RailBitBuffer buffer) { RailCommandUpdate update = RailResource.Instance.CreateCommandUpdate(); // Read: [EntityId] update.entityId = buffer.ReadEntityId(); // Read: [Count] int count = (int)buffer.Read(BUFFER_COUNT_BITS); // Read: [Commands] for (int i = 0; i < count; i++) { update.commands.Store(RailCommand.Decode(buffer)); } return(update); }
internal void ServerUpdate() { this.Initialize(); this.NotifyControllerChanged(); this.UpdateAuth(); RailCommand latest = this.GetLatestCommand(); if (latest != null) { this.ApplyControlGeneric(latest); latest.IsNewCommand = false; // Use the remote tick rather than the last applied tick // because we might be skipping some commands to keep up this.UpdateCommandAck(this.Controller.EstimatedRemoteTick); } this.PostUpdate(); }
} // Called on controller internal virtual void ApplyControlGeneric(RailCommand toApply) { } // Called on controller and server
} // Called on controller internal virtual void UpdateControlGeneric(RailCommand toPopulate) { } // Called on controller