/// <summary> /// Subtree for the user switching the lamp on/off. /// </summary> /// <param name="switchTo">THe desired state of StateName.IsTurnedOn after executing the tree.</param> private Node ST_Switch(SmartCharacter user, StateName switchTo) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding), this.Node_Require(StateName.RoleLamp, ~switchTo), user.Node_GoTo(standPoint.position), user.Node_OrientTowards(lightSwitch.transform.position), user.Node_StartInteraction(FullBodyBipedEffector.RightHand, lightSwitch.interactionObject), user.Node_WaitForFinish(FullBodyBipedEffector.RightHand), user.Node_StopInteraction(FullBodyBipedEffector.RightHand), new LeafInvoke(() => lightSwitch.Set(switchTo > 0)), this.Node_Set(switchTo) ); }