Example #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)
        {
            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);
        }
Example #2
0
		private void HandlePowerUp(Unit unit, SpellId spell, GameObject go, Action respawnCallback)
		{
			if (go != null && !go.IsDeleted)
			{
				if (spell != 0)
				{
					unit.SpellCast.TriggerSelf(spell);
				}
				go.Delete();
				CallDelayed(PowerUpRespawnTimeMillis, respawnCallback);
			}
		}