Пример #1
0
    void DisableItem(GameObject go, DisableType disableType)
    {
        UIButton btn = go.GetComponent <UIButton>();

        btn.enabled = false;
        PlayerSkillCell cell = go.GetComponent <PlayerSkillCell>();

        cell.huiSp.gameObject.SetActive(true);
        //cell.backSp.color = Color.gray;
        UIManager.RemoveButtonEventHandler(go, EnumButtonEvent.OnClick);
        UIManager.SetButtonEventHandler(go, EnumButtonEvent.OnClick, OnClickDisableBtn, (int)disableType, 0);
    }
Пример #2
0
        public void Initialise()
        {
            var builder = ImmutableDictionary.CreateBuilder <ulong, Disable>();

            foreach (DisableModel model in WorldDatabase.GetDisables())
            {
                DisableType type = (DisableType)model.Type;
                builder.Add(Hash(type, model.ObjectId), new Disable(type, model.ObjectId, model.Note));
            }

            disables = builder.ToImmutable();
        }
        public void HandleDisableInfo(ICommandContext context,
                                      [Parameter("Disabled entity type.", ParameterFlags.None, typeof(EnumParameterConverter <DisableType>))]
                                      DisableType disableType,
                                      [Parameter("Object id for the disabled entity type.")]
                                      uint objectId)
        {
            string note = DisableManager.Instance.GetDisableNote(disableType, objectId);

            if (note == null)
            {
                context.SendMessage("That combination of disable type and object id isn't disabled!");
                return;
            }

            context.SendMessage($"Type: {disableType}, ObjectId: {objectId}, Note: {note}");
        }
Пример #4
0
        public bool Disable(DisableType disableType)
        {
            if (this.IsDeleted)
            {
                return(false);
            }

            if (Placement != null && disableType == DisableType.SafeDisable)
            {
                Placement.Position = new P3Float(Placement.Position.X, Placement.Position.Y, -30000);
            }

            if (EnableParent != null && disableType != DisableType.JustInitiallyDisabled)
            {
                EnableParent.Flags     = EnableParent.Flag.SetEnableStateToOppositeOfParent;
                EnableParent.Reference = new FormLink <ILinkedReferenceGetter>(Constants.Player);
            }

            MajorRecordFlagsRaw = EnumExt.SetFlag(MajorRecordFlagsRaw, (int)SkyrimMajorRecordFlag.InitiallyDisabled, true);
            return(true);
        }
Пример #5
0
        /// <summary>
        /// Allows to easily disable placed records. Specify <paramref name="disableType"/> to further designate
        /// how the record should be disabled.
        /// </summary>
        /// <param name="placed">IPlaced object to disable</param>
        /// <param name="disableType">How the record should be disabled</param>
        /// <returns>Returns true if the disable operation has succeeded, false otherwise.</returns>
        public static bool Disable(this IPlaced placed, DisableType disableType)
        {
            if (placed.IsDeleted)
            {
                return(false);
            }

            if (placed.Placement != null && disableType == DisableType.SafeDisable)
            {
                placed.Placement.Position = new P3Float(placed.Placement.Position.X, placed.Placement.Position.Y, -30000);
            }

            if (placed.EnableParent != null && disableType != DisableType.JustInitiallyDisabled)
            {
                placed.EnableParent.Flags = EnableParent.Flag.SetEnableStateToOppositeOfParent;
                placed.EnableParent.Reference.SetTo(Constants.Player.Cast <ILinkedReferenceGetter>());
            }

            placed.MajorRecordFlagsRaw = EnumExt.SetFlag(placed.MajorRecordFlagsRaw, (int)SkyrimMajorRecordFlag.InitiallyDisabled, true);
            return(true);
        }
Пример #6
0
    private void OnClickDisableBtn(ButtonScript obj, object args, int param1, int param2)
    {
        DisableType dt = (DisableType)param1;

        switch (dt)
        {
        case DisableType.DT_NoMana:
            PopText.Instance.Show(LanguageManager.instance.GetValue("notEnoughMana"), PopText.WarningType.WT_Warning, true);
            break;

        case DisableType.DT_NoPassitive:
            PopText.Instance.Show(LanguageManager.instance.GetValue("isPassitiveSkill"), PopText.WarningType.WT_Warning, true);
            break;

        case DisableType.DT_NoWeapon:
            PopText.Instance.Show(LanguageManager.instance.GetValue("notCorrectWeaponType"), PopText.WarningType.WT_Warning, true);
            break;

        default:
            break;
        }
    }
