Exemplo n.º 1
0
        public static string ModelData(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_model_info))
            {
                return(string.Empty);
            }

            var models = new DataBag <ModelData>();

            foreach (var npc in units.Select(unit => unit.Value))
            {
                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(npc.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(npc.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                uint modelId = (uint)npc.UnitData.DisplayID;
                if (modelId == 0)
                {
                    continue;
                }

                var model = new ModelData
                {
                    DisplayID = modelId
                };

                //if (models.ContainsKey(model))
                if (models.Any(modelInfo => modelInfo.Item1.DisplayID == modelId))
                {
                    continue;
                }

                var scale = npc.ObjectData.Scale;
                model.BoundingRadius = npc.UnitData.BoundingRadius / scale;
                model.CombatReach    = npc.UnitData.CombatReach / scale;
                model.Gender         = (Gender)npc.UnitData.Sex;

                models.Add(model);
            }

            var modelsDb = SQLDatabase.Get(models);

            return(SQLUtil.Compare(models, modelsDb, StoreNameType.None));
        }