Ejemplo n.º 1
0
        public void Serialize(GenericWriter writer)
        {
            writer.Write(SpawnedObjects.Count);

            for (int i = 0; i < SpawnedObjects.Count; i++)
            {
                ISpawnable spawn = SpawnedObjects[i];

                int serial = spawn.Serial;

                writer.Write(serial);
            }

            writer.Write(Running);

            if (m_SpawnTimer != null)
            {
                writer.Write(true);
                writer.WriteDeltaTime(m_NextSpawn);
            }
            else
            {
                writer.Write(false);
            }
        }
Ejemplo n.º 2
0
        public void RemoveSpawns()
        {
            Defrag();

            for (int i = 0; i < m_Entries.Count; i++)
            {
                SpawnerEntry entry = m_Entries[i];

                for (int j = entry.Spawned.Count - 1; j >= 0; j--)
                {
                    ISpawnable e = entry.Spawned[j];

                    if (e != null)
                    {
                        m_Spawned.Remove(e);
                        entry.Spawned.RemoveAt(j);
                        e.Delete();
                    }
                }
            }

            if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running)
            {
                DoTimer();
            }

            InvalidateProperties();
        }
Ejemplo n.º 3
0
    void Awake()
    {
        GameObject g  = Instantiate(Spawn, transform.position, Quaternion.identity);
        ISpawnable sp = g.GetComponent(typeof(ISpawnable)) as ISpawnable;

        sp.spawn(gameObject);
    }
Ejemplo n.º 4
0
        public void Serialize(GenericWriter writer)
        {
            writer.Write(0);

            writer.Write(SpawnedObjects.Count);
            for (var index = 0; index < SpawnedObjects.Count; index++)
            {
                ISpawnable sp = SpawnedObjects[index];
                if (sp is Item item)
                {
                    writer.Write(item);
                }
                else if (sp is Mobile mobile)
                {
                    writer.Write(mobile);
                }
                else
                {
                    writer.Write(Serial.MinusOne);
                }
            }

            writer.Write(SpawnName);
            writer.Write(MaxCount);
        }
Ejemplo n.º 5
0
 public void Replace(ISpawnable oldEntity, ISpawnable newEntity)
 {
     if (m_State == SpawnState.Active)
     {
         m_Spawned = newEntity;
     }
 }
Ejemplo n.º 6
0
            public void Remove(ISpawnable spawnable)
            {
                /* In this implementation we can ignore the argument since we
                * already know it. This is more like a signal function so. */

                m_Spawned = null;

                if (m_DeactivateOnRemove)
                {
                    m_State = SpawnState.Inactive;
                }
                else
                {
                    m_State = SpawnState.Respawning;

                    TimeSpan respawnDelay = GetRespawnDelay();

                    m_NextSpawn = DateTime.UtcNow + respawnDelay;

                    m_Timer = Timer.DelayCall(respawnDelay, Respawn);
                    m_Timer.Start();
                }

                m_Owner.OnEntityRemoved(spawnable);
            }
