示例#1
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalVariable activatorVariable = codeScope.GetVariableWithMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR);

            if (activatorVariable == null)
            {
                throw new ConversionException("getActionRef in non-activator scope found. Cannot convert that one.", expected: true);
            }
            return(TES5ReferenceFactory.CreateReferenceToVariable(activatorVariable));
        }
示例#2
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            //TODO: This function is nonexistent in Papyrus and most likely should be deleted
            TES5LocalVariable containerVariable = codeScope.GetVariableWithMeaning(TES5LocalVariableParameterMeaning.CONTAINER);

            if (containerVariable == null)
            {
                throw new ConversionException("GetContainer:  Cannot convert to Skyrim in other contexts than onEquip/onUnequip", expected: true);
            }
            return(TES5ReferenceFactory.CreateReferenceToVariable(containerVariable));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope        localScope        = codeScope.LocalScope;
            TES4FunctionArguments functionArguments = function.Arguments;
            TES5LocalVariable     activatorVariable = codeScope.GetVariableWithMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR);

            if (activatorVariable == null)
            {
                throw new ConversionException("isActionRef called in a context where action ref should not be present");
            }

            string dataString = functionArguments[0].StringValue;
            TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(TES5ReferenceFactory.CreateReferenceToVariable(activatorVariable), TES5ComparisonExpressionOperator.OPERATOR_EQUAL, this.referenceFactory.CreateReadReference(dataString, globalScope, multipleScriptsScope, localScope));

            return(expression);
        }
示例#4
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            string functionName = function.FunctionCall.FunctionName;
            TES4FunctionArguments functionArguments = function.Arguments;

            if (functionArguments == null || !functionArguments.Any())
            {
                TES5ObjectCallArguments constantArgumentForNoFunctionArguments = new TES5ObjectCallArguments();
                TES5LocalVariable       meaningVariable = codeScope.GetVariableWithMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR);
                if (meaningVariable != null)
                {
                    constantArgumentForNoFunctionArguments.Add(TES5ReferenceFactory.CreateReferenceToVariable(meaningVariable));
                }
                else
                {
                    constantArgumentForNoFunctionArguments.Add(TES5ReferenceFactory.CreateReferenceToPlayer());
                }

                constantArgumentForNoFunctionArguments.Add(new TES5Bool(true)); //Since default in oblivion is ,,skip the OnActivateBlock", this defaults to ,,abDefaultProcessingOnly = true" in Skyrim
                return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, multipleScriptsScope, constantArgumentForNoFunctionArguments));
            }

            TES5ObjectCallArguments constantArgument = new TES5ObjectCallArguments()
            {
                this.valueFactory.CreateValue(functionArguments[0], codeScope, globalScope, multipleScriptsScope)
            };
            ITES4StringValue blockOnActivate = functionArguments.GetOrNull(1);

            if (blockOnActivate != null)
            {
                bool blockOnActivateVal = (int)blockOnActivate.Data == 1;
                constantArgument.Add(new TES5Bool(!blockOnActivateVal));
            }

            return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, multipleScriptsScope, constantArgument));
        }