Aura.Channel.World.Shops.PersonalShop.CanPlace C# (CSharp) Метод

CanPlace() публичный статический Метод

Returns true if creature can place shop at their current location.
public static CanPlace ( Creature creature, string license ) : bool
creature Aura.Channel.World.Entities.Creature
license string
Результат bool
		public static bool CanPlace(Creature creature, string license)
		{
			var licenseData = AuraData.ShopLicenseDb.Find(license);
			if (licenseData == null)
			{
				Log.Warning("PersonalShop.CanPlace: Unknown license '{0}'.", license);
				return false;
			}

			var region = creature.Region;
			var pos = creature.GetPosition();
			var placementPos = GetPlacementPosition(pos, creature.Direction);

			// Check nearby shops
			var otherShops = region.GetProps(a => a.HasTag("/personal_shop/") && a.GetPosition().InRange(placementPos, 250));
			if (otherShops.Count != 0)
				return false;

			// Allow anywhere? (GM license)
			if (licenseData.AllowAnywhere)
				return true;

			// Only allow in specific regions
			if (!licenseData.Regions.Contains(region.Id))
				return false;

			var isOnStreet = region.IsOnStreet(pos);

			// Allow if not on street
			if (!isOnStreet)
				return true;

			// Only allow on street if inside certain allowed events
			var isInAllowedZone = false;
			foreach (var zone in licenseData.Zones)
			{
				// Get event
				var ev = region.GetClientEvent(a => a.GlobalName == zone);
				if (ev == null)
				{
					Log.Warning("PersonalShop.CanPlace: Unknown zone '{0}'.", zone);
					continue;
				}

				// Break if allowed zone was found
				if (ev.IsInside(pos))
				{
					isInAllowedZone = true;
					break;
				}
			}

			return isInAllowedZone;
		}