Ejemplo n.º 7
0
    private void SpawnEnemy()
    {
        GameObject newSpawnObj = ObjectPool.Instance.GetObject(spawnType.ToPoolObject());

        if (newSpawnObj)
        {
            newSpawnObj.transform.position = ActualSpawnPos;
            ISpawnable spawnable = newSpawnObj.GetComponentInChildren <ISpawnable>();
            if (!spawnable.HasWillBeenWritten())
            {
                spawnable.RegisterDeathEvent(ReportDeath);
            }

            EnemyBase enemyBase = newSpawnObj.GetComponent <EnemyBase>();

            if (enemyBase)
            {
                enemyBase.SpawnWithRagdoll(ActualSpawnPos);
            }

            EventSystem.Instance.TriggerEvent(Strings.Events.ENEMY_SPAWNED, newSpawnObj);
        }
        else
        {
            OnEnemyDeath();
            Debug.LogFormat("<color=#ffff00>" + "NOT ENOUGH SPAWN-OBJECTS for: " + spawnType + "</color>");
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 1회 Spawn 수행.
    /// </summary>
    public override void Start()
    {
        var pool = PoolManager.GetOrCreate(PrefabName);

        Vector3    position = SpawnPosition;
        Quaternion rotation = SpawnRotation;

        if (RelativeToOwner)
        {
            position += owner.transform.position;
            rotation *= owner.transform.rotation;
        }

        //풀에서 ISpawnable 객체를 가져온다.
        asPooledObject  = pool.Instantiate(position, rotation);
        asSpawnedObject = asPooledObject.gameObject.GetComponent <FieldObject>() as ISpawnable;

        if (asSpawnedObject == null)
        {
            Debug.LogError("ISpawnable을 구현하지 않은 FieldObject는 Spawn할 수 없습니다 ");
            pool.Dispose(asPooledObject);

            asPooledObject = null;
            return;
        }

        asSpawnedObject.SpawnOwner = owner;
        asSpawnedObject.OnSpawn(owner);

        IsActive = true;
    }
Ejemplo n.º 9
0
 void ISpawner.Remove(ISpawnable spawn)
 {
     if (_Spawn != null)
     {
         _Spawn.Remove(spawn);
     }
 }
Ejemplo n.º 10
0
 public void Remove(ISpawnable spawn)
 {
     if (spawn is AncientClayVase vase)
     {
         RemoveVase(vase);
     }
 }
Ejemplo n.º 11
0
        public void Serialize(GenericWriter writer)
        {
            writer.Write((int)this.m_SpawnedObjects.Count);

            for (int i = 0; i < this.m_SpawnedObjects.Count; i++)
            {
                ISpawnable spawn = this.m_SpawnedObjects[i];

                int serial = spawn.Serial;

                writer.Write((int)serial);
            }

            writer.Write((bool)this.m_Running);

            if (this.m_SpawnTimer != null)
            {
                writer.Write(true);
                writer.WriteDeltaTime((DateTime)this.m_NextSpawn);
            }
            else
            {
                writer.Write(false);
            }
        }
Ejemplo n.º 12
0
        public void Deserialize(GenericReader reader, int version)
        {
            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int        serial          = reader.ReadInt();
                ISpawnable spawnableEntity = World.FindEntity(serial) as ISpawnable;

                if (spawnableEntity != null)
                {
                    this.Add(spawnableEntity);
                }
            }

            this.m_Running = reader.ReadBool();

            if (reader.ReadBool())
            {
                this.m_NextSpawn = reader.ReadDeltaTime();

                if (this.Spawning)
                {
                    if (this.m_SpawnTimer != null)
                    {
                        this.m_SpawnTimer.Stop();
                    }

                    TimeSpan delay = this.m_NextSpawn - DateTime.UtcNow;
                    this.m_SpawnTimer = Timer.DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, new TimerCallback(TimerCallback));
                }
            }

            this.CheckTimer();
        }
Ejemplo n.º 13
0
 public void Remove(ISpawnable spawn)
 {
     if (spawn is KhaldunChest chest)
     {
         RemoveChest(chest);
     }
 }
Ejemplo n.º 14
0
 public static void Spawn(ISpawnable ObjectToSpawn)
 {
     if (instance == null)
     {
         Debug.LogError("Trying to access a null spawn pool");
     }
 }
