private static void Main() { Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); Console.Title = Title; log.Info("Initialising..."); ConfigurationManager <WorldServerConfiguration> .Initialise("WorldServer.json"); DatabaseManager.Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Database); GameTableManager.Initialise(); MapManager.Initialise(); SearchManager.Initialise(); EntityManager.Initialise(); EntityCommandManager.Initialise(); GlobalMovementManager.Initialise(); AssetManager.Initialise(); GlobalSpellManager.Initialise(); ServerManager.Initialise(); ResidenceManager.Initialise(); // make sure the assigned realm id in the configuration file exists in the database RealmId = ConfigurationManager <WorldServerConfiguration> .Config.RealmId; if (ServerManager.Servers.All(s => s.Model.Id != RealmId)) { throw new ConfigurationException($"Realm id {RealmId} in configuration file doesn't exist in the database!"); } MessageManager.Initialise(); SocialManager.Initialise(); CommandManager.Initialise(); NetworkManager <WorldSession> .Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Network); WorldManager.Initialise(lastTick => { NetworkManager <WorldSession> .Update(lastTick); MapManager.Update(lastTick); ResidenceManager.Update(lastTick); BuybackManager.Update(lastTick); }); using (WorldServerEmbeddedWebServer.Initialise()) { log.Info("Ready!"); while (true) { Console.Write(">> "); string line = Console.ReadLine(); if (!CommandManager.HandleCommand(new ConsoleCommandContext(), line, false)) { Console.WriteLine("Invalid command"); } } } }
/// <summary> /// Add a new <see cref="UnlockedSpell"/> created from supplied spell base id and tier. /// </summary> public void AddSpell(uint spell4BaseId, byte tier = 1) { SpellBaseInfo spellBaseInfo = GlobalSpellManager.GetSpellBaseInfo(spell4BaseId); if (spellBaseInfo == null) { throw new ArgumentOutOfRangeException(); } SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier); if (spellInfo == null) { throw new ArgumentOutOfRangeException(); } if (spells.ContainsKey(spell4BaseId)) { throw new InvalidOperationException(); } Item item = player.Inventory.SpellCreate(spellBaseInfo.Entry, 49); var unlockedSpell = new UnlockedSpell(spellBaseInfo, tier, item); if (!player.IsLoading) { player.Session.EnqueueMessageEncrypted(new ServerSpellUpdate { Spell4BaseId = spell4BaseId, TierIndex = tier, Activated = true }); } spells.Add(spellBaseInfo.Entry.Id, unlockedSpell); }
/// <summary> /// Cast a <see cref="Spell"/> with the supplied spell base id, tier and <see cref="SpellParameters"/>. /// </summary> public void CastSpell(uint spell4BaseId, byte tier, SpellParameters parameters) { if (parameters == null) { throw new ArgumentNullException(); } SpellBaseInfo spellBaseInfo = GlobalSpellManager.GetSpellBaseInfo(spell4BaseId); if (spellBaseInfo == null) { throw new ArgumentOutOfRangeException(); } SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier); if (spellInfo == null) { throw new ArgumentOutOfRangeException(); } parameters.SpellInfo = spellInfo; CastSpell(parameters); }