Esempio n. 1
0
        /// <summary>
        /// Creates a new GameObject with the given parameters
        /// </summary>
        public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
        {
            var go             = entry.GOCreator();
            var handlerCreator = entry.HandlerCreator;

            go.Init(entry, spawnEntry, spawnPoint);
            if (handlerCreator != null)
            {
                go.Handler = handlerCreator();
            }
            else
            {
                log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
                go.Delete();
                return(null);
            }
            go.Phase = where.Phase;
            var pos = where.Position;

            if (spawnPoint == null)
            {
                pos.Z = where.Map.Terrain.GetGroundHeightUnderneath(pos);
            }
            where.Map.AddObject(go, ref pos);

            go.MarkUpdate(GameObjectFields.DYNAMIC);
            return(go);
        }
Esempio n. 2
0
 internal override void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
 {
     base.Init(entry, spawnEntry, spawnPoint);
     this.m_goTransportEntry = this.Entry as GOMOTransportEntry;
     TransportMgr.TransportEntries.TryGetValue(this.m_entry.GOId, out this.m_transportEntry);
     this.m_isMOTransport = this.m_goTransportEntry != null && this.m_transportEntry != null;
 }
Esempio n. 3
0
        /// <summary>Creates a new GameObject with the given parameters</summary>
        public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null,
                                        GOSpawnPoint spawnPoint = null)
        {
            GameObject gameObject = entry.GOCreator();

            gameObject.GoId = entry.GOId;
            Func <GameObjectHandler> handlerCreator = entry.HandlerCreator;

            gameObject.Init(entry, spawnEntry, spawnPoint);
            if (handlerCreator != null)
            {
                gameObject.Handler = handlerCreator();
                gameObject.Phase   = where.Phase;
                Vector3 position = where.Position;
                if (spawnPoint == null)
                {
                    position.Z = where.Map.Terrain.GetGroundHeightUnderneath(position);
                }
                where.Map.AddObject(gameObject, ref position);
                gameObject.MarkUpdate(GameObjectFields.DYNAMIC);
                return(gameObject);
            }

            log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry,
                     entry.Type);
            gameObject.Delete();
            return(null);
        }
Esempio n. 4
0
        /// <summary>Initialize the GO</summary>
        /// <param name="entry"></param>
        /// <param name="templ"></param>
        internal virtual void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
        {
            EntityId =
                EntityId.GetGameObjectId((uint)Interlocked.Increment(ref _lastGOUID), entry.GOId);
            Type        |= ObjectTypes.GameObject;
            m_entry      = entry;
            m_spawnPoint = spawnPoint;
            GoId         = entry.GOId;
            DisplayId    = entry.DisplayId;
            EntryId      = entry.Id;
            GOType       = entry.Type;
            Flags        = m_entry.Flags;
            m_faction    = m_entry.Faction ?? Faction.NullFaction;
            ScaleX       = m_entry.Scale;
            GossipMenu   = entry.DefaultGossip;
            if (QuestHolderInfo != null && GossipMenu == null)
            {
                GossipMenu = new GossipMenu();
            }
            spawnEntry = spawnEntry ?? entry.FirstSpawnEntry;
            if (spawnEntry != null)
            {
                Phase = spawnEntry.Phase;
                State = spawnEntry.State;
                if (spawnEntry.Scale != 1.0)
                {
                    ScaleX = spawnEntry.Scale;
                }
                Orientation       = spawnEntry.Orientation;
                AnimationProgress = spawnEntry.AnimProgress;
                SetRotationFields(spawnEntry.Rotations);
            }

            m_entry.InitGO(this);
        }
