Exemplo n.º 1
0
 /// <summary>
 ///     Queues an event to broadcast to the server with a number of retries.
 /// </summary>
 public void RaiseEvent <T>(Action <T> initializer, ushort attempts = 3)
     where T : RailEvent
 {
     RailDebug.Assert(client.ServerPeer != null);
     if (client.ServerPeer != null)
     {
         T evnt = eventCreator.CreateEvent <T>();
         initializer(evnt);
         client.ServerPeer.SendEvent(evnt, attempts, false);
     }
 }
Exemplo n.º 2
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>
        public static RailEvent Decode(
            IRailEventConstruction eventCreator,
            RailIntCompressor compressor,
            RailBitBuffer buffer,
            Tick packetTick)
        {
            // Read: [EventType]
            int factoryType = buffer.ReadInt(compressor);

            RailEvent evnt = eventCreator.CreateEvent(factoryType);

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

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

            return(evnt);
        }