public int NearestZoneId(Character ch) { double angle = ch.Orientation; int x = (int)(ch.X + Math.Cos(angle) * 50f); int y = (int)(ch.Y + Math.Sin(angle) * 50f); int nearestDist = int.MaxValue; int nearest = 0; for (int t = 0; t < World.allSpawners.Count; t++) { BaseSpawner bs = World.allSpawners[t]; if (bs.MapId != ch.MapId) { continue; } int a = x - (int)bs.X; int b = y - (int)bs.Y; a = a * a + b * b; if (a < nearestDist) { nearestDist = a; nearest = bs.ZoneId; } } return(nearest); }
/// <summary> /// Removes a specific <see cref='BaseSpawner'/> from the <see cref='SpawnerList'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to remove from the <see cref='SpawnerList'/>.</param> /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception> public void Remove(BaseSpawner val) { int mapid = (val as BaseSpawner).MapId; mapid *= 1024; ArrayList al = (ArrayList)spawnZones[mapid + (int)World.zones[(val as BaseSpawner).ZoneId]]; if (al != null) { ((ArrayList)spawnZones[mapid + (int)World.zones[(val as BaseSpawner).ZoneId]]).Remove(val); } int ind = List.IndexOf(val); for (int a = 0; a < World.regSpawners.Count; a++) { ArrayList all = (ArrayList)World.regSpawners[a]; if (all == null) { continue; } int toRemove = -1; for (int b = 0; b < all.Count; b++) { int alb = (int)all[b]; if (alb > ind) { all[b] = alb - 1; } else if (alb == ind) { toRemove = b; } } if (toRemove != -1) { ((ArrayList)World.regSpawners[a]).RemoveAt(toRemove); } } for (int a = ind; a < World.regSpawners.Count - 1; a++) { World.regSpawners[a] = World.regSpawners[a + 1]; } dirty = true; List.Remove(val); }
/// <summary> /// Adds a <see cref='BaseSpawner'/> with the specified value to the /// <see cref='SpawnerList'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to add.</param> /// <returns>The index at which the new element was inserted.</returns> /// <seealso cref='SpawnerList.AddRange'/> public int Add(BaseSpawner val) { dirty = true; if ((val as BaseSpawner).ZoneId == 0) { // Search the zone id return(List.Add(val)); } int mapid = (val as BaseSpawner).MapId; mapid *= 1024; ArrayList al = (ArrayList)spawnZones[mapid + (int)World.zones[(val as BaseSpawner).ZoneId]]; if (al == null) { al = (ArrayList)(spawnZones[mapid + (int)World.zones[(val as BaseSpawner).ZoneId]] = new ArrayList()); } al.Add(val); return(List.Add(val)); }
/// <summary> /// Inserts a <see cref='BaseSpawner'/> into the <see cref='SpawnerList'/> at the specified index. /// </summary> /// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param> /// <param name='val'>The <see cref='BaseSpawner'/> to insert.</param> /// <seealso cref='SpawnerList.Add'/> public void Insert(int index, BaseSpawner val) { dirty = true; List.Insert(index, val); }
/// <summary> /// Returns the index of a <see cref='BaseSpawner'/> in /// the <see cref='SpawnerList'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to locate.</param> /// <returns> /// The index of the <see cref='BaseSpawner'/> of <paramref name='val'/> in the /// <see cref='SpawnerList'/>, if found; otherwise, -1. /// </returns> /// <seealso cref='SpawnerList.Contains'/> public int IndexOf(BaseSpawner val) { return(List.IndexOf(val)); }
/// <summary> /// Gets a value indicating whether the /// <see cref='SpawnerList'/> contains the specified <see cref='BaseSpawner'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to locate.</param> /// <returns> /// <see langword='true'/> if the <see cref='BaseSpawner'/> is contained in the collection; /// otherwise, <see langword='false'/>. /// </returns> /// <seealso cref='SpawnerList.IndexOf'/> public bool Contains(BaseSpawner val) { return(List.Contains(val)); }
public SpawnerTimer(BaseSpawner f) : base(WowTimer.Priorities.Second, 10000, "SpawnerTimer") { from = f; Start(); }
/// <summary> /// Copies the elements of an array to the end of the <see cref='SpawnerList'/>. /// </summary> /// <param name='val'> /// An array of type <see cref='BaseSpawner'/> containing the objects to add to the collection. /// </param> /// <seealso cref='SpawnerList.Add'/> public void AddRange(BaseSpawner[] val) { dirty = true; for (int i = 0; i < val.Length; i++) { this.Add(val[i]); } }
/// <summary> /// Initializes a new instance of <see cref='SpawnerList'/> containing any array of <see cref='BaseSpawner'/> objects. /// </summary> /// <param name='val'> /// A array of <see cref='BaseSpawner'/> objects with which to intialize the collection /// </param> public SpawnerList(BaseSpawner[] val) { dirty = true; this.AddRange(val); }
/// <summary> /// Removes a specific <see cref='BaseSpawner'/> from the <see cref='SpawnerList'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to remove from the <see cref='SpawnerList'/>.</param> /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception> public void Remove(BaseSpawner val) { int mapid = ( val as BaseSpawner ).MapId; mapid *= 1024; ArrayList al = (ArrayList)spawnZones[ mapid + (int)World.zones[ ( val as BaseSpawner ).ZoneId ] ]; if ( al != null ) { ( (ArrayList)spawnZones[ mapid + (int)World.zones[ ( val as BaseSpawner ).ZoneId ] ] ).Remove( val ); } int ind = List.IndexOf( val ); for( int a = 0;a < World.regSpawners.Count;a++ ) { ArrayList all = (ArrayList)World.regSpawners[ a ]; if ( all == null ) continue; int toRemove = -1; for(int b = 0; b < all.Count;b++ ) { int alb = (int)all[ b ]; if ( alb > ind ) all[ b ] = alb - 1; else if ( alb == ind ) toRemove = b; } if ( toRemove != -1 ) ( (ArrayList)World.regSpawners[ a ] ).RemoveAt( toRemove ); } for( int a = ind;a < World.regSpawners.Count - 1;a++ ) World.regSpawners[ a ] = World.regSpawners[ a + 1 ]; dirty = true; List.Remove(val); }
/// <summary> /// Returns the index of a <see cref='BaseSpawner'/> in /// the <see cref='SpawnerList'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to locate.</param> /// <returns> /// The index of the <see cref='BaseSpawner'/> of <paramref name='val'/> in the /// <see cref='SpawnerList'/>, if found; otherwise, -1. /// </returns> /// <seealso cref='SpawnerList.Contains'/> public int IndexOf(BaseSpawner val) { return List.IndexOf(val); }
/// <summary> /// Copies the <see cref='SpawnerList'/> values to a one-dimensional <see cref='Array'/> instance at the /// specified index. /// </summary> /// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='SpawnerList'/>.</param> /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param> /// <exception cref='ArgumentException'> /// <para><paramref name='array'/> is multidimensional.</para> /// <para>-or-</para> /// <para>The number of elements in the <see cref='SpawnerList'/> is greater than /// the available space between <paramref name='arrayIndex'/> and the end of /// <paramref name='array'/>.</para> /// </exception> /// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception> /// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception> /// <seealso cref='Array'/> public void CopyTo(BaseSpawner[] array, int index) { dirty = true; List.CopyTo(array, index); }
/// <summary> /// Gets a value indicating whether the /// <see cref='SpawnerList'/> contains the specified <see cref='BaseSpawner'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to locate.</param> /// <returns> /// <see langword='true'/> if the <see cref='BaseSpawner'/> is contained in the collection; /// otherwise, <see langword='false'/>. /// </returns> /// <seealso cref='SpawnerList.IndexOf'/> public bool Contains(BaseSpawner val) { return List.Contains(val); }
public SpawnerTimer( BaseSpawner f ) : base(WowTimer.Priorities.Second , 10000, "SpawnerTimer") { from = f; Start(); }
public static void Add( BaseSpawner bs, float X, float Y, float Z, ushort MapId ) { allSpawners.Add( bs ); bs.X = X; bs.Y = Y; bs.Z = Z; bs.MapId = MapId; }
/// <summary> /// Adds a <see cref='BaseSpawner'/> with the specified value to the /// <see cref='SpawnerList'/>. /// </summary> /// <param name='val'>The <see cref='BaseSpawner'/> to add.</param> /// <returns>The index at which the new element was inserted.</returns> /// <seealso cref='SpawnerList.AddRange'/> public int Add(BaseSpawner val) { dirty = true; if ( ( val as BaseSpawner ).ZoneId == 0 ) {// Search the zone id return List.Add(val); } int mapid = ( val as BaseSpawner ).MapId; mapid *= 1024; ArrayList al = (ArrayList)spawnZones[ mapid + (int)World.zones[ ( val as BaseSpawner ).ZoneId ] ]; if ( al == null ) al = (ArrayList)( spawnZones[ mapid + (int)World.zones[ ( val as BaseSpawner ).ZoneId ] ] = new ArrayList() ); al.Add( val ); return List.Add(val); }