Exemple #1
0
 public void LoadSpawnedCreatures(DataTable pDataTable, int pMapId)
 {
     if (!MapAlreadyLoaded(pMapId))
     {
         foreach (DataRow dRow in pDataTable.Rows)
         {
             var position = new Vector3()
             {
                 X = float.Parse(dRow[9].ToString()),
                 Y = float.Parse(dRow[10].ToString()),
                 Z = float.Parse(dRow[11].ToString())
             };
             var creature = new SpawnedCreature()
             {
                 SpawnGuid       = int.Parse(dRow[0].ToString()),
                 Creature        = GetCreatureByEntry(int.Parse(dRow[1].ToString())),
                 Map             = int.Parse(dRow[2].ToString()),
                 ZoneId          = int.Parse(dRow[3].ToString()),
                 AreaId          = int.Parse(dRow[4].ToString()),
                 SpawnMask       = (npcSpawnMask)Enum.Parse(typeof(npcSpawnMask), dRow[5].ToString()),
                 cPhaseMask      = int.Parse(dRow[6].ToString()),
                 ModelId         = int.Parse(dRow[7].ToString()),
                 EquipmentId     = int.Parse(dRow[8].ToString()),
                 Position        = position,
                 Orientation     = float.Parse(dRow[12].ToString()),
                 SpawnTimeSecs   = int.Parse(dRow[13].ToString()),
                 SpawnDist       = float.Parse(dRow[14].ToString()),
                 CurrentWayPoint = int.Parse(dRow[15].ToString()),
                 CurrentHealth   = int.Parse(dRow[16].ToString()),
                 CurrentMana     = int.Parse(dRow[17].ToString()),
                 MovementType    = (MovementType)Enum.Parse(typeof(MovementType), dRow[18].ToString()),
                 NpcFlag         = (NpcFlag)Enum.Parse(typeof(NpcFlag), dRow[19].ToString()),
                 UnitFlags       = (UnitFlags)Enum.Parse(typeof(UnitFlags), dRow[20].ToString()),
                 DynamicFlags    = (DynamicFlags)Enum.Parse(typeof(DynamicFlags), dRow[21].ToString()),
                 VerifiedBuild   = int.Parse(dRow[22].ToString())
             };
             mSpawnedCreatures.Add(creature);
         }
         mLoadedMaps.Add(pMapId);
     }
 }
        // ReSharper disable once FunctionComplexityOverflow
        public void LoadSpawnedCreatures(DataTable pDataTable, int pMapId)
        {
            if (!MapAlreadyLoaded(pMapId))
            {
                foreach (DataRow dRow in pDataTable.Rows)
                {
                    var creature = new SpawnedCreature();
                    var position = new Vector3();
                    foreach (DataColumn dColumn in pDataTable.Columns)
                    {
                        switch (dColumn.ColumnName)
                        {
                        case "guid":
                            creature.SpawnGuid = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "id":
                            creature.Creature = GetCreatureByEntry(int.Parse(dRow[dColumn].ToString()));
                            break;

                        case "map":
                            creature.Map = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "spawnMask":
                            creature.SpawnMask = (SpawnMask)Enum.Parse(typeof(SpawnMask), dRow[dColumn].ToString());
                            break;

                        case "phaseMask":
                            creature.PhaseMask = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "modelid":
                            creature.ModelId = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "equipment_id":
                            creature.EquipmentId = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "position_x":
                            position.X = float.Parse(dRow[dColumn].ToString());
                            break;

                        case "position_y":
                            position.Y = float.Parse(dRow[dColumn].ToString());
                            break;

                        case "position_z":
                            position.Z = float.Parse(dRow[dColumn].ToString());
                            break;

                        case "orientation":
                            creature.Orientation = float.Parse(dRow[dColumn].ToString());
                            break;

                        case "spawntimesecs":
                            creature.SpawnTimeSecs = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "spawndist":
                            creature.SpawnDist = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "currentwaypoint":
                            creature.CurrentWayPoint = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "curhealth":
                            creature.CurrentHealth = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "curmana":
                            creature.CurrentMana = int.Parse(dRow[dColumn].ToString());
                            break;

                        case "MovementType":
                            creature.MovementType = (MovementType)Enum.Parse(typeof(MovementType), dRow[dColumn].ToString());
                            break;

                        case "npcflag":
                            creature.NpcFlag = (NpcFlag)Enum.Parse(typeof(NpcFlag), dRow[dColumn].ToString());
                            break;

                        case "unit_flags":
                            creature.UnitFlags = (UnitFlags)Enum.Parse(typeof(UnitFlags), dRow[dColumn].ToString());
                            break;

                        case "dynamicflags":
                            creature.DynamicFlags = (DynamicFlags)Enum.Parse(typeof(DynamicFlags), dRow[dColumn].ToString());
                            break;
                        }
                    }
                    creature.Position = position;
                    mSpawnedCreatures.Add(creature);
                }
                mLoadedMaps.Add(pMapId);
            }
        }