Ejemplo n.º 15
0
        public virtual Point3D GetSpawnPosition(ISpawnable spawned)
        {
            Map map = Map;

            if (map == null || map == Map.Internal)
            {
                return(Location);
            }

            bool waterMob, waterOnlyMob;

            if (spawned is Mobile)
            {
                Mobile mob = (Mobile)spawned;

                waterMob     = mob.CanSwim;
                waterOnlyMob = (mob.CanSwim && mob.CantWalk);
            }
            else
            {
                waterMob     = false;
                waterOnlyMob = false;
            }

            // Try 10 times to find a Spawnable location.
            for (int i = 0; i < 10; i++)
            {
                int x = Location.X + (Utility.Random((m_HomeRange * 2) + 1) - m_HomeRange);
                int y = Location.Y + (Utility.Random((m_HomeRange * 2) + 1) - m_HomeRange);
                int z = Map.GetAverageZ(x, y);

                int mapZ = map.GetAverageZ(x, y);

                if (waterMob)
                {
                    if (Server.Mobiles.Spawner.IsValidWater(map, x, y, this.Z))
                    {
                        return(new Point3D(x, y, this.Z));
                    }
                    else if (Server.Mobiles.Spawner.IsValidWater(map, x, y, mapZ))
                    {
                        return(new Point3D(x, y, mapZ));
                    }
                }

                if (!waterOnlyMob)
                {
                    if (map.CanSpawnMobile(x, y, this.Z))
                    {
                        return(new Point3D(x, y, this.Z));
                    }
                    else if (map.CanSpawnMobile(x, y, mapZ))
                    {
                        return(new Point3D(x, y, mapZ));
                    }
                }
            }

            return(this.Location);
        }
Ejemplo n.º 16
0
    IEnumerator SpawnCheeseAway(GameObject spawn)
    {
        yield return(new WaitForSeconds(Random.Range(0.5f, 1f)));

        float altCheese = Random.Range(1.8f, -2.5f);

        float max = spawn.transform.position.y - 0.8f;

        float min = spawn.transform.position.y + 0.8f;

        if (max > 1.5f)
        {
            max = 1.8f;
        }

        if (min < -2.4f)
        {
            min = -2.4f;
        }

        ISpawnable iPreFab = (ISpawnable)prefabCheese.GetComponent(typeof(ISpawnable));

        iPreFab.setMovSpeed(movBallon);

        Instantiate(iPreFab.getPreFab(), new Vector3(spawn.transform.position.x + (DisInstance / 2), altCheese, 0), Quaternion.identity);
    }
Ejemplo n.º 17
0
 public Session(ISpawnable spawnable, string line_terminator)
 {
     _spawnable     = spawnable;
     LineTerminator = line_terminator;
     Expect         = new ExpectCommands(this);
     Send           = new SendCommands(this);
 }
Ejemplo n.º 18
0
        public void Spawn(int index)
        {
            Map map = Map;

            if (map == null || map == Map.Internal || SpawnNamesCount == 0 || index >= SpawnNamesCount || Parent != null)
            {
                return;
            }

            Defrag();

            if (CheckSpawnerFull())
            {
                return;
            }

            ISpawnable spawned = CreateSpawnedObject(index);

            if (spawned == null)
            {
                return;
            }

            spawned.Spawner = this;
            m_Spawned.Add(spawned);

            Point3D loc = (spawned is BaseVendor ? this.Location : GetSpawnPosition(spawned));

            spawned.OnBeforeSpawn(loc, map);
            spawned.MoveToWorld(loc, map);
            spawned.OnAfterSpawn();

            if (spawned is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)spawned;

                if (m_WalkingRange >= 0)
                {
                    bc.RangeHome = m_WalkingRange;
                }
                else
                {
                    bc.RangeHome = m_HomeRange;
                }

                bc.CurrentWayPoint = m_WayPoint;

                bc.SeeksHome = m_MobilesSeekHome;

                if (m_Team > 0)
                {
                    bc.Team = m_Team;
                }

                bc.Home = (m_UsesSpawnerHome) ? this.HomeLocation : bc.Location;
            }

            InvalidateProperties();
        }
Ejemplo n.º 19
0
 public Session(ISpawnable spawnable, string line_terminator, CancellationToken ct)
 {
     _spawnable     = spawnable;
     LineTerminator = line_terminator;
     Expect         = new ExpectCommands(this);
     Send           = new SendCommands(this);
     Ct             = ct;
 }
        private static void CheckForISpawnable(GameObject obj, SpawnAreaName areaName, string objectTag)
        {
            ISpawnable pooledObject = obj.GetComponent <ISpawnable>();

            pooledObject?.SetEnemySpawnName(objectTag);
            // TODO: Revisar si se necesita eventualmente
            pooledObject?.SetSpawnArea(areaName);
        }
