/// <summary> /// Attempt to possess this MoveComponent with a MoveController. /// </summary> /// <param name="controller">The MoveController requesting possession of this MoveComponent.</param> public void Possess(MoveController controller) { _previousController = _controller; if (controller != null) { _controller = controller; if (!_controller.IsPossessing(this)) _controller.PossessMover(this); _possessed(controller); } }
/// <summary> /// Callback when this MoveComponent is unpossessed by a MoveController. /// </summary> /// <param name="controller">The MoveController that just unpossessed this MoveComponent.</param> protected virtual void _unpossessed(MoveController controller) { }
/// <summary> /// Revert possesion of this MoveComponent to it's previous MoveController. Presumably useful for /// swapping vehicle control or temporarily possessing movers for cutscenes and whatnot. /// </summary> public void RevertPossession() { MoveController controller = _previousController; if (_controller != null && _controller.IsPossessing(this)) _controller.UnpossessMover(this); _controller = controller; if (_controller != null && !_controller.IsPossessing(this)) _controller.PossessMover(this); }
/// <summary> /// Unpossess this MoveComponent. /// </summary> public void Unpossess() { _previousController = _controller; if (_controller != null) _unpossessed(_controller); if (_controller.IsPossessing(this)) _controller.UnpossessMover(this); _controller = null; }
/// <summary> /// Called when this Actor is possessed by a MoveController. This is used to make sure that only an ActorController can possess /// an ActorComponent. /// </summary> /// <param name="controller">The MoveController that possessed this Actor.</param> protected override void _possessed(MoveController controller) { base._possessed(controller); // make sure that the controller possessing us is an // actor controller. if not, dump it! if (controller as ActorController == null) Unpossess(); }