Skip to content

TPInventoryPackage

Tomasz Piowczyk edited this page Sep 8, 2018 · 1 revision

ITPItemCallbacks

Action OnUsed { get; set; }
Action OnFailUsed { get; set; }

Action OnMoved { get; set; }
Action OnFailMoved { get; set; }

Action OnEquipped { get; set; }
Action OnUnEquipped { get; set; }

ITPItemData

int ID { get; }
int Type { get; }
string Name { get; }
string Description { get; }
double Worth { get; }
int AmountStack { get; }
int MaxStack { get; }
float Weight { get; }
ITPModifier[] Modifiers { get; }

ITPItem : ITPItemCallbacks, ITPItemData

bool Use();
bool Stack(int count = 1);

ITPItemSlot { }

ITPEquipSlot : ITPItemSlot { }

ITPItemSlot : ITPItemSlot where TItem : ITPItem

int Type { get; }
TItem StoredItem { get; set; }
Action OnItemChanged { get; set; }

TItem SwitchItem(TItem item);
bool MoveItem(ITPItemSlot<TItem> targetSlot);
bool CanHoldItem(TItem item);
bool TypeMatch(TItem item);
bool HasItem();
bool IsFull();

ITPEquipSlot : ITPItemSlot, ITPEquipSlot where TItem : ITPItem

ITPInventory<TItemSlot, TEquipSlot, TItem>
where TItemSlot : ITPItemSlot
where TEquipSlot : ITPEquipSlot
where TItem : ITPItem

TItemSlot[] ItemSlots { get; }
TEquipSlot[] EquipSlots { get; }
bool IsFull { get; }

bool AddItem(TItem item);
bool HasEmptySlot(int type = 0);
bool HasItem(int itemID);

TPItem : ITPItem

TPItemSlot : ITPItemSlot

TPEquipSlot : TPItemSlot, ITPEquipSlot

abstract class TPInventory<TItemSlot, TEquipSlot, TItem> : ITPInventory<TItemSlot, TEquipSlot, TItem>
where TItemSlot : ITPItemSlot
where TEquipSlot : ITPEquipSlot
where TItem : ITPItem

protected Dictionary<int, TItem> Items { get; set; }
public int ItemCount { get {} }

public virtual bool IsFull { get {} }
public virtual int SlotCount { get {} }
public virtual int EmptySlotsCount { get {} }

/// Returns false if slot doesn't match item or item exist and can't be more stacked
public virtual bool AddItem(TItem item, ITPItemSlot<TItem> slot){}

public void SetItemSlots(TItemSlot[] slots){}
public void SetEquipSlots(TEquipSlot[] slots){}

public ITPItemSlot<TItem> FindAnySlot(Predicate<ITPItemSlot<TItem>> match){}

/// Finds first matches slot from ItemSlots (can return null)
public TItemSlot FindItemSlot(Predicate<ITPItemSlot<TItem>> match){}

/// Finds first matches slot from EquipSlots (can return null)
public TEquipSlot FindEquipSlot(Predicate<ITPItemSlot<TItem>> match){}

Clone this wiki locally