Ejemplo n.º 21
0
    public void doSpawn(GameObject preFab)
    {
        GameObject spawn = preFab;

        ISpawnable iPreFab = (ISpawnable)preFab.GetComponent(typeof(ISpawnable));

        criaInstancia(iPreFab, spawn);
    }
Ejemplo n.º 22
0
 public BoomerangFlyingProjectile(SpriteBatch spriteBatch, Point spawnPosition, Constants.ProjectileOwner owner, ISpawnable itemToTrack, Vector2 velocity) : base(spriteBatch, spawnPosition, owner)
 {
     sprite           = ProjectileSpriteFactory.Instance.CreateBoomerangFlyingSprite();
     Velocity         = velocity;
     returningToOwner = false;
     this.itemToTrack = itemToTrack;
     projectileType   = LinkConstants.ProjectileType.Boomerang;
 }
 private void DrawList <T>(List <T> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         ISpawnable spawnable = (ISpawnable)list[i];
         spawnable.Draw();
     }
 }
Ejemplo n.º 24
0
        public void Remove(ISpawnable spawn)
        {
            var chest = spawn as KhaldunChest;

            if (chest != null)
            {
                RemoveChest(chest);
            }
        }
Ejemplo n.º 25
0
 public void Spawn(ISpawnable s)
 {
     if (spawned.Count < maxSpawns)
     {
         float x = transform.position.x + (2 * Random.Range(0, radius) - radius);
         float z = transform.position.z + (2 * Random.Range(0, radius) - radius);
         spawned.Add(s.Spawn(x, z));
     }
 }
Ejemplo n.º 26
0
        public void Spawn(int index)
        {
            Map map = this.Map;

            if (map == null || map == Map.Internal || this.SpawnNamesCount == 0 || index >= this.SpawnNamesCount || this.Parent != null)
            {
                return;
            }

            this.Defrag();

            if (this.CheckSpawnerFull())
            {
                return;
            }

            ISpawnable spawned = this.CreateSpawnedObject(index);

            if (spawned == null)
            {
                return;
            }

            spawned.Spawner = this;
            this.m_Spawned.Add(spawned);

            Point3D loc = (spawned is BaseVendor ? this.Location : this.GetSpawnPosition(spawned));

            spawned.OnBeforeSpawn(loc, map);

            this.InvalidateProperties();

            spawned.MoveToWorld(loc, map);

            if (spawned is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)spawned;

                if (this.m_WalkingRange >= 0)
                {
                    bc.RangeHome = this.m_WalkingRange;
                }
                else
                {
                    bc.RangeHome = this.m_HomeRange;
                }

                bc.CurrentWayPoint = this.m_WayPoint;

                if (this.m_Team > 0)
                {
                    bc.Team = this.m_Team;
                }

                bc.Home = this.HomeLocation;
            }
        }
Ejemplo n.º 27
0
        public void RemoveSpawn(ISpawnable e)
        {
            SpawnObject so = m_SpawnObjects.FirstOrDefault(s => s.SpawnedObjects.Contains(e));

            if (so != null)
            {
                so.SpawnedObjects.Remove(e);
            }
        }