Пример #7
0
 private static ulong Hash(DisableType type, uint objectId)
 {
     // hash where type takes up the top 32 bits and objectId takes up the lower 32 bits
     return(((ulong)type << 32) | objectId);
 }
Пример #8
0
        /// <summary>
        /// Return the disable reason for <see cref="DisableType"/> and objectId.
        /// </summary>
        public string GetDisableNote(DisableType type, uint objectId)
        {
            ulong hash = Hash(type, objectId);

            return(disables.TryGetValue(hash, out Disable disable) ? disable.Note : null);
        }
Пример #9
0
        /// <summary>
        /// Returns if <see cref="DisableType"/> and objectId are disabled.
        /// </summary>
        public bool IsDisabled(DisableType type, uint objectId)
        {
            ulong hash = Hash(type, objectId);

            return(disables.ContainsKey(hash));
        }
Пример #10
0
            static bool HandleAddDisables(StringArguments args, CommandHandler handler, DisableType disableType)
            {
                uint entry = args.NextUInt32();

                if (entry == 0)
                {
                    return(false);
                }

                uint flags = args.NextUInt32();

                string disableComment = args.NextString("");

                if (string.IsNullOrEmpty(disableComment))
                {
                    return(false);
                }

                string disableTypeStr = "";

                switch (disableType)
                {
                case DisableType.Spell:
                {
                    if (!Global.SpellMgr.HasSpellInfo(entry, Difficulty.None))
                    {
                        handler.SendSysMessage(CypherStrings.CommandNospellfound);
                        return(false);
                    }
                    disableTypeStr = "spell";
                    break;
                }

                case DisableType.Quest:
                {
                    if (Global.ObjectMgr.GetQuestTemplate(entry) == null)
                    {
                        handler.SendSysMessage(CypherStrings.CommandNoquestfound, entry);
                        return(false);
                    }
                    disableTypeStr = "quest";
                    break;
                }

                case DisableType.Map:
                {
                    if (!CliDB.MapStorage.ContainsKey(entry))
                    {
                        handler.SendSysMessage(CypherStrings.CommandNomapfound);
                        return(false);
                    }
                    disableTypeStr = "map";
                    break;
                }

                case DisableType.Battleground:
                {
                    if (!CliDB.BattlemasterListStorage.ContainsKey(entry))
                    {
                        handler.SendSysMessage(CypherStrings.CommandNoBattlegroundFound);
                        return(false);
                    }
                    disableTypeStr = "Battleground";
                    break;
                }

                case DisableType.Criteria:
                {
                    if (Global.CriteriaMgr.GetCriteria(entry) == null)
                    {
                        handler.SendSysMessage(CypherStrings.CommandNoAchievementCriteriaFound);
                        return(false);
                    }
                    disableTypeStr = "criteria";
                    break;
                }

                case DisableType.OutdoorPVP:
                {
                    if (entry > (int)OutdoorPvPTypes.Max)
                    {
                        handler.SendSysMessage(CypherStrings.CommandNoOutdoorPvpForund);
                        return(false);
                    }
                    disableTypeStr = "outdoorpvp";
                    break;
                }

                case DisableType.VMAP:
                {
                    if (!CliDB.MapStorage.ContainsKey(entry))
                    {
                        handler.SendSysMessage(CypherStrings.CommandNomapfound);
                        return(false);
                    }
                    disableTypeStr = "vmap";
                    break;
                }

                case DisableType.MMAP:
                {
                    if (!CliDB.MapStorage.ContainsKey(entry))
                    {
                        handler.SendSysMessage(CypherStrings.CommandNomapfound);
                        return(false);
                    }
                    disableTypeStr = "mmap";
                    break;
                }

                default:
                    break;
                }

                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_DISABLES);

                stmt.AddValue(0, entry);
                stmt.AddValue(1, disableType);
                SQLResult result = DB.World.Query(stmt);

                if (!result.IsEmpty())
                {
                    handler.SendSysMessage("This {0} (Id: {1}) is already disabled.", disableTypeStr, entry);
                    return(false);
                }

                stmt = DB.World.GetPreparedStatement(WorldStatements.INS_DISABLES);
                stmt.AddValue(0, entry);
                stmt.AddValue(1, disableType);
                stmt.AddValue(2, flags);
                stmt.AddValue(3, disableComment);
                DB.World.Execute(stmt);

                handler.SendSysMessage("Add Disabled {0} (Id: {1}) for reason {2}", disableTypeStr, entry, disableComment);
                return(true);
            }
