Ejemplo n.º 1
0
        public void SetOutput(PlayerEntity player)
        {
            IBoneRigging boneRigging = player.characterBoneInterface.CharacterBone;

            foreach (var output in _fsmOutput)
            {
                if (output.Valid)
                {
                    if (SharedConfig.IsServer)
                    {
                        _FsmOutputAction[(int)output.Type].ServerAction(player, output);
                    }
                    else
                    {
                        _FsmOutputAction[(int)output.Type].ClientAction(player, output);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static FsmOutputBaseSystem()
        {
            Action <PlayerEntity, FsmOutput> empty = (entity, output) => { };

            //ChangeDiveSensitivity

            for (int i = 0; i < _FsmOutputAction.Length; ++i)
            {
                _FsmOutputAction[i] = new FsmOutputAction
                {
                    ClientAction = empty,
                    ServerAction = empty
                };
            }
            _FsmOutputAction[(short)FsmOutputType.ChangeDiveSensitivity].ServerAction = empty;
            _FsmOutputAction[(short)FsmOutputType.ChangeDiveSensitivity].ClientAction = (player, output) =>
            {
                player.appearanceInterface.Appearance.SetInputSchemeActionField((int)output.FloatValue,
                                                                                InputSchemeConst.ActionHorizontal);
                player.appearanceInterface.Appearance.SetInputSchemeActionField((int)output.FloatValue,
                                                                                InputSchemeConst.ActionVertical);
                player.appearanceInterface.Appearance.SetInputSchemeActionField((int)output.FloatValue,
                                                                                InputSchemeConst.ActionUpDown);
            };

            //CharacterControllerHeight
            _FsmOutputAction[(short)FsmOutputType.CharacterControllerHeight].ServerAction = (entity, output) =>
            {
                entity.characterControllerInterface.CharacterController.SetCharacterControllerHeight(output.FloatValue);
            };
            _FsmOutputAction[(short)FsmOutputType.CharacterControllerHeight].ClientAction = (entity, output) =>
            {
                entity.characterControllerInterface.CharacterController.SetCharacterControllerHeight(output.FloatValue);
                entity.stateInterVar.StateInterCommands.Commands.Add(
                    new KeyValuePair <short, float>((short)FsmOutputType.CharacterControllerHeight, output.FloatValue));
            };

            //CharacterControllerJumpHeight
            _FsmOutputAction[(short)FsmOutputType.CharacterControllerJumpHeight].ServerAction = (entity, output) =>
            {
                entity.characterControllerInterface.CharacterController.SetCharacterControllerHeight(output.FloatValue, false);
            };

            _FsmOutputAction[(short)FsmOutputType.CharacterControllerJumpHeight].ClientAction = (entity, output) =>
            {
                entity.characterControllerInterface.CharacterController.SetCharacterControllerHeight(output.FloatValue, false);
                entity.stateInterVar.StateInterCommands.Commands.Add(
                    new KeyValuePair <short, float>((short)FsmOutputType.CharacterControllerJumpHeight,
                                                    output.FloatValue));
            };

            //CharacterControllerRadius
            _FsmOutputAction[(short)FsmOutputType.CharacterControllerRadius].ServerAction = (entity, output) =>
            {
                entity.characterControllerInterface.CharacterController.SetCharacterControllerRadius(output.FloatValue);
            };

            _FsmOutputAction[(short)FsmOutputType.CharacterControllerRadius].ClientAction = (entity, output) =>
            {
                entity.characterControllerInterface.CharacterController.SetCharacterControllerRadius(output.FloatValue);
                entity.stateInterVar.StateInterCommands.Commands.Add(new KeyValuePair <short, float>((short)FsmOutputType.CharacterControllerRadius, output.FloatValue));
            };

            //FirstPersonHeight
            _FsmOutputAction[(short)FsmOutputType.FirstPersonHeight].ServerAction = (entity, output) =>
            {
                entity.appearanceInterface.FirstPersonAppearance.SetFirstPersonHeight(output.FloatValue);
            };

            _FsmOutputAction[(short)FsmOutputType.FirstPersonHeight].ClientAction = (entity, output) =>
            {
                entity.appearanceInterface.FirstPersonAppearance.SetFirstPersonHeight(output.FloatValue);
                entity.stateInterVar.StateInterCommands.Commands.Add(new KeyValuePair <short, float>((short)FsmOutputType.FirstPersonHeight, output.FloatValue));
            };

            //FirstPersonForwardOffset
            _FsmOutputAction[(short)FsmOutputType.FirstPersonForwardOffset].ServerAction = (entity, output) =>
            {
                entity.appearanceInterface.FirstPersonAppearance.SetFirstPersonForwardOffset(output.FloatValue);
            };

            _FsmOutputAction[(short)FsmOutputType.FirstPersonForwardOffset].ClientAction = (entity, output) =>
            {
                entity.appearanceInterface.FirstPersonAppearance.SetFirstPersonForwardOffset(output.FloatValue);
                entity.stateInterVar.StateInterCommands.Commands.Add(new KeyValuePair <short, float>((short)FsmOutputType.FirstPersonForwardOffset, output.FloatValue));
            };

            // Peek
            _FsmOutputAction[(short)FsmOutputType.Peek].ServerAction = (entity, output) =>
            {
                IBoneRigging boneRigging = entity.characterBoneInterface.CharacterBone;
                output.Valid = false;
                boneRigging.Peek(output.FloatValue);
            };

            _FsmOutputAction[(short)FsmOutputType.Peek].ClientAction = (entity, output) =>
            {
                IBoneRigging boneRigging = entity.characterBoneInterface.CharacterBone;
                output.Valid = false;
                boneRigging.Peek(output.FloatValue);
                entity.stateInterVar.StateInterCommands.Commands.Add(new KeyValuePair <short, float>((short)FsmOutputType.Peek, output.FloatValue));
            };

            //FirstPersonSight
            _FsmOutputAction[(short)FsmOutputType.FirstPersonSight].ServerAction = (entity, output) =>
            {
                IBoneRigging boneRigging = entity.characterBoneInterface.CharacterBone;
                output.Valid = false;
                boneRigging.SightProgress(output.FloatValue);
            };

            _FsmOutputAction[(short)FsmOutputType.FirstPersonSight].ClientAction = (entity, output) =>
            {
                IBoneRigging boneRigging = entity.characterBoneInterface.CharacterBone;
                output.Valid = false;
                boneRigging.SightProgress(output.FloatValue);
                entity.stateInterVar.StateInterCommands.Commands.Add(new KeyValuePair <short, float>((short)FsmOutputType.FirstPersonSight, output.FloatValue));
            };

            //InterruptAction
            _FsmOutputAction[(short)FsmOutputType.InterruptAction].ServerAction = empty;
            _FsmOutputAction[(short)FsmOutputType.InterruptAction].ClientAction = (entity, output) =>
            {
                entity.stateInterface.State.AddInterruptInput((FsmInput)output.FloatValue);
            };

            _FsmOutputAction[(short)FsmOutputType.RebindAnimator].ServerAction = (entity, output) =>
            {
                if (entity.hasThirdPersonAnimator)
                {
                    entity.thirdPersonAnimator.UnityAnimator.Rebind();
                    Logger.InfoFormat("ThirdPerson   AnimatorRebind");
                }

                if (entity.hasFirstPersonAnimator)
                {
                    entity.firstPersonAnimator.UnityAnimator.Rebind();
                    Logger.InfoFormat("FirstPerson   AnimatorRebind");
                }
            };
            _FsmOutputAction[(short)FsmOutputType.RebindAnimator].ClientAction = (entity, output) =>
            {
                if (entity.hasThirdPersonAnimator)
                {
                    entity.thirdPersonAnimator.UnityAnimator.Rebind();
                    Logger.InfoFormat("ThirdPerson   AnimatorRebind");
                }

                if (entity.hasFirstPersonAnimator)
                {
                    entity.firstPersonAnimator.UnityAnimator.Rebind();
                    Logger.InfoFormat("FirstPerson   AnimatorRebind");
                }
            };

            _FsmOutputAction[(short)FsmOutputType.LayerWeight].ServerAction     =
                _FsmOutputAction[(short)FsmOutputType.LayerWeight].ClientAction =
                    SetLayerWeightOut;

            _FsmOutputAction[(short)FsmOutputType.Bool].ServerAction     =
                _FsmOutputAction[(short)FsmOutputType.Bool].ClientAction =
                    SetCommonOut;

            _FsmOutputAction[(short)FsmOutputType.Float].ServerAction     =
                _FsmOutputAction[(short)FsmOutputType.Float].ClientAction =
                    SetCommonOut;

            _FsmOutputAction[(short)FsmOutputType.Int].ServerAction     =
                _FsmOutputAction[(short)FsmOutputType.Int].ClientAction =
                    SetCommonOut;
        }