コード例 #1
0
 protected override Validation <string, AnimationDrivenLocomotion> CreateService(
     KinematicBody target,
     Physics3DSettings physicsSettings,
     ILoggerFactory loggerFactory)
 {
     return
         (from manager in AnimationManager
          .ToValidation("Failed to find the animation manager.")
          from skeleton in Skeleton
          .ToValidation("Failed to find the skeleton.")
          from states in StatesPath.TrimToOption().Bind(manager.FindStates)
          .ToValidation($"Unable to find an AnimationStates control at '{StatesPath}'.")
          from blender in Blend2DPath.TrimToOption().Bind(manager.FindBlender2D)
          .ToValidation($"Unable to find a Blender2D control at '{Blend2DPath}'.")
          from timeScale in TimeScalePath.TrimToOption().Bind(manager.FindTimeScale)
          .ToValidation($"Unable to find a TimeScale control at '{TimeScalePath}'.")
          from idleState in IdleState.TrimToOption()
          .ToValidation("Idle state value was not specified.")
          from moveState in MoveState.TrimToOption()
          .ToValidation("Move state value was not specified.")
          select new AnimationDrivenLocomotion(
              manager.AnimationTree,
              skeleton,
              states,
              blender,
              timeScale,
              idleState,
              moveState,
              target,
              physicsSettings,
              this,
              Active,
              loggerFactory));
 }
コード例 #2
0
ファイル: DropAction.cs プロジェクト: kitfka/AlleyCat
        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);
                });
            }
コード例 #3
0
        private void EndPath(StatesPath path, State currentState, StatesPathStatus pathStatus)
        {
            var pathCopy = Mapper.Map <StatesPath>(path);

            pathCopy.Status = pathStatus;
            pathCopy.StatesPathCollection.Add(new StatesPathNode()
            {
                State = currentState
            });
            ImportantPaths.Add(pathCopy);
        }
コード例 #4
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
     });
 }
コード例 #5
0
 protected override Validation <string, MeleeToolConfiguration> CreateService(
     string key,
     string slot,
     Set <string> additionalSlots,
     Set <string> tags,
     ILoggerFactory loggerFactory)
 {
     return
         (from swingAnimation in Optional(SwingAnimation)
          .ToValidation("Missing swing animation.")
          from statesPath in StatesPath.TrimToOption()
          .ToValidation("Missing animation state machine path.")
          from seekerPath in SeekerPath.TrimToOption()
          .ToValidation("Missing seekable animator path.")
          from playerControl in PlayerControl
          .ToValidation("Failed to find the player control.")
          from idleState in IdleState.TrimToOption()
          .ToValidation("Idle state value was not specified.")
          from swingState in SwingState.TrimToOption()
          .ToValidation("Swing state value was not specified.")
          select new MeleeToolConfiguration(
              key,
              slot,
              additionalSlots,
              tags,
              ArmInput,
              SwingInput,
              swingAnimation,
              statesPath,
              seekerPath,
              idleState,
              swingState,
              new Range <float>(Max(MinPosition, 0), Max(MaxPosition, 0), TFloat.Inst),
              playerControl,
              Active,
              loggerFactory)
     {
         Mesh = Mesh,
         EquipAnimation = EquipAnimation,
         UnequipAnimation = UnequipAnimation,
         Animation = Animation,
         AnimationBlend = AnimationBlend,
         AnimationTransition = AnimationTransition
     });
 }
コード例 #6
0
ファイル: SitActionFactory.cs プロジェクト: kitfka/AlleyCat
 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
     });
 }
コード例 #7
0
 protected override Validation <string, GetUpAction> CreateService(
     string key, string displayName, ILoggerFactory loggerFactory)
 {
     return
         (from statesPath in StatesPath.TrimToOption()
          .ToValidation("States path was not specified.")
          from subStatesPath in SubStatesPath.TrimToOption()
          .ToValidation("Sub-states path 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.")
          select new GetUpAction(
              key,
              displayName,
              statesPath,
              subStatesPath,
              state,
              exitState,
              Active,
              loggerFactory));
 }
コード例 #8
0
        private void StepInsideNet(StatesPath path, StatesNet net, State currentState, string finishStateId)
        {
            if (currentState.AvailableEvents.IsNullOrEmpty())
            {
                EndPath(path, currentState, StatesPathStatus.Blocked);
                return;
            }

            if (StateOccuredPreviously(path, currentState))
            {
                EndPath(path, currentState, StatesPathStatus.Unsuccessful);
                return;
            }

            if (currentState.Id.Equals(finishStateId))
            {
                EndPath(path, currentState, StatesPathStatus.Successful);
                return;
            }

            foreach (var availableEvent in currentState.AvailableEvents)
            {
                var currentNode = new StatesPathNode
                {
                    State          = currentState,
                    LeavingEventId = availableEvent
                };

                var iterationPath = Mapper.Map <StatesPath>(path);
                iterationPath.StatesPathCollection.Add(currentNode);

                var nextStateId = currentState.AvaliableStatesIds[availableEvent];
                var nextState   = net.GetById(nextStateId);

                StepInsideNet(iterationPath, net, nextState, finishStateId);
            }
        }
コード例 #9
0
 private bool StateOccuredPreviously(StatesPath path, State currentState)
 {
     return(path.StatesPathCollection
            .Select(node => node.State.Id)
            .Any(id => id.Equals(currentState.Id)));
 }