Ejemplo n.º 28
0
        /*
         * public override bool OnDefragSpawn(ISpawnable spawned, bool remove)
         * {
         * // To despawn a mob that was lured 4x away from its spawner
         * // TODO: Move this to a config
         * if (spawned is BaseCreature c && c.Combatant == null && c.GetDistanceToSqrt( Location ) > c.RangeHome * 4)
         * {
         *  c.Delete();
         *  remove = true;
         * }
         *
         * return base.OnDefragSpawn(entry, spawned, remove);
         * }
         */

        public override Point3D GetSpawnPosition(ISpawnable spawned, Map map)
        {
            if (map == null || map == Map.Internal)
            {
                return(Location);
            }

            bool waterMob, waterOnlyMob;

            if (spawned is Mobile mob)
            {
                waterMob     = mob.CanSwim;
                waterOnlyMob = mob.CanSwim && mob.CantWalk;
            }
            else
            {
                waterMob     = false;
                waterOnlyMob = false;
            }

            // Try 10 times to find a valid location.
            for (var i = 0; i < 10; i++)
            {
                var x = Location.X + (Utility.Random(HomeRange * 2 + 1) - HomeRange);
                var y = Location.Y + (Utility.Random(HomeRange * 2 + 1) - HomeRange);

                var mapZ = map.GetAverageZ(x, y);

                if (waterMob)
                {
                    if (IsValidWater(map, x, y, Z))
                    {
                        return(new Point3D(x, y, Z));
                    }

                    if (IsValidWater(map, x, y, mapZ))
                    {
                        return(new Point3D(x, y, mapZ));
                    }
                }

                if (!waterOnlyMob)
                {
                    if (map.CanSpawnMobile(x, y, Z))
                    {
                        return(new Point3D(x, y, Z));
                    }

                    if (map.CanSpawnMobile(x, y, mapZ))
                    {
                        return(new Point3D(x, y, mapZ));
                    }
                }
            }

            return(HomeLocation);
        }
Ejemplo n.º 29
0
        public void Spawn(SpawnObject so)
        {
            Map map = Map;

            if (map == null || map == Map.Internal || SpawnObjectCount == 0 || so == null || Parent != null || GetSpawnCount(so) >= so.MaxCount)
            {
                return;
            }

            Defrag();

            if (CheckSpawnerFull())
            {
                return;
            }

            ISpawnable spawned = CreateSpawnedObject(so);

            if (spawned == null)
            {
                return;
            }

            spawned.Spawner = this;
            so.SpawnedObjects.Add(spawned);

            Point3D loc = (spawned is BaseVendor ? Location : GetSpawnPosition(spawned));

            spawned.OnBeforeSpawn(loc, map);

            InvalidateProperties();

            spawned.MoveToWorld(loc, map);

            if (spawned is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)spawned;

                if (m_WalkingRange >= 0)
                {
                    bc.RangeHome = m_WalkingRange;
                }
                else
                {
                    bc.RangeHome = m_HomeRange;
                }

                bc.CurrentWayPoint = m_WayPoint;

                if (m_Team > 0)
                {
                    bc.Team = m_Team;
                }

                bc.Home = HomeLocation;
            }
        }
Ejemplo n.º 30
0
        private void Spawn()
        {
            ISpawnable spawn = this.m_Definition.Spawn(this);

            if (spawn != null)
            {
                this.Add(spawn);
            }
        }
Ejemplo n.º 31
0
		public virtual Point3D GetSpawnPosition( ISpawnable spawned )
		{
			Map map = Map;

			if ( map == null || map == Map.Internal )
				return Location;

			bool waterMob, waterOnlyMob;

			if ( spawned is Mobile )
			{
				Mobile mob = (Mobile)spawned;

				waterMob = mob.CanSwim;
				waterOnlyMob = ( mob.CanSwim && mob.CantWalk );
			}
			else
			{
				waterMob = false;
				waterOnlyMob = false;
			}

			// Try 10 times to find a Spawnable location.
			for ( int i = 0; i < 10; i++ )
			{
				int x = Location.X + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange);
				int y = Location.Y + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange);
				int z = Map.GetAverageZ( x, y );

				int mapZ = map.GetAverageZ( x, y );

				if ( waterMob )
				{
					if ( Server.Mobiles.Spawner.IsValidWater( map, x, y, this.Z ) )
						return new Point3D( x, y, this.Z );
					else if ( Server.Mobiles.Spawner.IsValidWater( map, x, y, mapZ ) )
						return new Point3D( x, y, mapZ );
				}

				if ( !waterOnlyMob )
				{
					if ( map.CanSpawnMobile( x, y, this.Z ) )
						return new Point3D( x, y, this.Z );
					else if ( map.CanSpawnMobile( x, y, mapZ ) )
						return new Point3D( x, y, mapZ );
				}
			}

			return this.Location;
		}
