// Input Button
        private static EventCondition <GameEntityModel> .EvaluationDelegate BuildInputButton(Storage.GenericParameter parameter, out int keyFrame, Storage.CharacterAnimation animation)
        {
            keyFrame = InvalidKeyframe;
            // Read button, state, negation
            uint        buttonId      = (uint)parameter.SafeInt(1);
            ButtonState buttonState   = (ButtonState)parameter.SafeInt(2);
            bool        positiveCheck = !parameter.SafeBool(0);

            // Return delegate
            return(delegate(GameEntityModel mainModel, List <GameEntityModel>[] subjectModels){
                PlayerInputModel inputModel = StateManager.state.GetModel(mainModel.inputModelId) as PlayerInputModel;
                if (inputModel == null)
                {
                    return false;
                }
                PlayerInputController inputController = inputModel.Controller() as PlayerInputController;
                if (inputController == null)
                {
                    return false;
                }
                bool verifies = false;
                // verify model's button state
                switch (buttonState)
                {
                case ButtonState.hold:          verifies = inputController.IsButtonHold(inputModel, buttonId);          break;

                case ButtonState.press:         verifies = inputController.IsButtonPressed(inputModel, buttonId);       break;

                case ButtonState.release:       verifies = inputController.IsButtonReleased(inputModel, buttonId);      break;
                }
                return verifies == positiveCheck;
            });
        }
Beispiel #2
0
        private static EventAction <GameEntityModel> .ExecutionDelegate BuildConsumeInput(Storage.GenericParameter parameter)
        {
            uint buttonId       = (uint)parameter.SafeInt(1);
            bool consumeRelease = parameter.SafeBool(0);

            return(delegate(GameEntityModel mainModel, List <GameEntityModel>[] subjectModels){
                PlayerInputModel inputModel = StateManager.state.GetModel(mainModel.inputModelId) as PlayerInputModel;
                if (inputModel == null)
                {
                    return;
                }
                PlayerInputController inputController = inputModel.Controller() as PlayerInputController;
                if (inputController == null)
                {
                    return;
                }
                if (consumeRelease)
                {
                    inputController.ConsumeRelease(inputModel, buttonId);
                }
                else
                {
                    inputController.ConsumePress(inputModel, buttonId);
                }
            });
        }
        // Input Velocity
        private static EventCondition <GameEntityModel> .EvaluationDelegate BuildInputVelocity(Storage.GenericParameter parameter, out int keyFrame, Storage.CharacterAnimation animation)
        {
            keyFrame = InvalidKeyframe;
            // Read orientation, operator, numerator subject, numerator var, number, module
            Orientation orientation = (Orientation)parameter.SafeInt(1);

            ConditionUtils <GameEntityModel> .ComparisonOperation comparisonOperator = (ConditionUtils <GameEntityModel> .ComparisonOperation)parameter.SafeInt(2);
            int        numeratorSubjectId      = parameter.SafeInt(3);
            string     numeratorSubjectVarName = parameter.SafeString(0);
            FixedFloat staticComparisonValue   = parameter.SafeFloat(0);
            bool       useModule = parameter.SafeBool(1);

            // return delegate
            return(delegate(GameEntityModel mainModel, List <GameEntityModel>[] subjectModels){
                PlayerInputModel inputModel = StateManager.state.GetModel(mainModel.inputModelId) as PlayerInputModel;
                if (inputModel == null)
                {
                    return false;
                }
                FixedFloat inputAxisValue = getOrientedAxisValue(inputModel.axis, orientation, useModule);
                return CompareWithNumerator(mainModel, numeratorSubjectId, numeratorSubjectVarName, inputAxisValue, staticComparisonValue, comparisonOperator, subjectModels);
            });
        }