Ejemplo n.º 1
0
        /// <summary>
        /// Note that the packetTick may not be the tick this event was created on
        /// if we're re-trying to send this event in subsequent packets. This tick
        /// is intended for use in tick diffs for compression.
        /// </summary>
        internal static RailEvent Decode(
            RailBitBuffer buffer,
            Tick packetTick)
        {
            // Read: [EventType]
            int factoryType = buffer.ReadInt(RailEvent.FactoryTypeCompressor);

            RailEvent evnt = RailEvent.Create(factoryType);

            // Read: [EventId]
            evnt.EventId = buffer.ReadSequenceId();

            // Read: [HasEntityId]
            bool hasEntityId = buffer.ReadBool();

            if (hasEntityId)
            {
                // Read: [EntityId]
                evnt.EntityId = buffer.ReadEntityId();
            }

            // Read: [EventData]
            evnt.DecodeData(buffer, packetTick);

            return(evnt);
        }
Ejemplo n.º 2
0
        private void DecodeHeader(RailBitBuffer buffer)
        {
            // Read: [LocalTick]
            this.senderTick = buffer.ReadTick();

            // Read: [AckTick]
            this.ackTick = buffer.ReadTick();

            // Read: [AckReliableEventId]
            this.ackEventId = buffer.ReadSequenceId();
        }