Ejemplo n.º 32
0
		public override Point3D GetSpawnPosition( ISpawnable spawned, Map map )
		{
			//Eliminate children on different facets than the chosen map.

			List<IChildDistSpawner> children = new List<IChildDistSpawner>( m_Children );

			for ( int i = children.Count-1; i >= 0; i-- )
				if ( children[i].Map != map || children[i].RootParent != null ) //Not in a container or not on the same map!
					children.RemoveAt( i );

			if ( children.Count > 0 )
				return children[Utility.Random( children.Count )].GetSpawnPosition( spawned );
			else
				return GetSpawnPosition( spawned );
		}
Ejemplo n.º 33
0
        public Point3D GetSpawnPosition(ISpawnable spawned)
        {
            Map map = Map;

            if (map == null)
                return Location;

            bool waterMob, waterOnlyMob;

            if (spawned is Mobile)
            {
                Mobile mob = (Mobile)spawned;

                waterMob = mob.CanSwim;
                waterOnlyMob = (mob.CanSwim && mob.CantWalk);
            }
            else
            {
                waterMob = false;
                waterOnlyMob = false;
            }

            for (int i = 0; i < 10; ++i)
            {
                int x = GetAdjustedLocation(m_HomeRange, m_SpawnArea.Width, m_SpawnArea.X, X);
                int y = GetAdjustedLocation(m_HomeRange, m_SpawnArea.Height, m_SpawnArea.Y, Y);

                int mapZ = map.GetAverageZ(x, y);

                if (m_IgnoreHousing || ((BaseHouse.FindHouseAt(new Point3D(x, y, mapZ), Map, 16) == null &&
                    BaseHouse.FindHouseAt(new Point3D(x, y, this.Z), Map, 16) == null)))
                {
                    if (waterMob)
                    {
                        if (IsValidWater(map, x, y, this.Z))
                            return new Point3D(x, y, this.Z);
                        else if (IsValidWater(map, x, y, mapZ))
                            return new Point3D(x, y, mapZ);
                    }

                    if (!waterOnlyMob)
                    {
                        if (map.CanSpawnMobile(x, y, this.Z))
                            return new Point3D(x, y, this.Z);
                        else if (map.CanSpawnMobile(x, y, mapZ))
                            return new Point3D(x, y, mapZ);
                    }
                }
            }

            return this.Location;
        }
Ejemplo n.º 34
0
		void ISpawner.Remove( ISpawnable spawn )
		{
			m_SpawnedObjects.Remove( spawn );

			CheckTimer();
		}
Ejemplo n.º 35
0
		public void Remove(ISpawnable spawn)
        {
            if (m_SpawnObjects == null) return;

            foreach (SpawnObject so in m_SpawnObjects)
            {
                for (int i = 0; i < so.SpawnedObjects.Count; ++i)
                {
                    if (so.SpawnedObjects[i] == spawn)
                    {
                        so.SpawnedObjects.Remove(spawn);
                        m_killcount++;
                        return;
                    }
                }
            }
        }
Ejemplo n.º 36
0
        private void Add(ISpawnable spawn)
        {
            this.m_SpawnedObjects.Add(spawn);

            spawn.Spawner = this;

            if (spawn is BaseCreature)
                ((BaseCreature)spawn).RemoveIfUntamed = this.RemoveIfUntamed;
        }
Ejemplo n.º 37
0
 protected virtual void OnAfterSpawn( ISpawnable spawnable )
 {
 }
Ejemplo n.º 38
0
        public virtual bool IsComponentItem(ISpawnable item)
        {
            if (item == null)
                return false;

            if (item == this || (m_TillerMan is Item && item == (Item)m_TillerMan) || item == m_SPlank || item == m_PPlank || item == m_Hold)
                return true;
            return false;
        }
Ejemplo n.º 39
0
 public override bool IsComponentItem(ISpawnable item)
 {
     return item == this || item == m_Line || item == m_Rudder || item is RudderHandle;
 }
Ejemplo n.º 40
0
        void ISpawner.Remove(ISpawnable spawn)
        {
            this.m_Spawned.Remove(spawn);

            this.InvalidateProperties();
        }
