public override void OnEvent(ObjectMoved evnt) { if (evnt.Entity.IsOwner) { // Interactive objects respond to events if (evnt.Entity.GetComponent <InteractiveObjects>()) { i = evnt.Entity.GetComponent <InteractiveObjects>(); } if (evnt.Push) { i.SetVelocity(evnt.Velocity); evnt.Entity.GetState <IDynamicObjectState>().Held = false; } else { if (evnt.Hold) { i.Hold(evnt.Position, evnt.Rotation); evnt.Entity.GetState <IDynamicObjectState>().Held = true; } else { i.Drop(evnt.Velocity); evnt.Entity.GetState <IDynamicObjectState>().Held = false; } } } }
private void OnInteractiveObjectDestroyed(CoreInteractiveObject InteractiveObject) { InteractiveObjects.Remove(InteractiveObject); var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.GetLogicColliderAsBox(); if (interactiveObjectLogicCollider != null) { InteractiveObjectsIndexedByLogicCollider.Remove(interactiveObjectLogicCollider); } }
private void OnInteractiveObjectCreated(CoreInteractiveObject InteractiveObject) { InteractiveObjects.Add(InteractiveObject); var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.GetLogicColliderAsBox(); if (interactiveObjectLogicCollider != null) { InteractiveObjectsIndexedByLogicCollider.Add(interactiveObjectLogicCollider, InteractiveObject); } }
public override void OnDestroy() { base.OnDestroy(); for (var i = InteractiveObjects.Count - 1; i >= 0; i--) { OnInteractiveObjectDestroyed(InteractiveObjects[i]); } InteractiveObjects.Clear(); InteractiveObjects = null; InteractiveObjectsIndexedByLogicCollider.Clear(); InteractiveObjectsIndexedByLogicCollider = null; }
private void OnInteractiveObjectCreated(CoreInteractiveObject InteractiveObject) { InteractiveObjects.Add(InteractiveObject); if (InteractiveObject.InteractiveGameObject != null) { var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.LogicCollider; if (interactiveObjectLogicCollider != null) { InteractiveObjectsIndexedByLogicCollider.Add(interactiveObjectLogicCollider, InteractiveObject); } } InteractiveObject.RegisterInteractiveObjectDestroyedEventListener(this.OnInteractiveObjectDestroyed); }
private void DestroyAllInteractiveObjects() { InteractiveObjects.ForEach(x => { GameObject.Destroy(x); }); InteractiveObjects.Clear(); Enemies.ForEach(x => { GameObject.Destroy(x); }); Enemies.Clear(); }
public void AddInteractiveObject(GameObject interactiveObject) { InteractiveObjects.Add(interactiveObject); }