Example #1
0
        private static void CMInvoke()
        {
            PvPBattle.Bind();
            BattleNotoriety.Enable();

            var scenarios = new List <PvPScenario>();

            foreach (var type in BattleTypes.Where(t => t != null))
            {
                VitaNexCore.TryCatch(
                    () =>
                {
                    var battle = type.CreateInstanceSafe <PvPBattle>();

                    if (battle == null)
                    {
                        throw new Exception("PvPBattle Type could not be constructed, requires a constructor with 0 arguments.");
                    }

                    PvPScenario scenario = battle;
                    scenarios.Add(scenario);
                    battle.Delete();

                    CMOptions.ToConsole("Created scenario ({0}) '{1}'", scenario.TypeOf.Name, scenario.Name);
                },
                    CMOptions.ToConsole);
            }

            Scenarios = scenarios.ToArray();
            scenarios.Clear();

            foreach (var battle in Battles.Values.Where(b => b != null && !b.Deleted).ToArray())
            {
                VitaNexCore.TryCatch(
                    battle.Init,
                    ex =>
                {
                    VitaNexCore.TryCatch(battle.Delete);

                    CMOptions.ToConsole("Failed to initialize battle #{0} '{1}'", battle.Serial, battle.Name);
                    CMOptions.ToConsole(ex);
                });
            }

            foreach (var profile in Profiles.Values.Where(p => p != null && !p.Deleted).ToArray())
            {
                VitaNexCore.TryCatch(
                    profile.Init,
                    ex =>
                {
                    VitaNexCore.TryCatch(profile.Delete);

                    CMOptions.ToConsole("Failed to initialize profile #{0} '{1}'", profile.Owner.Serial.Value, profile.Owner.RawName);
                    CMOptions.ToConsole(ex);
                });
            }
        }
Example #2
0
 private static void CMEnabled()
 {
     PvPBattle.Bind();
     BattleNotoriety.Enable();
 }