Esempio n. 5
0
        public static GOSpawnEntry GetClosestEntry(this ICollection <GOSpawnPoolTemplate> templates, IWorldLocation pos)
        {
            if (pos == null)
            {
                return(templates.First().Entries.FirstOrDefault());
            }
            float        num1         = float.MaxValue;
            GOSpawnEntry goSpawnEntry = null;

            foreach (GOSpawnPoolTemplate template in templates)
            {
                if (template != null && template.MapId == pos.MapId)
                {
                    foreach (GOSpawnEntry entry in template.Entries)
                    {
                        if ((int)entry.Phase == (int)pos.Phase)
                        {
                            float num2 = pos.Position.DistanceSquared(entry.Position);
                            if (num2 < (double)num1)
                            {
                                num1         = num2;
                                goSpawnEntry = entry;
                            }
                        }
                    }
                }
            }

            return(goSpawnEntry);
        }
Esempio n. 6
0
        public static GOSpawnEntry GetClosestEntry(this ICollection <GOSpawnEntry> entries, IWorldLocation pos)
        {
            if (pos == null)
            {
                return(entries.First());
            }

            var          closestDistSq = float.MaxValue;
            GOSpawnEntry closest       = null;

            foreach (var entry in entries)
            {
                if (entry.MapId != pos.MapId || entry.Phase != pos.Phase)
                {
                    continue;
                }
                var distSq = pos.Position.DistanceSquared(entry.Position);
                if (distSq < closestDistSq)
                {
                    closestDistSq = distSq;
                    closest       = entry;
                }
            }
            return(closest);
        }
Esempio n. 7
0
        public static GOSpawnEntry GetClosestEntry(this ICollection <GOSpawnPoolTemplate> templates, IWorldLocation pos)
        {
            if (pos == null)
            {
                return(templates.First().Entries.FirstOrDefault());
            }

            var          closestDistSq = float.MaxValue;
            GOSpawnEntry closest       = null;

            foreach (var template in templates)
            {
                if (template == null || template.MapId != pos.MapId)
                {
                    continue;
                }

                foreach (var entry in template.Entries)
                {
                    if (entry.Phase != pos.Phase)
                    {
                        continue;
                    }

                    var distSq = pos.Position.DistanceSquared(entry.Position);
                    if (distSq < closestDistSq)
                    {
                        closestDistSq = distSq;
                        closest       = entry;
                    }
                }
            }
            return(closest);
        }
Esempio n. 8
0
        /// <summary>Initialize the GO</summary>
        /// <param name="entry"></param>
        /// <param name="templ"></param>
        internal virtual void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
        {
            this.EntityId =
                EntityId.GetGameObjectId((uint)Interlocked.Increment(ref GameObject._lastGOUID), entry.GOId);
            this.Type        |= ObjectTypes.GameObject;
            this.m_entry      = entry;
            this.m_spawnPoint = spawnPoint;
            this.GoId         = entry.GOId;
            this.DisplayId    = entry.DisplayId;
            this.EntryId      = entry.Id;
            this.GOType       = entry.Type;
            this.Flags        = this.m_entry.Flags;
            this.m_faction    = this.m_entry.Faction ?? Faction.NullFaction;
            this.ScaleX       = this.m_entry.Scale;
            this.GossipMenu   = entry.DefaultGossip;
            if (this.QuestHolderInfo != null && this.GossipMenu == null)
            {
                this.GossipMenu = new GossipMenu();
            }
            spawnEntry = spawnEntry ?? entry.FirstSpawnEntry;
            if (spawnEntry != null)
            {
                this.Phase = spawnEntry.Phase;
                this.State = spawnEntry.State;
                if ((double)spawnEntry.Scale != 1.0)
                {
                    this.ScaleX = spawnEntry.Scale;
                }
                this.Orientation       = spawnEntry.Orientation;
                this.AnimationProgress = spawnEntry.AnimProgress;
                this.SetRotationFields(spawnEntry.Rotations);
            }

            this.m_entry.InitGO(this);
        }
