/// <summary> /// Writes as many events as possible up to maxSize and returns the number /// of events written in the batch. Also increments the total counter. /// </summary> private void EncodeEvents( RailBitBuffer buffer, int maxSize) { this.eventsWritten += buffer.PackToSize( maxSize, RailConfig.MAXSIZE_EVENT, this.GetNextEvents(), (evnt) => evnt.Encode(buffer, this.senderTick), (evnt) => evnt.RegisterSent()); }
public void Encode( RailBitBuffer buffer, int maxTotalSize, int maxIndividualSize, Action <T> encode) { buffer.PackToSize( maxTotalSize, maxIndividualSize, this.pending, encode, (val) => this.sent.Add(val)); }
protected void EncodeView(RailBitBuffer buffer, int reservedBytes) { buffer.PackToSize( RailConfig.PACKCAP_MESSAGE_TOTAL - reservedBytes, int.MaxValue, this.view.GetOrdered(), (pair) => { buffer.WriteEntityId(pair.Key); // Write: [EntityId] buffer.WriteTick(pair.Value.Tick); // Write: [Tick] buffer.WriteBool(pair.Value.IsFrozen); // Write: [IsFrozen] }); #endif }