コード例 #1
0
ファイル: Player.Map.cs プロジェクト: jungrok5/CypherCore
        // Reset all solo instances and optionally send a message on success for each
        public void ResetInstances(InstanceResetMethod method, bool isRaid, bool isLegacy)
        {
            // method can be INSTANCE_RESET_ALL, INSTANCE_RESET_CHANGE_DIFFICULTY, INSTANCE_RESET_GROUP_JOIN

            // we assume that when the difficulty changes, all instances that can be reset will be
            Difficulty diff = GetDungeonDifficultyID();

            if (isRaid)
            {
                if (!isLegacy)
                {
                    diff = GetRaidDifficultyID();
                }
                else
                {
                    diff = GetLegacyRaidDifficultyID();
                }
            }

            foreach (var pair in m_boundInstances[(int)diff].ToList())
            {
                InstanceSave p     = pair.Value.save;
                MapRecord    entry = CliDB.MapStorage.LookupByKey(pair.Key);
                if (entry == null || entry.IsRaid() != isRaid || !p.CanReset())
                {
                    continue;
                }

                if (method == InstanceResetMethod.All)
                {
                    // the "reset all instances" method can only reset normal maps
                    if (entry.InstanceType == MapTypes.Raid || diff == Difficulty.Heroic)
                    {
                        continue;
                    }
                }

                // if the map is loaded, reset it
                Map map = Global.MapMgr.FindMap(p.GetMapId(), p.GetInstanceId());
                if (map != null && map.IsDungeon())
                {
                    if (!map.ToInstanceMap().Reset(method))
                    {
                        continue;
                    }
                }

                // since this is a solo instance there should not be any players inside
                if (method == InstanceResetMethod.All || method == InstanceResetMethod.ChangeDifficulty)
                {
                    SendResetInstanceSuccess(p.GetMapId());
                }

                p.DeleteFromDB();
                m_boundInstances[(int)diff].Remove(pair.Key);

                // the following should remove the instance save from the manager and delete it as well
                p.RemovePlayer(this);
            }
        }