Exemplo n.º 1
0
        public static void Run()
        {
            var module_ = AngelScript.ScriptEngine.GetModule("test", AngelScript.asEGMFlags.asGM_ALWAYS_CREATE);

            ScriptEngine.CallPragmas(new string[]
            {
                "bindfunc",
                "void assert(bool, string@+) -> mono FOnline.Tests::asAssert",
                "bindfunc",
                "int mul(int x, int y) -> mono FOnline.BindFuncTests::Mul",
                "bindfunc",
                "int string::GetPointer() -> mono FOnline.BindFuncTests::GetPointer"
            });
            module_.AddScriptSection("test", @"
void Run()
{
    assert(mul(2,3)==6, ""Static bindfunc"");
    string s(""hi"");
    assert(s.GetPointer() > 0, ""Nonstatic bindfunc"");
}
");
            module_.Build();
            var module = module_ as dynamic;

            module.Run();
            Global.Log("eee");
        }
Exemplo n.º 2
0
        public static bool AddAttackPlane(this Critter npc, uint priority, Critter target)
        {
            if (npc.IsPlayer)
            {
                Map  map = npc.GetMap();
                uint loc = 0;
                if (map != null)
                {
                    loc = map.GetLocation().GetProtoId();
                }
                Global.Log("ERR: adding attack plane to player, loc pid={0}", loc);
            }
            NpcPlane plane = Global.CreatePlane();

            plane.Type            = PlaneType.Attack;
            plane.Priority        = (priority == 0?Priorities.Attack:priority);
            plane.Attack_TargId   = target.Id;
            plane.Attack_MinHp    = Global.DeadHitPoints;
            plane.Attack_IsGag    = false;
            plane.Attack_GagHexX  = 0;
            plane.Attack_GagHexY  = 0;
            plane.Attack_LastHexX = target.HexX;
            plane.Attack_LastHexY = target.HexY;
            plane.Run             = false;
            return(npc.AddPlane(plane));
        }
Exemplo n.º 3
0
        static void Init(object sender, EventArgs e)
        {
            Global.Log("Init from mono!");

            //Tests.InitRun ();

            Global.Log("Done with tests.");
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     main.Init += Init;
     if (args.Contains("-mono_repl"))
     {
         main.Init += (o, e) => StartREPL();
     }
     main.Start += (o, e) =>
     {
         //Tests.StartRun();
         Global.Log("Start from mono!");
     };
 }
Exemplo n.º 5
0
 public static void Assert(bool cond, string msg)
 {
     total++;
     if (cond)
     {
         counter++;
         Global.Log("{0} passed.", msg);
     }
     else
     {
         Global.Log("{0} failed.", msg);
     }
 }
Exemplo n.º 6
0
        public static bool AddMiscPlane(this Critter npc, uint priority, uint waitSecond, string funcName)
        {
            NpcPlane plane = Global.CreatePlane();

            plane.Type            = PlaneType.Misc;
            plane.Priority        = priority == 0 ? Priorities.Misc : priority;
            plane.Misc_WaitSecond = waitSecond;
            if (funcName != null && !plane.Misc_SetScript(funcName))
            {
                Global.Log("Set script <{0}> fail", funcName);
                return(false);
            }
            return(npc.AddPlane(plane));
        }
Exemplo n.º 7
0
        public static void StartRun()
        {
            Global.Log("Running tests...");
            //counter = total = 0;

            try
            {
                MemoryTests.Run();
            }
            finally
            {
                Global.Log("{0} succeeded out of {1}.", counter, total);
            }
        }
Exemplo n.º 8
0
        public static void InitRun()
        {
            Global.Log("Running tests...");
            counter = total = 0;

            try
            {
                AngelScriptTests.Run();
                BindFuncTests.Run();
                ArrayTests.Run();
            }
            finally
            {
                Global.Log("{0} succeeded out of {1}.", counter, total);
            }
        }
Exemplo n.º 9
0
        public static bool AddAttackPlane(this Critter npc, uint priority, uint critId)
        {
            Critter target = Global.GetCritter(critId);

            if (target == null)
            {
                Global.Log("Target not found.");
                return(false);
            }

            NpcPlane plane = Global.CreatePlane();

            plane.Type            = PlaneType.Attack;
            plane.Priority        = (priority == 0?Priorities.Attack:priority);
            plane.Attack_TargId   = target.Id;
            plane.Attack_MinHp    = Global.DeadHitPoints;
            plane.Attack_IsGag    = false;
            plane.Attack_GagHexX  = 0;
            plane.Attack_GagHexY  = 0;
            plane.Attack_LastHexX = target.HexX;
            plane.Attack_LastHexY = target.HexY;
            plane.Run             = false;
            return(npc.AddPlane(plane));
        }
Exemplo n.º 10
0
 public SceneryArray()
     : base(type)
 {
     Global.Log("Creating SceneryArray({0})", type);
 }