Inheritance: IDataModel
コード例 #1
0
ファイル: UnitMisc.cs プロジェクト: rob3ns/PacketSniffer
        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;

            // Build a dictionary with model data; model is the key
            var models = new StoreDictionary<uint, 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;
                if (npc.Model.HasValue)
                    modelId = npc.Model.Value;
                else
                    continue;

                // Do not add duplicate models
                if (models.ContainsKey(modelId))
                    continue;

                float scale = npc.Size.GetValueOrDefault(1.0f);
                var model = new ModelData
                {
                    BoundingRadius = npc.BoundingRadius.GetValueOrDefault(0.306f) / scale,
                    CombatReach = npc.CombatReach.GetValueOrDefault(1.5f) / scale,
                    Gender = npc.Gender.GetValueOrDefault(Gender.Male)
                };

                models.Add(modelId, model);
            }

            var entries = models.Keys();
            var modelsDb = SQLDatabase.GetDict<uint, ModelData>(entries, "DisplayID");
            return SQLUtil.CompareDicts(models, modelsDb, StoreNameType.None, "DisplayID");
        }
コード例 #2
0
ファイル: UnitMisc.cs プロジェクト: jackpoz/WowPacketParser
        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;
                if (npc.Model.HasValue)
                    modelId = npc.Model.Value;
                else
                    continue;

                var model = new ModelData
                {
                    DisplayID = modelId
                };

                if (models.ContainsKey(model))
                    continue;

                var scale = npc.Size.GetValueOrDefault(1.0f);
                model.BoundingRadius = npc.BoundingRadius.GetValueOrDefault(0.306f) / scale;
                model.CombatReach = npc.CombatReach.GetValueOrDefault(1.5f) / scale;
                model.Gender = npc.Gender.GetValueOrDefault(Gender.Male);

                models.Add(model);
            }

            var modelsDb = SQLDatabase.Get(models);
            return SQLUtil.Compare(models, modelsDb, StoreNameType.None);
        }
コード例 #3
0
ファイル: UnitMisc.cs プロジェクト: Huri/WowPacketParser
        public static string ModelData(Dictionary<Guid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

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

            // Build a dictionary with model data; model is the key
            var models = new StoreDictionary<uint, ModelData>();
            foreach (var npc in units.Select(unit => unit.Value))
            {
                uint modelId;
                if (npc.Model.HasValue)
                    modelId = npc.Model.Value;
                else
                    continue;

                // Do not add duplicate models
                if (models.ContainsKey(modelId))
                    continue;

                var model = new ModelData
                {
                    BoundingRadius = npc.BoundingRadius.GetValueOrDefault(0.306f),
                    CombatReach = npc.CombatReach.GetValueOrDefault(1.5f),
                    Gender = npc.Gender.GetValueOrDefault(Gender.Male)
                };

                models.Add(modelId, model, null);
            }

            var entries = models.Keys();
            var modelsDb = SQLDatabase.GetDict<uint, ModelData>(entries, "modelid");
            return SQLUtil.CompareDicts(models, modelsDb, StoreNameType.None, "modelid");
        }