Ejemplo n.º 1
0
        public long Init(DigObject x)
        {
            long id = x.id;

            if (id == 0L)
            {
                id   = ++lastId;
                x.id = id;
                digObjects.Add(x);
            }

            Type t = x.GetType();

            if (t == tGameObject)
            {
                gameObjects.Add((GameObject)x);
            }
            else if (t == tRigidbody)
            {
                rigidbodies.Add((Rigidbody)x);
            }
            else if (t.IsSubclassOf(tBehaviour))
            {
                behaviours.Add((Behaviour)x);
            }
            else if (t.IsSubclassOf(tCollider))
            {
                colliders.Add((Collider)x);
            }
            return(id);
        }
Ejemplo n.º 2
0
        public void SetAsMain()
        {
            if (main == this)
            {
                return;
            }
            _main.value = this;
            long i = timeStamp;             //we also remove this from the savestates because savestates are for past objects

            while (saveStates.ContainsKey(i))
            {
                DigObject doi = saveStates[i];
                if (doi != this)
                {
                    doi.Dispose();
                }
                saveStates.Remove(i);
            }
        }
Ejemplo n.º 3
0
 public DigObject GetClone(long timeStamp)         //this prefers the savestates, and creates one if doesn't exist and has the same timestamp
 {
     if (saveStates.ContainsKey(timeStamp))
     {
         return(saveStates[timeStamp]);
     }
     if (timeStamp == this.timeStamp)
     {
         DisposeOld();
         DigObject clone = (DigObject)this.MemberwiseClone();
         saveStates[timeStamp] = clone;                 //this must be done before ValidateClone to avoid infinite recursion
         clone.ValidateClone();
         return(clone);
     }
     else
     {
         throw new Exception("Timestamp is too old. Timestamp: " + timeStamp + ". This timestamp: " + this.timeStamp);
     }
 }