Esempio n. 1
0
        /// <summary>
        /// Reconstructs this command from a serialized command and returns the size of the command.
        /// </summary>
        public int Reconstruct(byte[] Source, int StartIndex)
        {
            reader.Initialize(Source, StartIndex);

            ControllerID = reader.ReadByte();
            LeInput      = (InputCode)reader.ReadByte();

            ValuesMask = reader.ReadUInt();

            HasPosition = GetMaskBool(ValuesMask, DataType.Position);
            HasTarget   = GetMaskBool(ValuesMask, DataType.Target);
            HasFlag     = GetMaskBool(ValuesMask, DataType.Flag);
            HasCoord    = GetMaskBool(ValuesMask, DataType.Coord);
            HasCount    = GetMaskBool(ValuesMask, DataType.Count);
            HasSelect   = GetMaskBool(ValuesMask, DataType.Select);

            if (HasPosition)
            {
                _position.x = reader.ReadInt();
                _position.y = reader.ReadInt();
            }
            if (HasTarget)
            {
                _target = reader.ReadUShort();
            }
            if (HasFlag)
            {
                _flag = reader.ReadBool();
            }
            if (HasCoord)
            {
                _coord.x = reader.ReadInt();
                _coord.y = reader.ReadInt();
            }
            if (HasCount)
            {
                _count = reader.ReadInt();
            }

            if (HasSelect)
            {
                Select        = new Selection();
                reader.count += Select.Reconstruct(
                    AgentController.InstanceManagers[ControllerID],
                    reader.source,
                    reader.count);
            }

            return(reader.count - StartIndex);
        }
Esempio n. 2
0
        /// <summary>
        /// Reconstructs this command from a serialized command and returns the size of the command.
        /// </summary>
        public int Reconstruct(byte[] Source, int StartIndex = 0)
        {
            reader.Initialize(Source, StartIndex);
            ControllerID             = reader.ReadByte();
            LeInput                  = reader.ReadUShort();
            this.ContainedTypesCount = reader.ReadUShort();

            for (int i = 0; i < this.ContainedTypesCount; i++)
            {
                ushort dataID    = reader.ReadUShort();
                ushort dataCount = reader.ReadUShort();
                FastList <ICommandData> items = GetItemsList(dataID);
                Type dataType = RegisteredData.GetReversed(dataID);
                for (int j = 0; j < dataCount; j++)
                {
                    ICommandData item = Activator.CreateInstance(dataType) as ICommandData;
                    item.Read(reader);
                    items.Add(item);
                }
            }

            return(reader.Position - StartIndex);
        }
        public static IEnumerator StreamPlayback(Replay playbackReplay)
        {
            CurrentReplay = playbackReplay;

            byte[] playbackBytes = playbackReplay.Content;

            yield return(null);

            FrameManager.AdjustFramerate = false;

            Reader reader = new Reader();

            reader.Initialize(playbackBytes, 0);
            Frame[] frames = Deserialize(reader);

            for (int i = 0; i < frames.Length; i++)
            {
                Frame frame = frames[i];

                CommandManager.ProcessFrame(i, frame);
            }
            yield break;
        }