예제 #1
0
        void TestScript_Notified(string arg1, Parameter[] arg2)
        {
            if (arg1 == "trigger" || arg1 == "weapon_fired" || arg1 == "touch")
            {
                return;
            }

            GameInterface.Script_PushString(arg1);
            GameInterface.Script_Call(363, 0, 1);
        }
예제 #2
0
        private static void CallRaw(string identifier, params Parameter[] parameters)
        {
            // push arguments
            foreach (var parameter in parameters.Reverse())
            {
                parameter.PushValue();
            }

            // call the function
            if (!GameInterface.Script_Call(identifier.ToLowerInvariant(), _entRef, parameters.Length))
            {
                SetEntRef(-1);
                throw new ScriptException("Could not find function " + identifier);
            }

            // reset the entref to 0
            SetEntRef(-1);

            // check for return values
            _returnValue = null;

            if (GameInterface.Notify_NumArgs() == 1)
            {
                switch (GameInterface.Script_GetType(0))
                {
                case VariableType.Entity:
                    _returnValue = Entity.GetEntity(GameInterface.Script_GetEntRef(0));
                    break;

                case VariableType.Integer:
                    _returnValue = GameInterface.Script_GetInt(0);
                    break;

                case VariableType.Float:
                    _returnValue = GameInterface.Script_GetFloat(0);
                    break;

                case VariableType.String:
                    _returnValue = GameInterface.Script_GetString(0);
                    break;

                case VariableType.Vector:
                    Vector3 outValue;
                    GameInterface.Script_GetVector(0, out outValue);
                    _returnValue = outValue;
                    break;
                }
            }

            GameInterface.Script_CleanReturnStack();
        }