Пример #11
0
            static bool HandleRemoveDisables(StringArguments args, CommandHandler handler, DisableType disableType)
            {
                if (!uint.TryParse(args.NextString(), out uint entry) || entry == 0)
                {
                    return(false);
                }

                string disableTypeStr = "";

                switch (disableType)
                {
                case DisableType.Spell:
                    disableTypeStr = "spell";
                    break;

                case DisableType.Quest:
                    disableTypeStr = "quest";
                    break;

                case DisableType.Map:
                    disableTypeStr = "map";
                    break;

                case DisableType.Battleground:
                    disableTypeStr = "Battleground";
                    break;

                case DisableType.Criteria:
                    disableTypeStr = "criteria";
                    break;

                case DisableType.OutdoorPVP:
                    disableTypeStr = "outdoorpvp";
                    break;

                case DisableType.VMAP:
                    disableTypeStr = "vmap";
                    break;

                case DisableType.MMAP:
                    disableTypeStr = "mmap";
                    break;
                }

                PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_DISABLES);

                stmt.AddValue(0, entry);
                stmt.AddValue(1, disableType);
                SQLResult result = DB.World.Query(stmt);

                if (result.IsEmpty())
                {
                    handler.SendSysMessage("This {0} (Id: {1}) is not disabled.", disableTypeStr, entry);
                    return(false);
                }

                stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_DISABLES);
                stmt.AddValue(0, entry);
                stmt.AddValue(1, disableType);
                DB.World.Execute(stmt);

                handler.SendSysMessage("Remove Disabled {0} (Id: {1})", disableTypeStr, entry);
                return(true);
            }
