protected Node FillOutForm(SmartCharacter user) { Vector3 oldPosition = new Vector3(); return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated, ~StateName.RightHandOccupied), this.Node_Require(StateName.RoleTable, ~StateName.HoldingBall, ~StateName.HoldingWallet), new LeafInvoke(() => oldPosition = user.transform.position), new Race( new Sequence( new LeafWait(15000), new LeafInvoke(() => RunStatus.Failure)), user.ST_StandAtWaypoint(this.StandPoint)), user.Node_NudgeTo(Val.V(() => this.StandPoint.position)), new LeafInvoke(() => user.transform.rotation = this.StandPoint.rotation), new LeafInvoke(() => user.HoldPropRightHand.Attach(user.HoldPropHidden.Release())), new LeafInvoke(() => user.GetRightProp().FadeIn()), user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.PropPickup), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), new LeafInvoke(() => this.PropHolder.Attach(user.HoldPropRightHand.Release())), user.Node_StopInteraction(FullBodyBipedEffector.RightHand), user.Behavior.ST_PlayHandGesture("writing", 6000), user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.PropPickup), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), new LeafInvoke(() => user.HoldPropRightHand.Attach(this.PropHolder.Release())), user.Node_StopInteraction(FullBodyBipedEffector.RightHand), new LeafWait(500), new LeafInvoke(() => user.GetRightProp().FadeOut()), new LeafWait(500), new LeafInvoke(() => user.HoldPropHidden.Attach(user.HoldPropRightHand.Release())), user.Node_GoTo(Val.V(() => oldPosition))); }
protected Node GetDrink(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.RightHandOccupied, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleDispenser), user.Node_GoTo(this.StandPoint.position), user.Node_OrientTowards(this.DrinkButton.transform.position), new DecoratorCatch( () => //if terminates, make sure the right hand interaction and headlook is stopped { user.Character.StopInteraction(FullBodyBipedEffector.RightHand); user.Character.HeadLookStop(); }, new Sequence( user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.DrinkButton), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), new SequenceParallel( //user.Node_HeadLook(this.DrinkPickup.transform.position), user.Node_OrientTowards(this.DrinkPickup.transform.position)), user.Node_StopInteraction(FullBodyBipedEffector.RightHand), new LeafWait(1000), new LeafInvoke(() => GenerateDrink()), new LeafWait(500))), user.ST_Pickup(DrinkHolder, DrinkPickup), user.Node_Set(StateName.HoldingDrink, StateName.RightHandOccupied), user.Node_GoTo(this.LeavePoint.position)); }
/// <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.RoleTelevision, ~switchTo), user.Node_GoTo(turnOnOffStandPoint.position), user.Node_OrientTowards(onOffSwitch.transform.position), user.Node_StartInteraction(FullBodyBipedEffector.LeftHand, onOffSwitch), user.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand), user.Node_StopInteraction(FullBodyBipedEffector.LeftHand), this.Node_Set(switchTo) ); }
protected Node Press(SmartCharacter user) { return new Sequence( user.ST_StandAtWaypoint(StandPoint), user.Node_StartInteraction(FullBodyBipedEffector.LeftHand, InteractionPress), user.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand), new DecoratorLoop( 10, new LeafInvoke(() => PhysicalPress.PhysicalButton.position += PhysicalPress.PressDirection.normalized * 0.003f)), new LeafInvoke(() => this.ButtonTransform.GetComponent<Renderer>().material.color = Color.green), new DecoratorLoop( 10, new LeafInvoke(() => PhysicalPress.PhysicalButton.position -= PhysicalPress.PressDirection.normalized * 0.003f)), user.Node_StopInteraction(FullBodyBipedEffector.LeftHand), user.Node_HeadLookStop()); }
/// <summary> /// Subtree for Give. Here holdingState should be the StateName corresponding /// to the state for holding the object exchanged, e.g. HoldingWallet, HoldingBall. /// beforeGive and afterGive can be used to specify actions to be done both before the give starts /// (but after they have met and oriented towards each other) and to be done after the give ends. /// </summary> protected Node ST_Give(SmartCharacter user, StateName holdingState, Node beforeGive, Node afterGive) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, holdingState, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleActor, StateName.IsStanding, ~holdingState, ~StateName.IsIncapacitated), new SequenceParallel( user.Node_GoToUpToRadius(new Val<Vector3>(this.transform.position), 1.0f), this.Node_OrientTowards(new Val<Vector3>(user.transform.position)), user.Node_OrientTowards(new Val<Vector3>(this.transform.position))), beforeGive, new SequenceParallel( user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionGive), new Sequence( new LeafWait(1000), this.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionTake)), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), this.Node_WaitForTrigger(FullBodyBipedEffector.RightHand)), new LeafInvoke(() => this.HoldPropRightHand.Attach(user.HoldPropRightHand.Release())), user.Node_Set(~holdingState), afterGive, this.Node_Set(holdingState), new SequenceParallel( user.Node_StopInteraction(FullBodyBipedEffector.RightHand), this.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionHoldRight))); }
protected Node TakeWeaponIncapacitated(SmartCharacter user) { return new Sequence( user.Node_GoToUpToRadius(Val.V(() => this.WaypointFront.position), 1.0f), user.Node_OrientTowards(Val.V(() => this.transform.position)), //TODO new interaction object to take the weapon? user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionGive), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), new LeafInvoke(() => user.HoldPropRightHand.Attach(this.HoldPropRightHand.Release())), this.Node_Set(~StateName.RightHandOccupied, ~StateName.HoldingWeapon), user.Node_Set(StateName.RightHandOccupied, StateName.HoldingWeapon), new LeafInvoke(() => Debug.Log("Here2")), user.Node_StopInteraction(FullBodyBipedEffector.RightHand)); }
protected Node GiveBriefcase(SmartCharacter user) { return new Sequence( user.Node_GoToUpToRadius(Val.V(() => this.transform.position), 1.5f), new SequenceParallel( user.Node_OrientTowards(Val.V(() => this.transform.position)), this.Node_OrientTowards(Val.V(() => user.transform.position))), new SequenceParallel( user.Node_StartInteraction(FullBodyBipedEffector.LeftHand, this.InteractionGive), new Sequence( new LeafWait(1000), this.Node_StartInteraction(FullBodyBipedEffector.LeftHand, this.InteractionTake)), user.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand), this.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand)), new LeafInvoke(() => this.HoldPropLeftHand.Attach(user.HoldPropLeftHand.Release())), user.Node_Set(~StateName.HasBackpack), this.Node_Set(StateName.HasBackpack), new SequenceParallel( user.Node_StopInteraction(FullBodyBipedEffector.LeftHand), this.Node_StopInteraction(FullBodyBipedEffector.LeftHand))); }
protected Node ST_Take(SmartCharacter user, StateName holdingState, Node afterTake) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.HoldingBall, ~StateName.HoldingWallet, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleTable, holdingState), user.Node_GoTo(this.StandPoint.position), new SequenceParallel( user.Node_HeadLook(this.PropPickup.transform.position), user.Node_OrientTowards(this.PropPickup.transform.position)), new DecoratorCatch( () => { user.Character.StopInteraction(FullBodyBipedEffector.RightHand); user.Character.HeadLookStop(); }, new Sequence( user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.PropPickup), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), new LeafInvoke(() => user.HoldPropRightHand.Attach(this.PropHolder.Release())), user.Node_HeadLookStop())), this.Node_Set(~holdingState), afterTake, user.Node_Set(holdingState), user.Node_StartInteraction(FullBodyBipedEffector.RightHand, user.InteractionHoldRight), user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand), new LeafWait(300)); }