This commit is contained in:
2026-04-25 23:37:10 +02:00
commit 19d6bd934a
476 changed files with 9198 additions and 0 deletions
@@ -0,0 +1,45 @@
using RPGCore.BackpackEquipment.ObjectModules.Content.Events;
using RPGCore.BackpackEquipment.Objects;
using RPGCore.ObjectModules.ActionObjectModule;
namespace RPGCore.BackpackEquipment.ObjectModules.Content.Actions
{
public class TakeAction : BaseAction
{
private readonly IContentOwner _contentOwner;
private readonly ItemObject _item;
private readonly int _index;
public TakeAction(IContentOwner contentOwner, ItemObject item, int index = -1)
{
_contentOwner = contentOwner;
_item = item;
_index = index;
}
public override void CanDoIt()
{
_contentOwner.CanAdd(_item, _index);
}
protected override void OnDoIt()
{
var takeEvent = new TakeEvent { unit = unit, item = _item };
unit.events.InvokeBefore(takeEvent);
Check(!takeEvent.isPrevented, string.Format(ActionWasPreventedMessage, nameof(TakeAction)));
unit.events.InvokeAfter(takeEvent);
var content = unit.GetComponent<ContentModule>();
content.Add(_item);
content.TransferTo(_contentOwner, _item, _index);
}
protected override void OnEndIt()
{
}
protected override void OnCancelIt()
{
}
}
}