Esempio n. 9
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var go = entry.GOCreator();
			var handlerCreator = entry.HandlerCreator;
			go.Init(entry, spawnEntry, spawnPoint);
			if (handlerCreator != null)
			{
				go.Handler = handlerCreator();
			}
			else
			{
				log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
				go.Delete();
				return null;
			}
			go.Phase = where.Phase;
			var pos = where.Position;
			if (spawnPoint == null)
			{
				pos.Z = where.Map.Terrain.GetGroundHeightUnderneath(pos);
			}
			where.Map.AddObject(go, ref pos);

			go.MarkUpdate(GameObjectFields.DYNAMIC);
			return go;
		}
Esempio n. 10
0
		internal override void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
		{
			base.Init(entry, spawnEntry, spawnPoint);

			m_goTransportEntry = Entry as GOMOTransportEntry;
			TransportMgr.TransportEntries.TryGetValue(m_entry.GOId, out m_transportEntry);
			m_isMOTransport = m_goTransportEntry != null && m_transportEntry != null;
		}
Esempio n. 11
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntryId id, Map map, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var entry = GOMgr.GetEntry(id);
			if (entry != null)
			{
				return Create(entry, map, spawnEntry, spawnPoint);
			}
			return null;
		}
Esempio n. 12
0
		/// <summary>
		/// Creates the given kind of GameObject with the default Template
		/// </summary>
		public static GameObject Create(GOEntryId id, IWorldLocation location, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var entry = GOMgr.GetEntry(id);
			if (entry == null)
			{
				return null;
			}
			return Create(entry, location, spawnEntry, spawnPoint);
		}
