コード例 #1
0
        public override IWorkshopTree Get(ActionSet actionSet, IWorkshopTree[] parameterValues, object[] additionalParameterData)
        {
            VariableElements elements = ((VariableResolve)additionalParameterData[0]).ParseElements(actionSet);
            WorkshopVariable variable = elements.IndexReference.WorkshopVariable;

            Element       destination  = (Element)parameterValues[1];
            Element       duration     = (Element)parameterValues[2];
            IWorkshopTree reevaluation = parameterValues[3];

            if (variable.IsGlobal)
            {
                actionSet.AddAction(Element.Part <A_ChaseGlobalVariableOverTime>(
                                        variable,
                                        destination,
                                        duration,
                                        reevaluation
                                        ));
            }
            else
            {
                actionSet.AddAction(Element.Part <A_ChasePlayerVariableOverTime>(
                                        elements.Target,
                                        variable,
                                        destination,
                                        duration,
                                        reevaluation
                                        ));
            }

            return(null);
        }
コード例 #2
0
        public static FuncMethod StopChasingVariable(DeltinScript deltinScript) => new FuncMethodBuilder()
        {
            Name          = "StopChasingVariable",
            Documentation = "Stops an in-progress chase of a variable, leaving it at its current value.",
            Parameters    = new CodeParameter[] {
                new VariableParameter("variable", "The variable to stop. Must be a variable defined on the rule level.", VariableType.Dynamic, deltinScript.Types.Any(), new VariableResolveOptions()
                {
                    CanBeIndexed = false, FullVariable = true
                })
            },
            Action = (actionSet, methodCall) => {
                VariableElements elements = ((VariableResolve)methodCall.AdditionalParameterData[0]).ParseElements(actionSet);
                WorkshopVariable variable = ((IndexReference)elements.IndexReference).WorkshopVariable;

                if (variable.IsGlobal)
                {
                    actionSet.AddAction(Element.Part("Stop Chasing Global Variable", variable));
                }
                else
                {
                    actionSet.AddAction(Element.Part("Stop Chasing Player Variable", elements.Target, variable));
                }

                return(null);
            }
        };
 public AssignmentOperationInfo(string comment, ActionSet actionSet, VariableElements variableInfo, IWorkshopTree value)
 {
     _comment  = comment;
     ActionSet = actionSet;
     Value     = value;
     _elements = variableInfo;
 }
コード例 #4
0
        public override IWorkshopTree Get(ActionSet actionSet, IWorkshopTree[] parameterValues, object[] additionalParameterData)
        {
            VariableResolve variableResolve = (VariableResolve)additionalParameterData[0];
            Operation       operation       = (Operation)((EnumMember)parameterValues[1]).Value;
            Element         value           = (Element)parameterValues[2];

            VariableElements variableElements = variableResolve.ParseElements(actionSet);

            actionSet.AddAction(variableElements.IndexReference.ModifyVariable(
                                    operation, value, variableElements.Target, variableElements.Index
                                    ));
            return(null);
        }
コード例 #5
0
        public override IWorkshopTree Get(ActionSet actionSet, IWorkshopTree[] parameterValues, object[] additionalParameterData)
        {
            VariableElements elements = ((VariableResolve)additionalParameterData[0]).ParseElements(actionSet);
            WorkshopVariable variable = elements.IndexReference.WorkshopVariable;

            if (variable.IsGlobal)
            {
                actionSet.AddAction(Element.Part <A_StopChasingGlobalVariable>(variable));
            }
            else
            {
                actionSet.AddAction(Element.Part <A_StopChasingPlayerVariable>(elements.Target, variable));
            }

            return(null);
        }
コード例 #6
0
        public static FuncMethod ChaseVariableAtRate(DeltinScript deltinScript) => new FuncMethodBuilder()
        {
            Name          = "ChaseVariableAtRate",
            Documentation = "Gradually modifies the value of a variable at a specific rate.",
            Parameters    = new CodeParameter[] {
                new VariableParameter("variable", "The variable to manipulate. Player variables will chase the event player's variable. Must be a variable defined on the rule level.", VariableType.Dynamic, deltinScript.Types.Any(), new VariableResolveOptions()
                {
                    CanBeIndexed = false, FullVariable = true
                }),
                new CodeParameter("destination", "The value that the variable will eventually reach. The type of this value may be either a number or a vector, through the variable’s existing value must be of the same type before the chase begins. Can use number or vector based values.", NumberOrVector(deltinScript)),
                new CodeParameter("rate", "The amount of change that will happen to the variable’s value each second.", deltinScript.Types.Number()),
                new CodeParameter("reevaluation", "Specifies which of this action's inputs will be continuously reevaluated. This action will keep asking for and using new values from reevaluated inputs.", deltinScript.Types.EnumType("RateChaseReevaluation"))
            },
            Action = (actionSet, methodCall) => {
                VariableElements elements = ((VariableResolve)methodCall.AdditionalParameterData[0]).ParseElements(actionSet);
                WorkshopVariable variable = ((IndexReference)elements.IndexReference).WorkshopVariable;

                Element       destination  = methodCall.Get(1);
                Element       rate         = methodCall.Get(2);
                IWorkshopTree reevaluation = methodCall.ParameterValues[3];

                if (variable.IsGlobal)
                {
                    actionSet.AddAction(Element.Part("Chase Global Variable At Rate",
                                                     variable,
                                                     destination,
                                                     rate,
                                                     reevaluation
                                                     ));
                }
                else
                {
                    actionSet.AddAction(Element.Part("Chase Player Variable At Rate",
                                                     elements.Target,
                                                     variable,
                                                     destination,
                                                     rate,
                                                     reevaluation
                                                     ));
                }

                return(null);
            }
        };
コード例 #7
0
        public static FuncMethod ModifyVariable(DeltinScript deltinScript) => new FuncMethodBuilder()
        {
            Name          = "ModifyVariable",
            Documentation = "Modifies the value of a variable.",
            Parameters    = new CodeParameter[] {
                new VariableParameter("variable", "The variable to modify. Player variables will modify the event player's variable.", deltinScript.Types.Any()),
                new CodeParameter("operation", "The way in which the variable’s value will be changed. Options include standard arithmetic operations as well as array operations for appending and removing values.", deltinScript.Types.EnumType("Operation")),
                new CodeParameter("value", "The value used for the modification. For arithmetic operations, this is the second of two operands, with the other being the variable’s existing value. For array operations, this is the value to append or remove.", deltinScript.Types.Any())
            },
            Action = (actionSet, methodCall) => {
                VariableResolve variableResolve = (VariableResolve)methodCall.AdditionalParameterData[0];
                Operation       operation       = ((ElementEnumMember)methodCall.ParameterValues[1]).GetOperation();
                IWorkshopTree   value           = methodCall.ParameterValues[2];

                VariableElements variableElements = variableResolve.ParseElements(actionSet);

                variableElements.IndexReference.Modify(actionSet, operation, value, variableElements.Target, variableElements.Index);
                return(null);
            }
        };