Ejemplo n.º 41
0
        public Point3D GetSpawnPosition(ISpawnable spawned)
        {
            Map map = this.Map;

            if (map == null)
                return this.Location;

            bool waterMob, waterOnlyMob;

            if (spawned is Mobile)
            {
                Mobile mob = (Mobile)spawned;

                waterMob = mob.CanSwim;
                waterOnlyMob = (mob.CanSwim && mob.CantWalk);
            }
            else
            {
                waterMob = false;
                waterOnlyMob = false;
            }

            // Try 10 times to find a spawnable location.
            for (int i = 0; i < 10; ++i)
            {
                int x, y;

                if (this.m_HomeRange > 0)
                {
                    x = this.Location.X + (Utility.Random((this.m_HomeRange * 2) + 1) - this.m_HomeRange);
                    y = this.Location.Y + (Utility.Random((this.m_HomeRange * 2) + 1) - this.m_HomeRange);
                }
                else
                {
                    x = this.Location.X;
                    y = this.Location.Y;
                }

                int mapZ = map.GetAverageZ(x, y);

                if (waterMob)
                {
                    if (IsValidWater(map, x, y, this.Z))
                        return new Point3D(x, y, this.Z);
                    else if (IsValidWater(map, x, y, mapZ))
                        return new Point3D(x, y, mapZ);
                }

                if (!waterOnlyMob)
                {
                    if (map.CanSpawnMobile(x, y, this.Z))
                        return new Point3D(x, y, this.Z);
                    else if (map.CanSpawnMobile(x, y, mapZ))
                        return new Point3D(x, y, mapZ);
                }
            }

            return this.Location;
        }
Ejemplo n.º 42
0
		public virtual Point3D GetSpawnPosition( ISpawnable spawn )
		{
			return base.GetSpawnPosition( spawn, Map );
		}
Ejemplo n.º 43
0
            public SpawnInstance( GenericReader reader, CreatureSpawner owner )
            {
                m_Owner = owner;

                m_State = (SpawnState) reader.ReadInt();
                m_DeactivateOnRemove = reader.ReadBool();

                switch ( m_State )
                {
                    // TODO: It seems a good place to use the State pattern...

                    case SpawnState.Inactive:
                        break;

                    case SpawnState.Active:
                        m_Spawned = World.Instance.FindEntity( reader.ReadInt() ) as ISpawnable;

                        if ( m_Spawned != null )
                            m_Spawned.Spawner = this;
                        else
                            m_State = SpawnState.Inactive;

                        break;

                    case SpawnState.Respawning:
                        m_NextSpawn = reader.ReadDateTime();

                        TimeSpan delay = m_NextSpawn - DateTime.Now;

                        if ( delay.TotalMilliseconds < 0 )
                            delay = TimeSpan.Zero;

                        m_Timer = Timer.DelayCall( delay, Respawn );
                        break;
                }
            }
Ejemplo n.º 44
0
		public void Remove( ISpawnable spawn )
		{
			//spawn.Delete();
		}
Ejemplo n.º 45
0
        void ISpawner.Remove(ISpawnable spawn)
        {
            m_Spawned.Remove(spawn);

            InvalidateProperties();
        }
Ejemplo n.º 46
0
        public override bool IsComponentItem(ISpawnable spawnable)
        {
            if (!(spawnable is Item))
                return false;

            Item item = (Item)spawnable;

            if (m_MooringLines.Contains(item) || m_Cannons.Contains(item) || m_CannonTiles.Contains(item)
                || m_FillerTiles.Contains(item) || m_HoldTiles.Contains(item) || m_Addons.Contains(item) || item == m_Wheel || item == m_GalleonHold)
                return true;

            return base.IsComponentItem(spawnable);
        }
