private void OnRemovedRigidBody(IBody body)
    {
        GameObject go = PhysicsManager.instance.GetGameObject(body);

        if (go != null)
        {
            PhysicsManager.instance.RemoveBody(body);

            List <FrameSyncBehaviour> behavioursToRemove = new List <FrameSyncBehaviour>(go.GetComponentsInChildren <FrameSyncBehaviour>());

            for (int i = 0; i < behavioursToRemove.Count; i++)
            {
                IFrameSyncBehaviour tsmb = behavioursToRemove[i] as IFrameSyncBehaviour;

                int index = GetBehaviourIndex(mapManagedBehaviors, tsmb);
                if (index >= 0)
                {
                    mapManagedBehaviors.RemoveAt(index);
                }
            }

            foreach (var item in behaviorsByPlayer)
            {
                List <FrameSyncManagedBehaviour> listBh = item.Value;
                RemoveFromTSMBList(listBh, behavioursToRemove);
            }
        }
    }
Esempio n. 2
0
 /**
  * @brief Registers an implementation of {@link IFrameSyncBehaviour} to be included in the simulation.
  *
  * @param FrameSyncBehaviour Instance of an {@link IFrameSyncBehaviour}
  **/
 public static void RegisterIFrameSyncBehaviour(IFrameSyncBehaviour FrameSyncBehaviour)
 {
     if (instance != null && instance.lockstep != null)
     {
         instance.queuedBehaviours.Add(instance.NewManagedBehavior(FrameSyncBehaviour));
     }
 }
Esempio n. 3
0
 /**
  * @brief Registers an implementation of {@link IFrameSyncBehaviour} to be included in the simulation.
  *
  * @param FrameSyncBehaviour Instance of an {@link IFrameSyncBehaviour}
  **/
 public static void RegisterIFrameSyncBehaviour(IFrameSyncBehaviour FrameSyncBehaviour)
 {
     if (instance != null /*&& instance.lockstep != null*/)
     {
         instance.ListManagedBehaviors.Add(new KeyValuePair <IFrameSyncBehaviour, FrameSyncManagedBehaviour>(
                                               FrameSyncBehaviour, instance.NewManagedBehavior(FrameSyncBehaviour)));
     }
 }
Esempio n. 4
0
        private FrameSyncManagedBehaviour NewManagedBehavior(IFrameSyncBehaviour FrameSyncBehavior)
        {
            FrameSyncManagedBehaviour result = new FrameSyncManagedBehaviour(FrameSyncBehavior);

            //mapBehaviorToManagedBehavior[FrameSyncBehavior] = result;

            return(result);
        }
Esempio n. 5
0
    public static GameObject RemoveSyncBehaviour(GameObject go)
    {
        if (go == null || instance == null)
        {
            return(null);
        }

        List <FrameSyncBehaviour> behavioursToRemove = new List <FrameSyncBehaviour>(go.GetComponentsInChildren <FrameSyncBehaviour>());

        for (int i = 0; i < behavioursToRemove.Count; i++)
        {
            IFrameSyncBehaviour tsmb = behavioursToRemove[i] as IFrameSyncBehaviour;

            int index = instance.GetBehaviourIndex(instance.ListManagedBehaviors, tsmb);
            if (index >= 0)
            {
                instance.ListManagedBehaviors.RemoveAt(index);
            }
        }
        return(go);
    }
 public FrameSyncManagedBehaviour(IFrameSyncBehaviour FrameSyncBehavior)
 {
     StateTracker.AddTracking(this);
     StateTracker.AddTracking(FrameSyncBehavior);
     this.FrameSyncBehavior = FrameSyncBehavior;
 }
Esempio n. 7
0
    public int GetBehaviourIndex(List <KeyValuePair <IFrameSyncBehaviour, FrameSyncManagedBehaviour> > Behaviors, IFrameSyncBehaviour bh)
    {
        for (int i = 0; i < Behaviors.Count; i++)
        {
            if (Behaviors[i].Key == bh)
            {
                return(i);
            }
        }

        return(-1);
    }
Esempio n. 8
0
    private FrameSyncManagedBehaviour NewManagedBehavior(IFrameSyncBehaviour FrameSyncBehavior)
    {
        FrameSyncManagedBehaviour result = new FrameSyncManagedBehaviour(FrameSyncBehavior);

        return(result);
    }