Пример #12
0
        public void LoadDisables()
        {
            uint oldMSTime = Time.GetMSTime();

            // reload case
            m_DisableMap.Clear();

            SQLResult result = DB.World.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");

            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 disables. DB table `disables` is empty!");
                return;
            }

            uint total_count = 0;

            do
            {
                DisableType type = (DisableType)result.Read <uint>(0);
                if (type >= DisableType.Max)
                {
                    Log.outError(LogFilter.Sql, "Invalid type {0} specified in `disables` table, skipped.", type);
                    continue;
                }

                uint   entry    = result.Read <uint>(1);
                byte   flags    = result.Read <byte>(2);
                string params_0 = result.Read <string>(3);
                string params_1 = result.Read <string>(4);

                DisableData data = new DisableData();
                data.flags = flags;

                switch (type)
                {
                case DisableType.Spell:
                    if (!(Global.SpellMgr.HasSpellInfo(entry, Difficulty.None) || flags.HasAnyFlag <byte>(DisableFlags.SpellDeprecatedSpell)))
                    {
                        Log.outError(LogFilter.Sql, "Spell entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }

                    if (flags == 0 || flags > DisableFlags.MaxSpell)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags for spell {0} are invalid, skipped.", entry);
                        continue;
                    }

                    if (flags.HasAnyFlag(DisableFlags.SpellMap))
                    {
                        var array = new StringArray(params_0, ',');
                        for (byte i = 0; i < array.Length;)
                        {
                            if (uint.TryParse(array[i++], out uint id))
                            {
                                data.param0.Add(id);
                            }
                        }
                    }

                    if (flags.HasAnyFlag(DisableFlags.SpellArea))
                    {
                        var array = new StringArray(params_1, ',');
                        for (byte i = 0; i < array.Length;)
                        {
                            if (uint.TryParse(array[i++], out uint id))
                            {
                                data.param1.Add(id);
                            }
                        }
                    }

                    break;

                // checked later
                case DisableType.Quest:
                    break;

                case DisableType.Map:
                case DisableType.LFGMap:
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry == null)
                    {
                        Log.outError(LogFilter.Sql, "Map entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    bool isFlagInvalid = false;
                    switch (mapEntry.InstanceType)
                    {
                    case MapTypes.Common:
                        if (flags != 0)
                        {
                            isFlagInvalid = true;
                        }
                        break;

                    case MapTypes.Instance:
                    case MapTypes.Raid:
                        if (flags.HasAnyFlag(DisableFlags.DungeonStatusHeroic) && Global.DB2Mgr.GetMapDifficultyData(entry, Difficulty.Heroic) == null)
                        {
                            flags -= DisableFlags.DungeonStatusHeroic;
                        }
                        if (flags.HasAnyFlag(DisableFlags.DungeonStatusHeroic10Man) && Global.DB2Mgr.GetMapDifficultyData(entry, Difficulty.Raid10HC) == null)
                        {
                            flags -= DisableFlags.DungeonStatusHeroic10Man;
                        }
                        if (flags.HasAnyFlag(DisableFlags.DungeonStatusHeroic25Man) && Global.DB2Mgr.GetMapDifficultyData(entry, Difficulty.Raid25HC) == null)
                        {
                            flags -= DisableFlags.DungeonStatusHeroic25Man;
                        }
                        if (flags == 0)
                        {
                            isFlagInvalid = true;
                        }
                        break;

                    case MapTypes.Battleground:
                    case MapTypes.Arena:
                        Log.outError(LogFilter.Sql, "Battlegroundmap {0} specified to be disabled in map case, skipped.", entry);
                        continue;
                    }
                    if (isFlagInvalid)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags for map {0} are invalid, skipped.", entry);
                        continue;
                    }
                    break;
                }

                case DisableType.Battleground:
                    if (!CliDB.BattlemasterListStorage.ContainsKey(entry))
                    {
                        Log.outError(LogFilter.Sql, "Battlegroundentry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    if (flags != 0)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags specified for Battleground{0}, useless data.", entry);
                    }
                    break;

                case DisableType.OutdoorPVP:
                    if (entry > (int)OutdoorPvPTypes.Max)
                    {
                        Log.outError(LogFilter.Sql, "OutdoorPvPTypes value {0} from `disables` is invalid, skipped.", entry);
                        continue;
                    }
                    if (flags != 0)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags specified for outdoor PvP {0}, useless data.", entry);
                    }
                    break;

                case DisableType.Criteria:
                    if (Global.CriteriaMgr.GetCriteria(entry) == null)
                    {
                        Log.outError(LogFilter.Sql, "Criteria entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    if (flags != 0)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags specified for Criteria {0}, useless data.", entry);
                    }
                    break;

                case DisableType.VMAP:
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry == null)
                    {
                        Log.outError(LogFilter.Sql, "Map entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    switch (mapEntry.InstanceType)
                    {
                    case MapTypes.Common:
                        if (flags.HasAnyFlag(DisableFlags.VmapAreaFlag))
                        {
                            Log.outInfo(LogFilter.Server, "Areaflag disabled for world map {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLiquidStatus))
                        {
                            Log.outInfo(LogFilter.Server, "Liquid status disabled for world map {0}.", entry);
                        }
                        break;

                    case MapTypes.Instance:
                    case MapTypes.Raid:
                        if (flags.HasAnyFlag(DisableFlags.VmapHeight))
                        {
                            Log.outInfo(LogFilter.Server, "Height disabled for instance map {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLOS))
                        {
                            Log.outInfo(LogFilter.Server, "LoS disabled for instance map {0}.", entry);
                        }
                        break;

                    case MapTypes.Battleground:
                        if (flags.HasAnyFlag(DisableFlags.VmapHeight))
                        {
                            Log.outInfo(LogFilter.Server, "Height disabled for Battlegroundmap {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLOS))
                        {
                            Log.outInfo(LogFilter.Server, "LoS disabled for Battlegroundmap {0}.", entry);
                        }
                        break;

                    case MapTypes.Arena:
                        if (flags.HasAnyFlag(DisableFlags.VmapHeight))
                        {
                            Log.outInfo(LogFilter.Server, "Height disabled for arena map {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLOS))
                        {
                            Log.outInfo(LogFilter.Server, "LoS disabled for arena map {0}.", entry);
                        }
                        break;

                    default:
                        break;
                    }
                    break;
                }

                case DisableType.MMAP:
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry == null)
                    {
                        Log.outError(LogFilter.Sql, "Map entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    switch (mapEntry.InstanceType)
                    {
                    case MapTypes.Common:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for world map {0}.", entry);
                        break;

                    case MapTypes.Instance:
                    case MapTypes.Raid:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for instance map {0}.", entry);
                        break;

                    case MapTypes.Battleground:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for Battlegroundmap {0}.", entry);
                        break;

                    case MapTypes.Arena:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for arena map {0}.", entry);
                        break;

                    default:
                        break;
                    }
                    break;
                }

                default:
                    break;
                }
                if (!m_DisableMap.ContainsKey(type))
                {
                    m_DisableMap[type] = new Dictionary <uint, DisableData>();
                }

                m_DisableMap[type].Add(entry, data);
                ++total_count;
            }while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} disables in {1} ms", total_count, Time.GetMSTimeDiffToNow(oldMSTime));
        }
Пример #13
0
        public bool IsDisabledFor(DisableType type, uint entry, Unit unit, byte flags = 0)
        {
            Cypher.Assert(type < DisableType.Max);
            if (!m_DisableMap.ContainsKey(type) || m_DisableMap[type].Empty())
            {
                return(false);
            }

            var data = m_DisableMap[type].LookupByKey(entry);

            if (data == null)    // not disabled
            {
                return(false);
            }

            switch (type)
            {
            case DisableType.Spell:
            {
                byte spellFlags = data.flags;
                if (unit != null)
                {
                    if ((spellFlags.HasAnyFlag(DisableFlags.SpellPlayer) && unit.IsTypeId(TypeId.Player)) ||
                        (unit.IsTypeId(TypeId.Unit) && ((unit.IsPet() && spellFlags.HasAnyFlag(DisableFlags.SpellPet)) || spellFlags.HasAnyFlag(DisableFlags.SpellCreature))))
                    {
                        if (spellFlags.HasAnyFlag(DisableFlags.SpellMap))
                        {
                            List <uint> mapIds = data.param0;
                            if (mapIds.Contains(unit.GetMapId()))
                            {
                                return(true);                                               // Spell is disabled on current map
                            }
                            if (!spellFlags.HasAnyFlag(DisableFlags.SpellArea))
                            {
                                return(false);                                              // Spell is disabled on another map, but not this one, return false
                            }
                            // Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
                        }

                        if (spellFlags.HasAnyFlag(DisableFlags.SpellArea))
                        {
                            var areaIds = data.param1;
                            if (areaIds.Contains(unit.GetAreaId()))
                            {
                                return(true);                                               // Spell is disabled in this area
                            }
                            return(false);                                                  // Spell is disabled in another area, but not this one, return false
                        }
                        else
                        {
                            return(true);                                                   // Spell disabled for all maps
                        }
                    }

                    return(false);
                }
                else if (spellFlags.HasAnyFlag(DisableFlags.SpellDeprecatedSpell))            // call not from spellcast
                {
                    return(true);
                }
                else if (flags.HasAnyFlag(DisableFlags.SpellLOS))
                {
                    return(spellFlags.HasAnyFlag(DisableFlags.SpellLOS));
                }

                break;
            }

            case DisableType.Map:
            case DisableType.LFGMap:
                Player player = unit.ToPlayer();
                if (player != null)
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry.IsDungeon())
                    {
                        byte       disabledModes    = data.flags;
                        Difficulty targetDifficulty = player.GetDifficultyID(mapEntry);
                        Global.DB2Mgr.GetDownscaledMapDifficultyData(entry, ref targetDifficulty);
                        switch (targetDifficulty)
                        {
                        case Difficulty.Normal:
                            return(disabledModes.HasAnyFlag(DisableFlags.DungeonStatusNormal));

                        case Difficulty.Heroic:
                            return(disabledModes.HasAnyFlag(DisableFlags.DungeonStatusHeroic));

                        case Difficulty.Raid10HC:
                            return(disabledModes.HasAnyFlag(DisableFlags.DungeonStatusHeroic10Man));

                        case Difficulty.Raid25HC:
                            return(disabledModes.HasAnyFlag(DisableFlags.DungeonStatusHeroic25Man));

                        default:
                            return(false);
                        }
                    }
                    else if (mapEntry.InstanceType == MapTypes.Common)
                    {
                        return(true);
                    }
                }
                return(false);

            case DisableType.Quest:
                if (unit == null)
                {
                    return(true);
                }
                Player player1 = unit.ToPlayer();
                if (player1 != null)
                {
                    if (player1.IsGameMaster())
                    {
                        return(false);
                    }
                }
                return(true);

            case DisableType.Battleground:
            case DisableType.OutdoorPVP:
            case DisableType.Criteria:
            case DisableType.MMAP:
                return(true);

            case DisableType.VMAP:
                return(flags.HasAnyFlag(data.flags));
            }

            return(false);
        }
Пример #14
0
 public Disable(DisableType type, uint objectId, string note)
 {
     Type     = type;
     ObjectId = objectId;
     Note     = note;
 }