예제 #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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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
        }