#W# Change: Walking over farmable crops auto harvests them and puts it in your backpack.
This commit is contained in:
parent
a181e313cd
commit
edce93bba8
1 changed files with 46 additions and 3 deletions
|
|
@ -14,6 +14,36 @@ public abstract partial class FarmableCrop : Item
|
|||
public abstract Item GetCropObject();
|
||||
public abstract int GetPickedID();
|
||||
|
||||
public override void AddNameProperties(IPropertyList list)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandlesOnMovement => true;
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (m.Player && m.Alive && !_picked && m.InRange(this.Location, 2))
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromMilliseconds(100), () =>
|
||||
{
|
||||
if (m.InRange(this.Location, 2) && !_picked)
|
||||
{
|
||||
OnPicked(m, Location, Map);
|
||||
}
|
||||
});
|
||||
}
|
||||
base.OnMovement(m, oldLocation);
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile from)
|
||||
{
|
||||
if (from != null && from.Alive && from.Player && !_picked)
|
||||
{
|
||||
OnPicked(from, this.Location, this.Map);
|
||||
}
|
||||
return base.OnMoveOver(from);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
var map = Map;
|
||||
|
|
@ -40,7 +70,20 @@ public abstract partial class FarmableCrop : Item
|
|||
|
||||
var spawn = GetCropObject();
|
||||
|
||||
spawn?.MoveToWorld(loc, map);
|
||||
//spawn?.MoveToWorld(loc, map);
|
||||
if (spawn != null)
|
||||
{
|
||||
if (from.Backpack == null || !from.Backpack.CheckHold(from, spawn, true, true))
|
||||
{
|
||||
spawn.MoveToWorld(loc, map);
|
||||
from.SendMessage("Your backpack is full, the crop was placed on the ground.");
|
||||
}
|
||||
else
|
||||
{
|
||||
from.AddToBackpack(spawn);
|
||||
from.PlaySound(0x13E); // Harvest sound
|
||||
}
|
||||
}
|
||||
|
||||
_picked = true;
|
||||
|
||||
|
|
@ -59,11 +102,11 @@ public abstract partial class FarmableCrop : Item
|
|||
}
|
||||
|
||||
[AfterDeserialization]
|
||||
private void AfterDeserialization()
|
||||
public void AfterDeserialization()
|
||||
{
|
||||
if (_picked)
|
||||
{
|
||||
Unlink();
|
||||
//Unlink();
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue