Beispiel #1
0
        public static void RegisterObject(RecordableObject obj)
        {
            if (objects == null)
            {
                objects = new List <ObjectData> ();
            }

            if (obj.playbackMode)
            {
                return;
            }

            if (obj.spawnIndex >= 0)
            {
                objects.Add(new ObjectData(obj, (uint)obj.spawnIndex, tick));
            }
            else
            {
                Debug.LogError("Spawn Index is not set properly on: " + obj.gameObject);
                return;
            }

            obj.gmIndex = objects.Count - 1;
            objects [obj.gmIndex].ticks = new List <RecordData> ();
        }
Beispiel #2
0
        public static void UnregisterObject(RecordableObject obj)
        {
            if (objects == null || obj.gmIndex < 0 || objects.Count <= obj.gmIndex)
            {
                return;
            }

            objects[obj.gmIndex].destroyed = true;
        }
Beispiel #3
0
        public static void ObjectTick(RecordableObject obj, RecordData res)
        {
            if (obj.gmIndex == -1)
            {
                RegisterObject(obj);
            }

            if (recording)
            {
                if (objects [obj.gmIndex].ticks == null)
                {
                    objects [obj.gmIndex].ticks = new List <RecordData> ();
                }
                objects [obj.gmIndex].ticks.Add(res);
            }
        }
Beispiel #4
0
        public static void ObjectTick(RecordableObject obj, RecordData res)
        {
            if (obj.gmIndex == -1)
            {
                RegisterObject(obj);
            }

            if (objects [obj.gmIndex].ticks == null)
            {
                objects [obj.gmIndex].ticks = new List <RecordData> ();
            }
            objects [obj.gmIndex].ticks.Add(res);

            //If not recording, only keep a set amount of history data
            if (!recording)
            {
                while (objects[obj.gmIndex].ticks.Count > 0 && (float)(res.timestamp - objects[obj.gmIndex].ticks[0].timestamp) * sendDiv * Time.fixedDeltaTime > settings.lagCompensationAmount)
                {
                    objects[obj.gmIndex].ticks.RemoveAt(0);
                }
            }
        }
Beispiel #5
0
 public ObjectData(RecordableObject comp, uint goI, uint sTick)
 {
     component = comp;
     goIndex   = goI;
     startTick = sTick;
 }