public BehaviorDb(RealmManager manager) { log.Info("Initializing Behavior Database..."); Manager = manager; Definitions = new Dictionary<ushort, Tuple<State, Loot>>(); if (Interlocked.Exchange(ref initializing, 1) == 1) { log.Error("Attempted to initialize multiple BehaviorDb at the same time."); throw new InvalidOperationException("Attempted to initialize multiple BehaviorDb at the same time."); } InitDb = this; FieldInfo[] fields = GetType() .GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .Where(field => field.FieldType == typeof (_)) .ToArray(); for (int i = 0; i < fields.Length; i++) { FieldInfo field = fields[i]; log.InfoFormat("Loading behavior for '{0}'({1}/{2})...", field.Name, i + 1, fields.Length); ((_) field.GetValue(this))(); field.SetValue(this, null); } InitDb = null; initializing = 0; log.Info("Behavior Database initialized..."); }
//public List<Player> GuildMembersOf(string guild) //{ // return (from i in Worlds where i.Key != 0 from e in i.Value.Players where String.Equals(e.Value.Guild, guild, StringComparison.CurrentCultureIgnoreCase) select e.Value).ToList(); //} public void Initialize() { log.Info("Initializing Realm Manager..."); GameData = new XmlData(); Behaviors = new BehaviorDb(this); GeneratorCache.Init(); MerchantLists.InitMerchatLists(GameData); AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus()); AddWorld(World.MARKET, new ClothBazaar()); AddWorld(World.TEST_ID, new Test()); AddWorld(World.TUT_ID, new Tutorial(true)); AddWorld(World.DAILY_QUEST_ID, new DailyQuestRoom()); Monitor = new RealmPortalMonitor(this); Task.Factory.StartNew(() => GameWorld.AutoName(1, true)).ContinueWith(_ => AddWorld(_.Result), TaskScheduler.Default); Chat = new ChatManager(this); Commands = new CommandManager(this); log.Info("Realm Manager initialized."); }
public void Initialize() { log.Info("Initializing Realm Manager..."); GameData = new XmlData(); Behaviors = new BehaviorDb(this); MerchantLists.InitMerchantLists(GameData); AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus()); Monitor = new RealmPortalMonitor(this); AddWorld(World.TUT_ID, new Tutorial(true)); AddWorld(World.NEXUS_LIMBO, new NexusLimbo()); AddWorld(World.VAULT_ID, new Vault(true)); AddWorld(World.TEST_ID, new Test()); AddWorld(World.RAND_REALM, new RandomRealm()); AddWorld(World.PVP, new PVPArena()); AddWorld(World.SHOP_ID, new Shop()); if (Program.Settings.GetValue<bool>("hasRealm")) AddWorld(GameWorld.AutoName(1, true)); Chat = new ChatManager(this); Commands = new CommandManager(); UnusualEffects.Init(); log.Info("Realm Manager initialized."); }