Ejemplo n.º 47
0
        public void OnEntityRemoved( ISpawnable spawnable )
        {
            if ( Group && TotalSpawned == 0 )
            {
                if ( m_GroupRespawnTimer != null )
                {
                    m_GroupRespawnTimer.Stop();
                    m_GroupRespawnTimer = null;
                }

                TimeSpan delay = TimeSpan.FromSeconds( Utility.RandomMinMax( (int) m_MinDelay.TotalSeconds, (int) m_MaxDelay.TotalSeconds ) );

                m_GroupRespawnTimer = Timer.DelayCall( delay, GroupRespawn );

                m_NextGroupRespawn = DateTime.Now + delay;
            }

            InvalidateProperties();
        }
Ejemplo n.º 48
0
            public void Respawn()
            {
                Despawn();

                ISpawnable spawnable = m_Owner.Spawn();

                if ( spawnable != null )
                {
                    spawnable.Spawner = this;

                    m_Spawned = spawnable;
                    m_State = SpawnState.Active;
                }

                m_Owner.OnEntityAdded( spawnable );
            }
Ejemplo n.º 49
0
 public void OnEntityAdded( ISpawnable spawnable )
 {
     InvalidateProperties();
 }
Ejemplo n.º 50
0
 public void Replace( ISpawnable oldEntity, ISpawnable newEntity )
 {
     if ( m_State == SpawnState.Active )
     {
         m_Spawned = newEntity;
     }
 }
Ejemplo n.º 51
0
        void ISpawner.Remove(ISpawnable spawn)
        {
            this.m_SpawnedObjects.Remove(spawn);

            this.CheckTimer();
        }
Ejemplo n.º 52
0
            public void Remove( ISpawnable spawnable )
            {
                /* In this implementation we can ignore the argument since we
                 * already know it. This is more like a signal function so. */

                m_Spawned = null;

                if ( m_DeactivateOnRemove )
                {
                    m_State = SpawnState.Inactive;
                }
                else
                {
                    m_State = SpawnState.Respawning;

                    TimeSpan respawnDelay = GetRespawnDelay();

                    m_NextSpawn = DateTime.Now + respawnDelay;

                    m_Timer = Timer.DelayCall( respawnDelay, Respawn );
                    m_Timer.Start();
                }

                m_Owner.OnEntityRemoved( spawnable );
            }
Ejemplo n.º 53
0
		public void Remove(ISpawnable spawn)
		{
			if (m_SpawnObjects == null)
			{
				return;
			}

			foreach (SpawnObject so in m_SpawnObjects)
			{
				for (int i = 0; i < so.SpawnedObjects.Count; ++i)
				{
					if (so.SpawnedObjects[i] == spawn)
					{
						so.SpawnedObjects.Remove(spawn);
						// if sequential spawning is active and the RestrictKillsToSubgroup flag is set, then check to see if
						// the object is in the current subgroup before adding to the total

						// Rel Por: NOTE it seems like this was supposed to be handled in Defrag.. not sure why it is handled here?... in any case I added it here - mob
						if (SequentialSpawn >= 0 && so.RestrictKillsToSubgroup)
						{
							if (so.SubGroup == SequentialSpawn)
							{
								m_killcount++;
							}
						}
						else
						{
							// just add it  
							m_killcount++;
						}

						return;
					}
				}
			}
		}
Ejemplo n.º 54
0
        public void Remove(ISpawnable spawn)
        {

        }
Ejemplo n.º 55
0
            private void Initialize( CreatureSpawner owner, bool deactivateOnRemove, SpawnState initialState, ISpawnable initialSpawned, Timer initialTimer )
            {
                m_Owner = owner;
                m_DeactivateOnRemove = deactivateOnRemove;

                m_State = initialState;

                m_Spawned = initialSpawned;
                m_Timer = initialTimer;
            }
Ejemplo n.º 56
0
		public void Remove( ISpawnable spawn )
		{
			Defrag();

			if ( spawn != null )
			{
				SpawnerEntry entry;
				m_Spawned.TryGetValue( spawn, out entry );

				if ( entry != null )
					entry.Spawned.Remove( spawn );

				m_Spawned.Remove( spawn );
			}

			if ( m_Running && !IsFull && m_Timer != null && !m_Timer.Running )
				DoTimer();
		}