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,38 @@
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()
{
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 15a26990a9c14410b2131f6d8286ad18
timeCreated: 1774104885
@@ -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()
{
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e2df668c012544ff893888d9f5bcce9a
timeCreated: 1774104779