// Velocity
        private static EventCondition <GameEntityModel> .EvaluationDelegate BuildVelocity(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){
                PhysicPointModel pointModel = StateManager.state.GetModel(mainModel.physicsModelId) as PhysicPointModel;
                if (pointModel == null)
                {
                    return false;
                }
                FixedFloat velocityValue = getOrientedAxisValue(pointModel.GetVelocity(), orientation, useModule);
                return CompareWithNumerator(mainModel, numeratorSubjectId, numeratorSubjectVarName, velocityValue, staticComparisonValue, comparisonOperator, subjectModels);
            });
        }
Пример #2
0
        private static EventAction <GameEntityModel> .ExecutionDelegate BuildSetVelocity(Storage.GenericParameter parameter)
        {
            int          mask     = parameter.SafeInt(1);
            FixedVector3 velocity = BuildFixedVector3(parameter, 0);
            bool         hasX     = mask == 0 || mask == 3 || mask == 4 || mask == 6;
            bool         hasY     = mask == 1 || mask == 3 || mask == 5 || mask == 6;
            bool         hasZ     = mask == 2 || mask == 4 || mask == 5 || mask == 6;

            return(delegate(GameEntityModel model, List <GameEntityModel>[] subjectModels){
                PhysicPointModel pointModel = StateManager.state.GetModel(model.physicsModelId) as PhysicPointModel;
                if (pointModel == null)
                {
                    return;
                }
                FixedVector3 originalVelocity = pointModel.GetVelocity();
                FixedVector3 finalVelocity = new FixedVector3(
                    hasX ? velocity.X : originalVelocity.X,
                    hasY ? velocity.Y : originalVelocity.Y,
                    hasZ ? velocity.Z : originalVelocity.Z
                    );
                pointModel.velocityAffectors[GameEntityController.animVelocityAffector] = finalVelocity;
            });
        }