38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using RPGCore.BackpackEquipment.ObjectModules.Content.Events;
|
|
using RPGCore.BackpackEquipment.Objects;
|
|
using RPGCore.ObjectModules.ActionObjectModule;
|
|
|
|
namespace RPGCore.BackpackEquipment.ObjectModules.Content.Actions
|
|
{
|
|
public class DropAction : BaseAction
|
|
{
|
|
private readonly ItemObject _item;
|
|
|
|
public DropAction(ItemObject item)
|
|
{
|
|
_item = item;
|
|
}
|
|
|
|
public override void CanDoIt()
|
|
{
|
|
}
|
|
|
|
protected override void OnDoIt()
|
|
{
|
|
var dropEvent = new DropEvent { unit = unit, item = _item };
|
|
unit.events.InvokeBefore(dropEvent);
|
|
Check(!dropEvent.isPrevented, string.Format(ActionWasPreventedMessage, nameof(DropAction)));
|
|
unit.events.InvokeAfter(dropEvent);
|
|
|
|
unit.GetComponent<ContentModule>().Remove(_item);
|
|
}
|
|
|
|
protected override void OnEndIt()
|
|
{
|
|
}
|
|
|
|
protected override void OnCancelIt()
|
|
{
|
|
}
|
|
}
|
|
} |