Beispiel #1
0
 internal static void Initialize(string[] args = null)
 {
     if (args != null)
     {
         for (int i = 0; i < args.Length; i++)
         {
             if (args[i] == "--mod" && Directory.Exists(Path.Combine(Application.StartupPath, "mods", args[i + 1])))
             {
                 ModName = args[i + 1];
             }
             if (args[i] == "--visisble3d") //this opens a form and renders the gameplay in realtime(will certainly make it slower, well, unsure. Since otherwise it would be rendered in memory)
             {
                 new FrmMain().Show();      //requires client zips
             }
         }
     }
     EventRegistry = new GameEventRegistry();
     BF2Engine     = new BF2Engine();
     if (string.IsNullOrEmpty(ModName))
     {
         Console.WriteLine("No mod was defined, which mod would you like to load?");
         var directories = Directory.EnumerateDirectories(Path.Combine(Application.StartupPath, "mods")).Select(d => new DirectoryInfo(d).Name);
         for (int i = 0; i < directories.Count(); i++)
         {
             Console.WriteLine("[" + i + "] " + directories.ToArray()[i]);
         }
         Console.Write(">");
         var mod = Console.ReadLine();
         if (!directories.Contains(mod))
         {
             Console.WriteLine("Invalid mod! Press any key to exit...");
             Console.ReadKey();
             Environment.Exit(-1);
         }
         ModName          = "mods/" + mod;
         ModAssembly      = Assembly.Load(File.ReadAllBytes(Path.Combine(Application.StartupPath, ModName, "phoenixmod.dll")));
         ModPath          = Path.Combine(Application.StartupPath, ModName);
         LoadedMod        = (IMod)Activator.CreateInstance(ModAssembly.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IMod))).First());
         ConFileProcessor = LoadedMod.GetConFileProcessor();
     }
     LoadedMod.Initialize(BF2Engine, EventRegistry);
     Console.WriteLine("Loaded " + LoadedMod.Name);
     BF2Engine.InitEngine();
     BF2Engine.LoadServerArchives();
 }
        //This is called once each time the task is enabled.
        //Call EndAction() to mark the action as finished, either in success or failure.
        //EndAction can be called from anywhere.
        protected override void OnExecute()
        {
            gameMode.value = GameEventRegistry.GetGameMode();

            EndAction(true);
        }
 //Called once per frame while the condition is active.
 //Return whether the condition is success or failure.
 protected override bool OnCheck()
 {
     Debug.Log("AARON: Game mode: " + GameEventRegistry.GetGameMode() + "==" + gameMode.value);
     return(gameMode.value == GameEventRegistry.GetGameMode());
 }