Aura.Channel.World.Entities.Prop.GetDropBehavior C# (CSharp) Method

GetDropBehavior() public static method

Returns prop behavior for dropping.
public static GetDropBehavior ( int dropType ) : PropFunc
dropType int
return PropFunc
		public static PropFunc GetDropBehavior(int dropType)
		{
			return (creature, prop) =>
			{
				if (RandomProvider.Get().NextDouble() > ChannelServer.Instance.Conf.World.PropDropChance)
					return;

				var dropInfo = AuraData.PropDropDb.Find(dropType);
				if (dropInfo == null)
				{
					Log.Warning("GetDropBehavior: Unknown prop drop type '{0}'.", dropType);
					return;
				}

				var rnd = RandomProvider.Get();

				// Get random item from potential drops
				var dropItemInfo = dropInfo.GetRndItem(rnd);
				var rndAmount = (dropItemInfo.Amount > 1 ? (ushort)rnd.Next(1, dropItemInfo.Amount) : (ushort)1);

				var item = new Item(dropItemInfo.ItemClass);
				item.Info.Amount = rndAmount;
				item.Drop(prop.Region, creature.GetPosition(), Item.DropRadius, creature, false);
			};
		}

Usage Example

Beispiel #1
0
		/// <summary>
		/// Creates new prop, based on prop data.
		/// </summary>
		/// <param name="propData"></param>
		/// <param name="regionId"></param>
		/// <param name="regionName"></param>
		/// <param name="areaName"></param>
		public Prop(PropData propData, int regionId, string regionName, string areaName)
			: this(propData.EntityId, propData.Id, regionId, (int)propData.X, (int)propData.Y, propData.Direction, propData.Scale, 0, "", "", "")
		{
			// Set full name
			this.GlobalName = string.Format("{0}/{1}/{2}", regionName, areaName, propData.Name);

			// Save parameters for use by dungeons
			this.Parameters = propData.Parameters.ToList();

			// Add drop behaviour if drop type exists
			var dropType = propData.GetDropType();
			if (dropType != -1)
				this.Behavior = Prop.GetDropBehavior(dropType);

			// Replace default shapes with the ones loaded from region.
			// (Is this really necessary?)
			this.State = propData.State;
			this.Shapes.Clear();
			this.Shapes.AddRange(propData.Shapes.Select(a => a.GetPoints(0, 0, 0)));
		}