protected override void DecodeData(RailBitBuffer buffer) { this.SetData( buffer.ReadBool(), buffer.ReadBool(), buffer.ReadBool(), buffer.ReadBool(), buffer.ReadBool()); }
internal static FixedByteBuffer8 Read(RailBitBuffer buffer) { uint first = 0; uint second = 0; first = buffer.ReadUInt(); if (buffer.ReadBool()) second = buffer.ReadUInt(); return new FixedByteBuffer8(first, second); }
public void DecodeView(RailBitBuffer buffer) { IEnumerable<KeyValuePair<EntityId, RailViewEntry>> decoded = buffer.UnpackAll( () => { return new KeyValuePair<EntityId, RailViewEntry>( buffer.ReadEntityId(), // Read: [EntityId] new RailViewEntry( buffer.ReadTick(), // Read: [Tick] buffer.ReadBool())); // Read: [IsFrozen] }); foreach (var pair in decoded) this.view.RecordUpdate(pair.Key, pair.Value); #endif }
public static RailStateDelta DecodeDelta( IRailStateConstruction stateCreator, RailBitBuffer buffer, Tick packetTick) { RailStateDelta delta = stateCreator.CreateDelta(); RailState state = null; Tick commandAck = Tick.INVALID; Tick removedTick = Tick.INVALID; // Read: [EntityId] EntityId entityId = buffer.ReadEntityId(); // Read: [IsFrozen] bool isFrozen = buffer.ReadBool(); if (isFrozen == false) { // Read: [FactoryType] int factoryType = buffer.ReadInt(stateCreator.EntityTypeCompressor); state = stateCreator.CreateState(factoryType); // Read: [IsRemoved] bool isRemoved = buffer.ReadBool(); if (isRemoved) // Read: [RemovedTick] { removedTick = buffer.ReadTick(); } // Read: [HasControllerData] state.HasControllerData = buffer.ReadBool(); // Read: [HasImmutableData] state.HasImmutableData = buffer.ReadBool(); if (state.HasImmutableData) // Read: [Immutable Data] { state.DataSerializer.DecodeImmutableData(buffer); } // Read: [Flags] state.Flags = buffer.Read(state.DataSerializer.FlagBits); // Read: [Mutable Data] state.DataSerializer.DecodeMutableData(buffer, state.Flags); if (state.HasControllerData) { // Read: [Controller Data] state.DataSerializer.DecodeControllerData(buffer); // Read: [Command Ack] commandAck = buffer.ReadTick(); } } delta.Initialize(packetTick, entityId, state, removedTick, commandAck, isFrozen); return(delta); }
internal static RailStateDelta DecodeDelta( RailBitBuffer buffer, Tick packetTick) { RailStateDelta delta = RailResource.Instance.CreateDelta(); RailState state = null; // Read: [EntityId] EntityId entityId = buffer.ReadEntityId(); // Read: [IsFrozen] bool isFrozen = buffer.ReadBool(); if (isFrozen == false) { // Read: [FactoryType] int factoryType = buffer.ReadInt(RailState.FactoryTypeCompressor); state = RailState.Create(factoryType); // Read: [IsRemoved] bool isRemoved = buffer.ReadBool(); if (isRemoved) { // Read: [DestroyedTick] state.RemovedTick = buffer.ReadTick(); // End Read } else { // Read: [HasControllerData] state.HasControllerData = buffer.ReadBool(); // Read: [HasImmutableData] state.HasImmutableData = buffer.ReadBool(); // Read: [Flags] state.Flags = buffer.Read(state.FlagBits); // Read: [Mutable Data] state.DecodeMutableData(buffer, state.Flags); if (state.HasControllerData) { // Read: [Controller Data] state.DecodeControllerData(buffer); // Read: [Command Ack] state.CommandAck = buffer.ReadTick(); } if (state.HasImmutableData) { // Read: [Immutable Data] state.DecodeImmutableData(buffer); } } } delta.Initialize(packetTick, entityId, state, isFrozen); return(delta); }