Aura.Channel.World.Entities.NPC.Warp C# (CSharp) Method

Warp() public method

Moves NPC to target location and adds it to the region. Returns false if region doesn't exist.
public Warp ( int regionId, int x, int y ) : bool
regionId int
x int
y int
return bool
		public override bool Warp(int regionId, int x, int y)
		{
			var region = ChannelServer.Instance.World.GetRegion(regionId);
			if (region == null)
			{
				Log.Error("NPC.Warp: Region '{0}' doesn't exist.", regionId);
				return false;
			}

			this.RemoveFromRegion();
			this.SetLocation(regionId, x, y);

			region.AddCreature(this);

			return true;
		}

Usage Example

コード例 #1
0
ファイル: SpawnManager.cs プロジェクト: tkiapril/aura
		/// <summary>
		/// Spawns one creature based on this spawners settings.
		/// </summary>
		/// <returns></returns>
		private void SpawnOne()
		{
			// Create NPC
			var creature = new NPC(this.RaceId);

			// Warp to spawn point
			var pos = this.GetRandomPosition();
			if (!creature.Warp(this.RegionId, pos.X, pos.Y))
			{
				Log.Error("CreatureSpawner: Failed to spawn '{0}'s, region '{1}' doesn't exist.", this.RaceId, this.RegionId);
				return;
			}

			// Save spawn location
			creature.SpawnLocation = new Location(this.RegionId, pos.X, pos.Y);

			// Random title
			if (_titles != null && _titles.Length != 0)
			{
				var title = (ushort)(_titles[RandomProvider.Get().Next(_titles.Length)]);
				if (title != 0)
				{
					creature.Titles.Enable(title);
					creature.Titles.ChangeTitle(title, false);
				}
			}

			// Maintenance
			creature.SpawnId = this.Id;
			creature.Disappears += this.OnDisappears;

			// Add to list to keep track of all creatures
			lock (_creatures)
				_creatures.Add(creature);
		}
All Usage Examples Of Aura.Channel.World.Entities.NPC::Warp