// CALLBACK private void OnRemovedRigidbody(IBody i_Body) { GameObject go = PhysicsManager.GetGameObject(i_Body); if (go != null) { TrueSyncObject trueSyncObject = go.GetComponent <TrueSyncObject>(); if (trueSyncObject != null) { m_TsBehaviourCache.Clear(); for (int index = 0; index < trueSyncObject.behaviourCount; ++index) { TrueSyncBehaviour behaviour = trueSyncObject.GetTrueSyncBehaviourByIndex(index); if (behaviour != null) { m_TsBehaviourCache.Add(behaviour); } } RemoveFromTSMBList(m_QueuedBehaviours, m_TsBehaviourCache); RemoveFromTSMBList(m_GeneralBehaviours, m_TsBehaviourCache); foreach (List <TrueSyncManagedBehaviour> list in m_BehavioursPerPlayer.Values) { RemoveFromTSMBList(list, m_TsBehaviourCache); } m_TsBehaviourCache.Clear(); } } }
private static object OverlapGeneric(Physics2D.Shape i_Shape, TSVector2 i_Position, Physics2D.BodySpecialSensor i_SensorType, int i_Mask) { Physics2D.World world = (Physics2D.World)PhysicsManager.GetWorld(); Physics2D.Body body = Physics2D.BodyFactory.CreateBody(world); body.CreateFixture(i_Shape); body.BodyType = Physics2D.BodyType.Static; body.CollisionCategories = Physics2D.Category.All; // Category.All is used for sweep test objects. body.CollidesWith = (Physics2D.Category)i_Mask; body.CollisionGroup = 0; body.IsSensor = true; body.SpecialSensor = i_SensorType; body.SpecialSensorMask = (int)Physics2D.Category.All; body.Position = i_Position; world.RemoveBody(body); world.ProcessRemovedBodies(); if (body._specialSensorResults.Count > 0) { if (i_SensorType == Physics2D.BodySpecialSensor.ActiveOnce) { return(PhysicsManager.GetGameObject(body._specialSensorResults[0]).GetComponent <TSCollider2D>()); } else { TSCollider2D[] result = new TSCollider2D[body._specialSensorResults.Count]; for (int i = 0; i < body._specialSensorResults.Count; i++) { result[i] = PhysicsManager.GetGameObject(body._specialSensorResults[i]).GetComponent <TSCollider2D>(); } return(result); } } return(null); }