public GameObject GetOwnedGO(GOEntryId id)
 {
     if (m_ownedGOs != null)
     {
         return(m_ownedGOs.Find(go => id == go.Entry.GOId));
     }
     return(null);
 }
Beispiel #2
0
        public static bool SpawnTransport(GOEntryId entryId)
        {
            TransportEntry entry;

            if (!TransportEntries.TryGetValue(entryId, out entry))
                return false;

            return true;
        }
Beispiel #3
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);
		}
Beispiel #4
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;
		}
Beispiel #5
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));
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public static bool SpawnTransport(GOEntryId entryId)
        {
            TransportEntry entry;

            if (!TransportEntries.TryGetValue(entryId, out entry))
            {
                return(false);
            }



            return(true);
        }
Beispiel #9
0
 public GOSpawnEntry(GOEntry entry, GameObjectState state, MapId mapId, ref Vector3 pos, float orientation,
                     float scale, float[] rotations, int respawnTimeSecs = 600)
 {
     Entry          = entry;
     EntryId        = entry.GOId;
     State          = state;
     MapId          = mapId;
     Position       = pos;
     Orientation    = orientation;
     Scale          = scale;
     Rotations      = rotations;
     RespawnSeconds = respawnTimeSecs;
 }
Beispiel #10
0
		public GOTemplate(GOEntry entry, GameObjectState state, 
			MapId mapId, ref Vector3 pos, float orientation, float scale, float[] rotations)
		{
			//Id = id;
			Entry = entry;
			EntryId = entry.GOId;
			State = state;
			MapId = mapId;
			Pos = pos;
			Orientation = orientation;
			Scale = scale;
			Rotations = rotations;
		}
Beispiel #11
0
 public GOSpawnEntry(GOEntry entry, GameObjectState state, MapId mapId, ref Vector3 pos, float orientation,
                     float scale, float[] rotations, int respawnTimeSecs = 600)
 {
     this.Entry          = entry;
     this.EntryId        = entry.GOId;
     this.State          = state;
     this.MapId          = mapId;
     this.Position       = pos;
     this.Orientation    = orientation;
     this.Scale          = scale;
     this.Rotations      = rotations;
     this.RespawnSeconds = respawnTimeSecs;
 }
 public void RemoveOwnedGO(GOEntryId goId)
 {
     if (m_ownedGOs != null)
     {
         foreach (var go in m_ownedGOs)
         {
             if ((GOEntryId)go.EntryId == goId)
             {
                 go.Delete();
                 return;
             }
         }
     }
 }
Beispiel #13
0
        public virtual void FinalizeDataHolder()
        {
            if (Id != 0U)
            {
                GOId = (GOEntryId)Id;
            }
            else
            {
                Id = (uint)GOId;
            }
            if (FactionId != FactionTemplateId.None)
            {
                Faction = FactionMgr.Get(FactionId);
            }
            InitEntry();
            if (GossipId != 0U && DefaultGossip == null)
            {
                if (GossipMgr.GetEntry(GossipId) == null)
                {
                    ContentMgr.OnInvalidDBData("GOEntry {0} has missing GossipId: {1}", (object)this,
                                               (object)GossipId);
                    DefaultGossip = new GossipMenu();
                }
                else
                {
                    DefaultGossip = new GossipMenu(GossipId);
                }
            }
            else if (QuestHolderInfo != null)
            {
                DefaultGossip = new GossipMenu();
            }

            if (HandlerCreator == null)
            {
                HandlerCreator = GOMgr.Handlers[(int)Type];
            }
            if (GOCreator == null)
            {
                GOCreator = !IsTransport
          ? () => new GameObject()
          : (Func <GameObject>)(() => (GameObject) new Transport());
            }
            if (Fields == null)
            {
                return;
            }
            GOMgr.Entries[Id] = this;
        }
Beispiel #14
0
        public static GameObject GetNearbyGO <O>(this O wObj, GOEntryId id, float radius) where O : WorldObject
        {
            GameObject go = (GameObject)null;

            wObj.IterateEnvironment(radius, (Func <WorldObject, bool>)(obj =>
            {
                if (!wObj.CanSee(obj) || !(obj is GameObject) || ((GameObject)obj).Entry.GOId != id)
                {
                    return(true);
                }
                go = (GameObject)obj;
                return(false);
            }));
            return(go);
        }
