public Node Stand(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, ~StateName.IsStanding, ~StateName.IsIncapacitated), user.Node_Require(this.Id, RelationName.IsSittingOn), this.Node_Require(StateName.RoleChair, StateName.IsOccupied), new LeafInvoke(() => user.Character.StandUp()), new LeafWait(1000), user.Node_Set(StateName.IsStanding), user.Node_Set(this.Id, ~RelationName.IsSittingOn), this.Node_Set(~StateName.IsOccupied)); }
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)); }
protected Node DropDrink(SmartCharacter user) { Prop toDestroy = null; return new Sequence( this.Node_Require(StateName.RoleTrashcan), user.Node_Require(StateName.RoleActor, StateName.IsStanding, StateName.HoldingDrink, StateName.RightHandOccupied), new LeafInvoke(() => toDestroy = user.HoldPropRightHand.CurrentProp), user.ST_StandAtWaypoint(this.StandPoint), user.ST_DropAndDestroy(DropTrash), user.Node_Set(~StateName.HoldingDrink, ~StateName.RightHandOccupied)); }
/// <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) ); }
/// <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) ); }
public Node Sit(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleChair, ~StateName.IsOccupied), this.Node_Set(StateName.IsOccupied), 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), user.Node_Set(~StateName.IsStanding), user.Node_Set(this.Id, RelationName.IsSittingOn), new LeafInvoke(() => user.Character.SitDown()), new LeafWait(1000), new LeafInvoke(() => user.Character.NavOrientBehavior(OrientationBehavior.LookForward))); }
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)); }
protected Node CustomerPutMoney(SmartCharacter user) { return new Sequence( this.Node_Require(StateName.RoleTeller), user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.RightHandOccupied, ~StateName.IsIncapacitated, StateName.HoldingWallet), user.ST_TakeWalletFromPocket(), user.ST_Put(HoldPropIntermediate, InteractionIntermediateCustomer), user.Node_Set(~StateName.HoldingWallet), this.Node_Set(StateName.HoldingWallet)); }
protected Node TellerPutMoney(SmartCharacter user) { return new Sequence( this.Node_Require(StateName.RoleTeller, StateName.HoldingWallet), user.Node_Require(StateName.RoleTeller, StateName.IsStanding, ~StateName.RightHandOccupied, ~StateName.IsIncapacitated), this.Node_Require(user.Id, RelationName.IsAdjacentTo), user.Node_GoTo(TellerStandPoint.position), user.Node_OrientTowards(CustomerStandPoint.position), user.ST_Pickup(HoldPropIntermediate, InteractionIntermediateTeller), user.ST_Put(HoldPropStorage, InteractionStorage), this.Node_Set(~StateName.HoldingWallet)); }
protected Node ST_Drop(SmartCharacter user, StateName holdingState, PropHolder holder) { return new Sequence( user.Node_Require(StateName.RoleActor, holdingState, StateName.IsStanding), this.Node_Require(StateName.RoleContainer, ~StateName.IsOccupied), new LeafInvoke(() => this.Holder.Attach(holder.Release())), this.Node_Set(holdingState, StateName.IsOccupied), user.Node_Set(~holdingState)); }
/// <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 GiveKey(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.HasKeys, StateName.IsStanding, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleActor, ~StateName.HasKeys, StateName.IsStanding, ~StateName.IsIncapacitated), user.Node_Icon("key"), new LeafWait(2000), user.Node_Icon(null), this.Node_Icon("key"), new LeafWait(2000), this.Node_Icon(null), user.Node_Set(~StateName.HasKeys), this.Node_Set(StateName.HasKeys)); }
protected Node Incapacitate(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.HoldingBall, ~StateName.HoldingDrink, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsDead), new LeafAssert(() => user != this), // Not reflexive user.Node_GoToUpToRadius(new Val<Vector3>(this.transform.position), 1.0f), new LeafInvoke(() => this.DecorationStars.gameObject.SetActive(true)), this.Node_Set(StateName.IsIncapacitated) ); }
protected Node TalkAngrily(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated), new LeafAssert(() => user != this), // Not reflexive this.ST_Talk(user), new SequenceParallel( this.Node_Icon("sad"), user.Node_Icon("sad")), new LeafWait(1500), new SequenceParallel( this.Node_Icon(null), user.Node_Icon(null)) ); }
protected Node Talk(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated), this.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated), new LeafAssert(() => user != this), // Not reflexive this.ST_Talk(user) ); }
protected Node ST_DropRightHand(SmartCharacter user, StateName holdingState) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.RightHandOccupied, holdingState, StateName.IsStanding), this.Node_Require(StateName.RoleContainer, ~StateName.IsOccupied), new LeafInvoke(() => this.transform.position = user.transform.position), new LeafInvoke(() => this.Holder.Attach(user.HoldPropRightHand.Release())), this.Node_Set(holdingState, StateName.IsOccupied), user.Node_Set(~holdingState, ~StateName.RightHandOccupied)); }
public Node Approach(SmartCharacter user) { return new Sequence( user.Node_Require(StateName.RoleActor, StateName.IsStanding), user.Node_GoTo(target.position)); }
protected Node ST_PickupLeftHand(SmartCharacter user, StateName holdingState) { return new Sequence( user.Node_Require(StateName.RoleActor, ~StateName.LeftHandOccupied, StateName.IsStanding), this.Node_Require(StateName.RoleContainer, holdingState, StateName.IsOccupied), user.Node_GoToUpToRadius(Val.V(() => this.ContainedProp.transform.position + 0.15f * user.transform.right), 0.1f), user.Behavior.Node_BodyAnimation("pickupleft", true), new LeafWait(500), new LeafInvoke(() => user.HoldPropLeftHand.Attach(this.Holder.Release())), this.Node_Set(~holdingState, ~StateName.IsOccupied), user.Node_Set(holdingState, StateName.LeftHandOccupied), new LeafWait(500)); }