Esempio n. 13
0
        /// <summary>
        /// Creates a new GameObject with the given parameters
        /// </summary>
        public static GameObject Create(GOEntryId id, Map map, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
        {
            var entry = GOMgr.GetEntry(id);

            if (entry != null)
            {
                return(Create(entry, map, spawnEntry, spawnPoint));
            }
            return(null);
        }
Esempio n. 14
0
        /// <summary>
        /// Creates the given kind of GameObject with the default Template
        /// </summary>
        public static GameObject Create(GOEntryId id, IWorldLocation location, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
        {
            var entry = GOMgr.GetEntry(id);

            if (entry == null)
            {
                return(null);
            }
            return(Create(entry, location, spawnEntry, spawnPoint));
        }
Esempio n. 15
0
        /// <summary>Creates a new GameObject with the given parameters</summary>
        public static GameObject Create(GOEntryId id, Map map, GOSpawnEntry spawnEntry = null,
                                        GOSpawnPoint spawnPoint = null)
        {
            GOEntry entry = GOMgr.GetEntry(id, true);

            if (entry != null)
            {
                return(GameObject.Create(entry, map, spawnEntry, spawnPoint));
            }
            return((GameObject)null);
        }
Esempio n. 16
0
 public static void Write(this GOSpawnEntry templ, TextWriter writer, string indent)
 {
     writer.WriteLine("{0}\tMap: {1}", indent, templ.MapId);
     writer.WriteLine("{0}\tState: {1}", indent, templ.State);
     if (templ.RespawnSeconds != 0)
     {
         writer.WriteLine("{0}\tRespawn: {1}", indent, templ.RespawnSeconds);
     }
     if (templ.DespawnSeconds != 0)
     {
         writer.WriteLine("{0}\tDespawn: {1}", indent, templ.DespawnSeconds);
     }
 }
Esempio n. 17
0
        public void FinalizeDataHolder()
        {
            if (!Asda2PortalMgr.Portals.ContainsKey((MapId)FromMap))
            {
                Asda2PortalMgr.Portals.Add((MapId)FromMap, new List <GOSpawnPoolTemplate>());
            }
            var pos     = new Vector3(FromX + 1000 * FromMap, FromY + 1000 * FromMap);
            var goEntry = new GOPortalEntry {
                GOCreator = GoCreator, GOId = GOEntryId.Portal
            };
            var goTempl = new GOSpawnEntry(goEntry, GameObjectState.Enabled, (MapId)FromMap,
                                           ref pos, 0, 1, new float[] { 0, 0, 0 });
            var templ = new GOSpawnPoolTemplate(goTempl, 1);

            Asda2PortalMgr.Portals[(MapId)FromMap].Add(templ);
        }
Esempio n. 18
0
        private static void DeSpawnEvent(WorldEvent worldEvent)
        {
            foreach (WorldEventNPC npcSpawn in worldEvent.NPCSpawns)
            {
                NPCSpawnEntry spawnEntry = NPCMgr.GetSpawnEntry(npcSpawn.Guid);
                Map           map        = spawnEntry.Map;
                if (map != null)
                {
                    if (npcSpawn.Spawn)
                    {
                        map.RemoveNPCSpawnPool(spawnEntry.PoolTemplate);
                    }
                    else
                    {
                        foreach (SpawnPoint <NPCSpawnPoolTemplate, NPCSpawnEntry, NPC, NPCSpawnPoint, NPCSpawnPool>
                                 spawnPoint in spawnEntry.SpawnPoints.ToArray())
                        {
                            spawnPoint.Respawn();
                        }
                    }
                }
            }

            foreach (WorldEventGameObject goSpawn in worldEvent.GOSpawns)
            {
                GOSpawnEntry spawnEntry = GOMgr.GetSpawnEntry(goSpawn.Guid);
                Map          map        = spawnEntry.Map;
                if (map != null)
                {
                    if (goSpawn.Spawn)
                    {
                        map.RemoveGOSpawnPool(spawnEntry.PoolTemplate);
                    }
                    else
                    {
                        foreach (SpawnPoint <GOSpawnPoolTemplate, GOSpawnEntry, GameObject, GOSpawnPoint, GOSpawnPool>
                                 spawnPoint in spawnEntry.SpawnPoints.ToArray())
                        {
                            spawnPoint.Respawn();
                        }
                    }
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Initialize the GO
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="templ"></param>
        internal virtual void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
        {
            EntityId = EntityId.GetGameObjectId((uint)Interlocked.Increment(ref _lastGOUID), entry.GOId);
            Type    |= ObjectTypes.GameObject;
            //DynamicFlagsLow = GameObjectDynamicFlagsLow.Activated;
            m_entry      = entry;
            m_spawnPoint = spawnPoint;

            DisplayId  = entry.DisplayId;
            EntryId    = entry.Id;
            GOType     = entry.Type;
            Flags      = m_entry.Flags;
            m_faction  = m_entry.Faction ?? Faction.NullFaction;
            ScaleX     = m_entry.Scale;
            GossipMenu = entry.DefaultGossip;

            if (QuestHolderInfo != null && GossipMenu == null)
            {
                // make sure, there is a GossipMenu that allows the player to start/finish quests
                GossipMenu = new GossipMenu();
            }

            spawnEntry = spawnEntry ?? entry.FirstSpawnEntry;
            if (spawnEntry != null)
            {
                Phase = spawnEntry.Phase;
                State = spawnEntry.State;
                if (spawnEntry.Scale != 1)
                {
                    ScaleX = spawnEntry.Scale;
                }
                Orientation       = spawnEntry.Orientation;
                AnimationProgress = spawnEntry.AnimProgress;
                SetRotationFields(spawnEntry.Rotations);
            }

            m_entry.InitGO(this);
        }
Esempio n. 20
0
        public static GOSpawnEntry GetClosestEntry(this ICollection <GOSpawnEntry> entries, IWorldLocation pos)
        {
            if (pos == null)
            {
                return(entries.First());
            }
            float        num1         = float.MaxValue;
            GOSpawnEntry goSpawnEntry = null;

            foreach (GOSpawnEntry entry in entries)
            {
                if (entry.MapId == pos.MapId && (int)entry.Phase == (int)pos.Phase)
                {
                    float num2 = pos.Position.DistanceSquared(entry.Position);
                    if (num2 < (double)num1)
                    {
                        num1         = num2;
                        goSpawnEntry = entry;
                    }
                }
            }

            return(goSpawnEntry);
        }
Esempio n. 21
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var go = entry.GOCreator();
			var handlerCreator = entry.HandlerCreator;
			go.Init(entry, spawnEntry, spawnPoint);
			if (handlerCreator != null)
			{
				go.Handler = handlerCreator();
			}
			else
			{
				log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
				go.Delete();
				return null;
			}
			go.Phase = where.Phase;
			var pos = where.Position;
			where.Map.AddObject(go, ref pos);
			return go;
		}
Esempio n. 22
0
		/// <summary>
		/// Initialize the GO
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="templ"></param>
		internal virtual void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
		{
			EntityId = EntityId.GetGameObjectId((uint)Interlocked.Increment(ref _lastGOUID), entry.GOId);
			Type |= ObjectTypes.GameObject;
			//DynamicFlagsLow = GameObjectDynamicFlagsLow.Activated;
			m_entry = entry;
			m_spawnPoint = spawnPoint;

			DisplayId = entry.DisplayId;
			EntryId = entry.Id;
			GOType = entry.Type;
			Flags = m_entry.Flags;
			m_faction = m_entry.Faction ?? Faction.NullFaction;
			ScaleX = m_entry.Scale;

			spawnEntry = spawnEntry ?? entry.FirstSpawnEntry;
			if (spawnEntry != null)
			{
				Phase = spawnEntry.Phase;
				State = spawnEntry.State;
				if (spawnEntry.Scale != 1)
				{
					ScaleX = spawnEntry.Scale;
				}
				Orientation = spawnEntry.Orientation;
				AnimationProgress = spawnEntry.AnimProgress;
				SetRotationFields(spawnEntry.Rotations);
			}

			m_entry.InitGO(this);
		}
Esempio n. 23
0
 public static GameObject Create(GOEntry entry, Map map, GOSpawnEntry spawnEntry = null,
                                 GOSpawnPoint spawnPoint = null)
 {
     return(Create(entry, new WorldLocation(map, Vector3.Zero, 1U), spawnEntry,
                   spawnPoint));
 }
Esempio n. 24
0
		/// <summary>
		/// Initialize the GO
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="templ"></param>
		internal virtual void Init(GOEntry entry, GOSpawnEntry spawnEntry, GOSpawnPoint spawnPoint)
		{
			EntityId = EntityId.GetGameObjectId((uint)Interlocked.Increment(ref _lastGOUID), entry.GOId);
			Type |= ObjectTypes.GameObject;
			//DynamicFlagsLow = GameObjectDynamicFlagsLow.Activated;
			m_entry = entry;
			m_spawnPoint = spawnPoint;

			DisplayId = entry.DisplayId;
			EntryId = entry.Id;
			GOType = entry.Type;
			Flags = m_entry.Flags;
			m_faction = m_entry.Faction ?? Faction.NullFaction;
			ScaleX = m_entry.Scale;
			GossipMenu = entry.DefaultGossip;

			if (QuestHolderInfo != null && GossipMenu == null)
			{
				// make sure, there is a GossipMenu that allows the player to start/finish quests
				GossipMenu = new GossipMenu();
			}

			spawnEntry = spawnEntry ?? entry.FirstSpawnEntry;
			if (spawnEntry != null)
			{
				Phase = spawnEntry.Phase;
				State = spawnEntry.State;
				if (spawnEntry.Scale != 1)
				{
					ScaleX = spawnEntry.Scale;
				}
				Orientation = spawnEntry.Orientation;
				AnimationProgress = spawnEntry.AnimProgress;
				SetRotationFields(spawnEntry.Rotations);
			}

			m_entry.InitGO(this);
		}
Esempio n. 25
0
		public static GameObject Create(GOEntry entry, Map map, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			return Create(entry, new WorldLocation(map, Vector3.Zero), spawnEntry, spawnPoint);
		}