Пример #1
0
        public static void Tests_GlobalFunctions()
        {
            var module_ = ScriptEngine.GetModule("test", asEGMFlags.asGM_ALWAYS_CREATE);

            module_.AddScriptSection("GlobalFunctions", @"
int One()
{
    return 1;
}
bool SomeTest(int i)
{
    return i % 2 == 0;
}
float Square(float x)
{
    return x * x;
}
int RefFunc(string& s)
{
    return s.length();
}
int HandleFunc(string@ s)
{
    return s.length();
}
shared interface IFoo
{
    int get_Prop();
}
class CFoo : IFoo
{
    CFoo(int i) { this.i = i; }
    int i;
    int get_Prop() { return i; }
}
IFoo@ GetAsInterface(int i) { return CFoo(i); }
CFoo@ GetNull() { return null; }
");
            module_.Build();

            dynamic module = module_ as dynamic;

            assert(module.One() == 1, "Calling parameterless function");
            assert(module.SomeTest(2), "Calling func returning true");
            assert(!module.SomeTest(3), "Calling func returning false");
            assert(module.Square(1.2f) == 1.44f, "Calling float function");

            var s = new ScriptString("hello");

            assert(module.RefFunc(s) == 5, "Calling byref function");
            assert(module.HandleFunc(s) == 5, "Calling handle function");

            assert(module.GetAsInterface(2) != null, "Calling function returning script object");
            assert(module.GetNull() == null, "Caling null returning function");
        }
Пример #2
0
        public virtual void PlaySound(string sound_name, ushort hx, ushort hy, uint radius)
        {
            var ss = new ScriptString(sound_name);

            Map_PlaySoundRadius(thisptr, ss.ThisPtr, hx, hy, radius);
        }
Пример #3
0
        public virtual void PlaySound(string sound_name)
        {
            var ss = new ScriptString(sound_name);

            Map_PlaySound(thisptr, ss.ThisPtr);
        }
Пример #4
0
        public virtual void SetTextMsgLex(ushort hx, ushort hy, uint color, ushort text_msg, uint str_num, string lexems)
        {
            var ss = new ScriptString(lexems);

            Map_SetTextMsgLex(thisptr, hx, hy, color, text_msg, str_num, ss.ThisPtr);
        }
Пример #5
0
        public virtual bool SetScript(string script)
        {
            var ss = new ScriptString(script);

            return(Map_SetScript(thisptr, ss.ThisPtr));
        }
Пример #6
0
        public virtual void SetText(ushort hx, ushort hy, uint color, string text)
        {
            var ss = new ScriptString(text);

            Map_SetText(thisptr, hx, hy, color, ss.ThisPtr);
        }
Пример #7
0
        public bool Get(string name, UIntArray data)
        {
            var ss = new ScriptString(name);

            return(Global_GetAnyData(ss.ThisPtr, data.ThisPtr));
        }
Пример #8
0
        public void Erase(string name)
        {
            var ss = new ScriptString(name);

            Global_EraseAnyData(ss.ThisPtr);
        }
Пример #9
0
        public void RadioMessageMsg(ushort channel, ushort text_msg, uint str_num, string lexems)
        {
            var ss = new ScriptString(lexems);

            Global_RadioMessageMsgLex(channel, text_msg, str_num, ss.ThisPtr);
        }
Пример #10
0
        public bool IsAnyData(string name)
        {
            var ss = new ScriptString(name);

            return(Global_IsAnyData(ss.ThisPtr));
        }
Пример #11
0
        public void RadioMessage(ushort channel, string text)
        {
            var ss = new ScriptString(text);

            Global_RadioMessage(channel, ss.ThisPtr);
        }
Пример #12
0
        public void Log(string s, params object[] args)
        {
            var ss = new ScriptString(string.Format(s + Environment.NewLine, args));

            Global_Log(ss.ThisPtr);
        }
Пример #13
0
        public void Log(string s)
        {
            var ss = new ScriptString(s + Environment.NewLine);

            Global_Log(ss.ThisPtr);
        }
Пример #14
0
        public virtual void SetLexems(string lexems)
        {
            var ss = new ScriptString(lexems);

            Item_SetLexems(thisptr, ss.ThisPtr);
        }
Пример #15
0
        public bool Set(string name, int[] data)
        {
            var ss = new ScriptString(name);

            return(Global_SetAnyData(ss.ThisPtr, new IntArray(data).ThisPtr));
        }
Пример #16
0
        public virtual bool Misc_SetScript(string func_name)
        {
            var ss = new ScriptString(func_name);

            return(NpcPlane_Misc_SetScript(thisptr, ss.ThisPtr));
        }
Пример #17
0
        public static void asAssert(bool cond, IntPtr msg)
        {
            var ss = new ScriptString(msg);

            Assert(cond, ss.ToString());
        }