///<summary> /// Cleans up the pair handler. ///</summary> public override void CleanUp() { //Fire off some events if needed! Note the order; we should stop containing before we stop touching. if (Parent == null) { if (Containing) { DetectorVolume.StoppedContaining(this); } if (Touching) { DetectorVolume.StoppedTouching(this); } } Containing = false; Touching = false; WasContaining = false; WasTouching = false; DetectorVolume.pairs.Remove(Collidable.entity); broadPhaseOverlap = new BroadPhaseOverlap(); DetectorVolume = null; Parent = null; //Child cleanup is responsible for cleaning up direct references to the involved collidables. }
protected void NotifyDetectorVolumeOfChanges() { //Don't notify the detector volume if we have a parent. The parent will analyze our state. if (Parent == null) { //Beware the order! //Starts touching -> starts containing if (!WasTouching && Touching) { DetectorVolume.BeganTouching(this); } if (!WasContaining && Containing) { DetectorVolume.BeganContaining(this); } //Stops containing -> stops touching if (WasContaining && !Containing) { DetectorVolume.StoppedContaining(this); } if (WasTouching && !Touching) { DetectorVolume.StoppedTouching(this); } } }