Example #1
0
        public override void Activate()
        {
            var data   = Engine.Story.Data;
            var oldVar = data.GetVariable(Name);
            var eval   = ExpressionHandler.EvaluateNumeric(Expression, data);

            switch (Operation)
            {
            case VariableAction.Set:
                data.SetVariable(Name, eval);
                break;

            case VariableAction.Add:
                data.SetVariable(Name, oldVar + eval);
                break;

            case VariableAction.Subtract:
                data.SetVariable(Name, oldVar - eval);
                break;

            case VariableAction.Multiply:
                data.SetVariable(Name, oldVar * eval);
                break;

            case VariableAction.Divide:
                data.SetVariable(Name, oldVar / eval);
                break;

            case VariableAction.Modulus:
                data.SetVariable(Name, oldVar % eval);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }