Exemple #1
0
        public void LoadGameObjectSpawns()
        {
            Log.Message(LogType.DB, "Loading gameobject spawns...");

            SQLResult result = DB.World.Select("SELECT * FROM gameobject_spawns");

            Parallel.For(0, result.Count, (i, loop) =>
            {
                var guid = result.Read <UInt64>(i, "Guid");
                var id   = result.Read <Int32>(i, "Id");

                GameObject data = Globals.DataMgr.FindGameObject(id);
                if (data == null)
                {
                    Log.Message(LogType.ERROR, "Loading a gameobject spawn (Guid: {0}) with non-existing stats (Id: {1}) skipped.", guid, id);
                    return;
                }

                GameObjectSpawn spawn = new GameObjectSpawn()
                {
                    Guid = guid,
                    Id   = id,
                    Map  = result.Read <UInt32>(i, "Map"),

                    Position = new Vector4()
                    {
                        X = result.Read <Single>(i, "X"),
                        Y = result.Read <Single>(i, "Y"),
                        Z = result.Read <Single>(i, "Z"),
                        O = result.Read <Single>(i, "O")
                    },

                    FactionTemplate = result.Read <UInt32>(i, "FactionTemplate"),
                    AnimProgress    = result.Read <Byte>(i, "AnimProgress"),
                    Activated       = result.Read <bool>(i, "Activated"),
                };

                spawn.CreateFullGuid();
                spawn.CreateData(data);

                AddSpawn(spawn, ref data);
            });

            Log.Message(LogType.DB, "Loaded {0} gameobject spawns.", GameObjectSpawns.Count);
            Log.Message();
        }