Beispiel #15
0
        public static GameObject GetNearbyGO <O>(this O wObj, GOEntryId id, float radius) where O : WorldObject
        {
            GameObject go = null;

            wObj.IterateEnvironment(radius, obj =>
            {
                if (wObj.CanSee(obj) && obj is GameObject && ((GameObject)obj).Entry.GOId == id)
                {
                    go = (GameObject)obj;
                    return(false);
                }
                return(true);
            });
            return(go);
        }
 public bool OwnsGo(GOEntryId goId)
 {
     if (m_ownedGOs == null)
     {
         return(false);
     }
     foreach (var go in m_ownedGOs)
     {
         if (go.Entry.GOId == goId)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #17
0
        public static GOEntry GetEntry(GOEntryId id, bool force = true)
        {
            if (!loaded && force)
            {
                log.Warn("Tried to get GOEntry but GOs are not loaded: {0}", id);
                return(null);
            }

            GOEntry goEntry;

            if (!Entries.TryGetValue((uint)id, out goEntry) && force)
            {
                throw new ContentException("Tried to get non-existing GOEntry: {0}", (object)id);
            }
            return(goEntry);
        }
Beispiel #18
0
		public static GOEntry GetEntry(GOEntryId id, bool force = true)
		{
			if (!loaded && force)
			{
				log.Warn("Tried to get GOEntry but GOs are not loaded: {0}", id);
				return null;
			}
			GOEntry entry;
			if (!Entries.TryGetValue((uint)id, out entry))
			{
				if (force)
				{
					throw new ContentException("Tried to get non-existing GOEntry: {0}", id);
				}
			}
			return entry;
		}
Beispiel #19
0
		public static GOEntry GetEntry(GOEntryId id)
		{
			if (!loaded)
			{
				log.Warn("Tried to get GOEntry but GOs are not loaded: {0}", id);
				return null;
			}
			GOEntry entry;
			if (!Entries.TryGetValue((uint)id, out entry))
			{
				if (ContentMgr.ForceDataPresence)
				{
					throw new ContentException("Tried to get GOEntry but GOs are not loaded: {0}", id);
				}
			}
			return entry;
		}
Beispiel #20
0
#pragma warning restore 0649

        #endregion

        protected WSGFaction(WarsongGulch instance,
                             SpellId flagSpell,
                             SpellId flagDropSpell,
                             SpellId flagDropDebuff,
                             SpellId flagCarrierDebuffSpellId,
                             GOEntryId flagStand,
                             GOEntryId flagDropId)
        {
            Instance                = instance;
            _flagSpell              = SpellHandler.Get(flagSpell);
            _flagDropSpell          = SpellHandler.Get(flagDropSpell);
            _flagDropDebuff         = SpellHandler.Get(flagDropDebuff);
            _flagCarrierDebuffSpell = SpellHandler.Get(flagCarrierDebuffSpellId);
            FlagStandEntry          = GOMgr.GetEntry(flagStand);
            DroppedFlagEntry        = GOMgr.GetEntry(flagDropId);

            _flagRespawnTime = WarsongGulch.FlagRespawnTimeMillis;
            Score            = 0;
        }
Beispiel #21
0
#pragma warning restore 0649

		#endregion

		protected WSGFaction(WarsongGulch instance,
			SpellId flagSpell,
			SpellId flagDropSpell,
			SpellId flagDropDebuff,
			SpellId flagCarrierDebuffSpellId,
			GOEntryId flagStand,
			GOEntryId flagDropId)
		{
			Instance = instance;
			_flagSpell = SpellHandler.Get(flagSpell);
			_flagDropSpell = SpellHandler.Get(flagDropSpell);
			_flagDropDebuff = SpellHandler.Get(flagDropDebuff);
			_flagCarrierDebuffSpell = SpellHandler.Get(flagCarrierDebuffSpellId);
			FlagStandEntry = GOMgr.GetEntry(flagStand);
			DroppedFlagEntry = GOMgr.GetEntry(flagDropId);

			_flagRespawn = WarsongGulch.FlagRespawnTime;
			Score = 0;
		}
Beispiel #22
0
        /// <summary>Finalize this GOSpawnEntry</summary>
        /// <param name="addToPool">If set to false, will not try to add it to any pool (recommended for custom GOSpawnEntry that share a pool)</param>
        public override void FinalizeDataHolder(bool addToPool)
        {
            if (Entry == null)
            {
                Entry = GOMgr.GetEntry(EntryId, false);
                if (Entry == null)
                {
                    ContentMgr.OnInvalidDBData("{0} had an invalid EntryId.", (object)this);
                    return;
                }
            }

            if (Scale == 0.0)
            {
                Scale = 1f;
            }
            if (EntryId == GOEntryId.Loot)
            {
                EntryId = (GOEntryId)EntryIdRaw;
            }
            else
            {
                EntryIdRaw = (uint)EntryId;
            }
            if (Rotations == null)
            {
                Rotations = new float[4];
            }
            base.FinalizeDataHolder(addToPool);
            if (MapId == MapId.End || MapId == MapId.None)
            {
                return;
            }
            Entry.SpawnEntries.Add(this);
            ArrayUtil.Set(ref GOMgr.SpawnEntries, SpawnId, this);
            if (!addToPool)
            {
                return;
            }
            AddToPoolTemplate();
        }
Beispiel #23
0
        public override void Apply()
        {
            GOEntryId miscValue  = (GOEntryId)Effect.MiscValue;
            GOEntry   entry      = GOMgr.GetEntry(miscValue, true);
            Unit      casterUnit = m_cast.CasterUnit;

            if (entry != null)
            {
                GO             = entry.Spawn(casterUnit, casterUnit);
                GO.State       = GameObjectState.Enabled;
                GO.Orientation = casterUnit.Orientation;
                GO.ScaleX      = 1f;
                GO.Faction     = casterUnit.Faction;
                GO.CreatedBy   = casterUnit.EntityId;
                if (GO.Handler is SummoningRitualHandler)
                {
                    ((SummoningRitualHandler)GO.Handler).Target = firstTarget;
                }
                if (m_cast.IsChanneling)
                {
                    m_cast.CasterUnit.ChannelObject = GO;
                }
                else
                {
                    if (Effect.Spell.Durations.Min <= 0)
                    {
                        return;
                    }
                    GO.RemainingDecayDelayMillis = Effect.Spell.Durations.Random();
                }
            }
            else
            {
                log.Error("Summoning Spell {0} refers to invalid Object: {1} ({2})",
                          Effect.Spell, miscValue, miscValue);
            }
        }
Beispiel #24
0
        public override void Apply()
        {
            GOEntryId miscValue  = (GOEntryId)this.Effect.MiscValue;
            GOEntry   entry      = GOMgr.GetEntry(miscValue, true);
            Unit      casterUnit = this.m_cast.CasterUnit;

            if (entry != null)
            {
                this.GO             = entry.Spawn((IWorldLocation)casterUnit, casterUnit);
                this.GO.State       = GameObjectState.Enabled;
                this.GO.Orientation = casterUnit.Orientation;
                this.GO.ScaleX      = 1f;
                this.GO.Faction     = casterUnit.Faction;
                this.GO.CreatedBy   = casterUnit.EntityId;
                if (this.GO.Handler is SummoningRitualHandler)
                {
                    ((SummoningRitualHandler)this.GO.Handler).Target = this.firstTarget;
                }
                if (this.m_cast.IsChanneling)
                {
                    this.m_cast.CasterUnit.ChannelObject = (WorldObject)this.GO;
                }
                else
                {
                    if (this.Effect.Spell.Durations.Min <= 0)
                    {
                        return;
                    }
                    this.GO.RemainingDecayDelayMillis = this.Effect.Spell.Durations.Random();
                }
            }
            else
            {
                SummonObjectEffectHandler.log.Error("Summoning Spell {0} refers to invalid Object: {1} ({2})",
                                                    (object)this.Effect.Spell, (object)miscValue, (object)miscValue);
            }
        }
Beispiel #25
0
        public static bool SpawnTransport(GOEntryId entryId)
        {
            TransportEntry transportEntry;

            return(TransportMgr.TransportEntries.TryGetValue(entryId, out transportEntry));
        }
Beispiel #26
0
		public void FinalizeDataHolder()
		{
			if (Scale == 0)
			{
				Scale = 1;
			}
			if (EntryId == 0)
			{
				EntryId = (GOEntryId)EntryIdRaw;
			}
			else
			{
				EntryIdRaw = (uint)EntryId;
			}
			if (Entry == null)
			{
				GOMgr.Entries.TryGetValue((uint)EntryId, out Entry);
				if (Entry == null)
				{
					ContentHandler.OnInvalidDBData("GOTemplate ({0}) had an invalid EntryId.", this);
					return;
				}
			}
			if (Rotations == null)
			{
				Rotations = new float[GOConstants.MaxRotations];
			}

			Entry.Templates.Add(this);
			//GOMgr.Templates.Add(Id, this);
		}
Beispiel #27
0
 public static string ToString(this GOEntryId id)
 {
     return(((int)id) + "(Id: " + (int)id + ")");
 }
Beispiel #28
0
		/// <summary>
		/// The Quest that requires the given GO to be used
		/// </summary>
		public Quest GetReqObjectQuest(GOEntryId npc)
		{
			for (var j = 0; j < m_RequireItemsQuests.Count; j++)
			{
				var quest = m_RequireItemsQuests[j];
				for (var i = 0; i < quest.Template.CollectableItems.Length; i++)
				{
					var interaction = quest.Template.GOInteractions[i];
					if (interaction.TemplateId == (uint)npc)
					{
						return quest;
					}
				}
			}
			return null;
		}
Beispiel #29
0
		public virtual void FinalizeDataHolder()
		{
			if (Id != 0)
			{
				GOId = (GOEntryId)Id;
			}
			else
			{
				Id = (uint)GOId;
			}

			if (FactionId != 0)
			{
				Faction = FactionMgr.Get(FactionId);
			}

			InitEntry();

			if (HandlerCreator == null)
			{
				HandlerCreator = GOMgr.Handlers[(int)Type];
			}

			if (GOCreator == null)
			{
				if (IsTransport)
				{
					GOCreator = () => new Transport();
				}
				else
				{
					GOCreator = () => new GameObject();
				}
			}

			if (Fields != null)		// ignore invalid ones
			{
				//Fields = null;
				GOMgr.Entries[Id] = this;
			}
		}
Beispiel #30
0
		public virtual void FinalizeDataHolder()
		{
			if (Id != 0)
			{
				GOId = (GOEntryId)Id;
			}
			else
			{
				Id = (uint)GOId;
			}

			if (FactionId != 0)
			{
				Faction = FactionMgr.Get(FactionId);
			}

			InitEntry();

			// create GossipMenu
			if (GossipId != 0 && DefaultGossip == null)
			{
				var gossipEntry = GossipMgr.GetEntry(GossipId);
				if (gossipEntry == null)
				{
					ContentMgr.OnInvalidDBData("GOEntry {0} has missing GossipId: {1}", this, GossipId);
					DefaultGossip = new GossipMenu();
				}
				else
				{
					DefaultGossip = new GossipMenu(GossipId);
				}
			}
			else if (QuestHolderInfo != null)
			{
				// Make sure, there is a gossip menu, so quests can be started/completed
				DefaultGossip = new GossipMenu();
			}

			// set HandlerCreator
			if (HandlerCreator == null)
			{
				HandlerCreator = GOMgr.Handlers[(int)Type];
			}

			if (GOCreator == null)
			{
				if (IsTransport)
				{
					GOCreator = () => new Transport();
				}
				else
				{
					GOCreator = () => new GameObject();
				}
			}

			if (Fields != null)		// ignore invalid ones
			{
				//Fields = null;
				GOMgr.Entries[Id] = this;
			}
		}
Beispiel #31
0
 public static EntityId GetGameObjectId(uint low, GOEntryId entry)
 {
     return(new EntityId(low, (uint)entry, HighId.GameObject));
 }
Beispiel #32
0
        public virtual void FinalizeDataHolder()
        {
            if (Id != 0)
            {
                GOId = (GOEntryId)Id;
            }
            else
            {
                Id = (uint)GOId;
            }

            if (FactionId != 0)
            {
                Faction = FactionMgr.Get(FactionId);
            }

            InitEntry();

            // create GossipMenu
            if (GossipId != 0 && DefaultGossip == null)
            {
                var gossipEntry = GossipMgr.GetEntry(GossipId);
                if (gossipEntry == null)
                {
                    ContentMgr.OnInvalidDBData("GOEntry {0} has missing GossipId: {1}", this, GossipId);
                    DefaultGossip = new GossipMenu();
                }
                else
                {
                    DefaultGossip = new GossipMenu(GossipId);
                }
            }
            else if (QuestHolderInfo != null)
            {
                // Make sure, there is a gossip menu, so quests can be started/completed
                DefaultGossip = new GossipMenu();
            }

            // set HandlerCreator
            if (HandlerCreator == null)
            {
                HandlerCreator = GOMgr.Handlers[(int)Type];
            }

            if (GOCreator == null)
            {
                if (IsTransport)
                {
                    GOCreator = () => new Transport();
                }
                else
                {
                    GOCreator = () => new GameObject();
                }
            }

            if (Fields != null)                         // ignore invalid ones
            {
                //Fields = null;
                GOMgr.Entries[Id] = this;
            }
        }
Beispiel #33
0
        /// <summary>
        /// Finalize this GOSpawnEntry
        /// </summary>
        /// <param name="addToPool">If set to false, will not try to add it to any pool (recommended for custom GOSpawnEntry that share a pool)</param>
        public override void FinalizeDataHolder(bool addToPool)
        {
            // get Entry
            if (Entry == null)
            {
                Entry = GOMgr.GetEntry(EntryId, false);
                if (Entry == null)
                {
                    ContentMgr.OnInvalidDBData("{0} had an invalid EntryId.", this);
                    return;
                }
            }

            // fix data inconsistencies
            if (Scale == 0)
            {
                Scale = 1;
            }

            if (EntryId == 0)
            {
                EntryId = (GOEntryId)EntryIdRaw;
            }
            else
            {
                EntryIdRaw = (uint)EntryId;
            }

            if (Rotations == null)
            {
                Rotations = new float[GOConstants.MaxRotations];
            }

            //GOMgr.Templates.Add(Id, this);

            // do the default thing
            base.FinalizeDataHolder(addToPool);

            if (MapId != MapId.End)
            {
                // valid map
                Entry.SpawnEntries.Add(this);

                // add to list of GOSpawnEntries
                ArrayUtil.Set(ref GOMgr.SpawnEntries, SpawnId, this);

                if (addToPool)
                {
                    // add to pool
                    AddToPoolTemplate();
                }
            }

            // Is this GO associated with an event
            if (_eventId != 0)
            {
                // The event id loaded can be negative if this
                // entry is expected to despawn during an event
                var eventId = (uint)Math.Abs(_eventId);

                //Check if the event is valid
                var worldEvent = WorldEventMgr.GetEvent(eventId);
                if (worldEvent != null)
                {
                    // Add this GO to the list of related spawns
                    // for the given world event
                    var eventGO = new WorldEventGameObject()
                    {
                        _eventId = _eventId, EventId = eventId, Guid = SpawnId, Spawn = _eventId > 0
                    };

                    worldEvent.GOSpawns.Add(eventGO);
                }
                EventId = eventId;
            }
        }
Beispiel #34
0
		/// <summary>
		/// Creates the given kind of GameObject with the default Template
		/// </summary>
		public static GameObject Create(GOEntryId id)
		{
			var entry = GOMgr.GetEntry(id);
			if (entry == null)
			{
				return null;
			}
			return Create(entry, entry.Templates.Count > 0 ? entry.Templates[0] : null);
		}
Beispiel #35
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntryId id, GOTemplate templ)
		{
			var entry = GOMgr.GetEntry(id);
			if (entry != null)
			{
				return Create(entry, templ);
			}
			return null;
		}
Beispiel #36
0
        protected AVFaction(AlteracValley instance, GOEntryId flagEntry)
        {
            Instance = instance;

        }
Beispiel #37
0
 protected AVFaction(AlteracValley instance, GOEntryId flagEntry)
 {
     Instance = instance;
 }
Beispiel #38
0
 public static GameObject GetNearbyGO <O>(this O wObj, GOEntryId id) where O : WorldObject
 {
     return(wObj.GetNearbyGO(id, WorldObject.BroadcastRange));
 }