Exemplo n.º 1
0
        protected virtual void PlayAnimation(
            IEquipmentHolder holder,
            Equipment equipment,
            Option <Node> dropTo,
            Godot.Animation animation,
            IAnimationManager animationManager,
            InteractionContext context)
        {
            animationManager.OnAnimationEvent
            .OfType <TriggerEvent>()
            .Where(e => e.Name == "Action" && e.Argument.Contains(Key))
            .Take(1)
            .TakeUntil(Disposed.Where(identity))
            .Subscribe(_ => Unequip(holder, equipment, dropTo, context), this);

            if (animationManager is IAnimationStateManager stateManager &&
                AnimatorPath.IsSome && StatesPath.IsSome)
            {
                (
                    from animator in AnimatorPath.Bind(stateManager.FindAnimator)
                    from states in StatesPath.Bind(stateManager.FindStates)
                    from state in ActionState
                    select(animator, states, state)).Iter(t =>
                {
                    t.animator.Animation = animation;
                    t.states.Playback.Travel(t.state);
                });
            }
Exemplo n.º 2
0
 protected override Validation <string, DropAction> CreateService(
     string key, string displayName, ILoggerFactory loggerFactory)
 {
     return(new DropAction(
                key,
                displayName,
                AnimatorPath.TrimToOption(),
                StatesPath.TrimToOption(),
                ActionState.TrimToOption(),
                toSet(Optional(Tags).Flatten()),
                Active,
                loggerFactory)
     {
         Animation = Animation
     });
 }
Exemplo n.º 3
0
 protected override Validation <string, SitAction> CreateService(
     string key, string displayName, ILoggerFactory loggerFactory)
 {
     return
         (from animation in Prelude.Optional(Animation)
          .ToValidation("Animation was not specified.")
          from statesPath in StatesPath.TrimToOption()
          .ToValidation("States path was not specified.")
          from subStatesPath in SubStatesPath.TrimToOption()
          .ToValidation("Sub-states path was not specified.")
          from idleState in IdleState.TrimToOption()
          .ToValidation("Idle state value was not specified.")
          from enterState in EnterState.TrimToOption()
          .ToValidation("Enter state value was not specified.")
          from state in State.TrimToOption()
          .ToValidation("State path was not specified.")
          from exitState in ExitState.TrimToOption()
          .ToValidation("Exit state value was not specified.")
          from enterAnimatorPath in EnterAnimatorPath.TrimToOption()
          .ToValidation("Enter animator path was not specified.")
          from animatorPath in AnimatorPath.TrimToOption()
          .ToValidation("Animator path was not specified.")
          from exitAnimatorPath in ExitAnimatorPath.TrimToOption()
          .ToValidation("Exit animator path was not specified.")
          select new SitAction(
              key,
              displayName,
              animation,
              statesPath,
              subStatesPath,
              idleState,
              enterState,
              state,
              exitState,
              enterAnimatorPath,
              animatorPath,
              exitAnimatorPath,
              Active,
              loggerFactory)
     {
         SittingDownAnimation = SittingDownAnimation,
         GettingUpAnimation = GettingUpAnimation
     });
 }