Exemplo n.º 1
0
 public static void AddFrameCommand(FrameIdxInfo info)
 {
     lock (SyncRoot)
     {
         KeyFrameCollection.FrameIdx = info.Idx;
         KeyFrameCollection.KeyFrames.Add(info);
     }
 }
Exemplo n.º 2
0
        public static void AddCurrentFrameCommand(int cmd, string entityId, string[] paramsString)
        {
            Simulation sim = SimulationManager.Instance.GetSimulation(Const.CLIENT_SIMULATION_ID);

            if (sim != null)
            {
                var logic = sim.GetBehaviour <LogicFrameSync.Src.LockStep.Behaviours.LogicFrameBehaviour>();
                if (logic != null)
                {
                    FrameIdxInfo info = new FrameIdxInfo(logic.CurrentFrameIdx, cmd, entityId, paramsString);
                    AddFrameCommand(info);
                }
            }
        }
Exemplo n.º 3
0
        public static byte[] Write(FrameIdxInfo info)
        {
            ByteBuffer buffer = new ByteBuffer();

            buffer.WriteInt32(info.Idx);
            buffer.WriteInt32(info.Cmd);
            buffer.WriteString(info.EntityId);
            int size = info.Params.Length;

            buffer.WriteInt32(size);
            for (int i = 0; i < size; ++i)
            {
                buffer.WriteString(info.Params[i]);
            }
            return(buffer.Getbuffer());
        }
Exemplo n.º 4
0
        public static FrameIdxInfo Read(byte[] bytes)
        {
            ByteBuffer   buffer = new ByteBuffer(bytes);
            FrameIdxInfo info   = new FrameIdxInfo();

            info.Idx      = buffer.ReadInt32();
            info.Cmd      = buffer.ReadInt32();
            info.EntityId = buffer.ReadString();
            int size = buffer.ReadInt32();

            info.Params = new string[size];
            for (int i = 0; i < size; ++i)
            {
                info.Params[i] = buffer.ReadString();
            }
            return(info);
        }
Exemplo n.º 5
0
        public static FrameIdxInfo DeSerialize(string str)
        {
            FrameIdxInfo info = new FrameIdxInfo();
            var          strs = str.Split(',');

            info.Idx      = int.Parse(strs[0]);
            info.Cmd      = int.Parse(strs[1]);
            info.EntityId = new System.Guid(strs[2]);
            int size = strs.Length - 4;

            if (size > 0)
            {
                info.Params = new string[size];
                for (int i = 0; i < size; i++)
                {
                    info.Params[i] = strs[3 + i];
                }
            }

            return(info);
        }
Exemplo n.º 6
0
        public static string Serialize(FrameIdxInfo info)
        {
            sb.Clear();

            sb.Append(info.Idx);
            sb.Append(",");
            sb.Append(info.Cmd);
            sb.Append(",");
            sb.Append(info.EntityId);
            sb.Append(",");

            int size = info.Params.Length;

            for (int i = 0; i < size; ++i)
            {
                sb.Append(info.Params[i]);
                sb.Append(",");
            }

            return(sb.ToString());
        }
Exemplo n.º 7
0
 public bool EqualsInfo(FrameIdxInfo target)
 {
     return(EntityId == target.EntityId && Cmd == target.Cmd && Idx == target.Idx);
 }