Skip to content
Snippets Groups Projects
Commit 4aa44af2 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Massive rework of inventory system.

- Now has 4 sections.
- Made to support the new inventory design.
- Passive items now only affect player if added to specific sections.
- All sections have their full size, null indicates a slot is empty.
- Functionality to easily move items between sections.
- Much more convoluted back-end code.
- It just works now.
parent 24f5b940
No related branches found
No related tags found
1 merge request!35Massive rework of inventory system.
......@@ -277,7 +277,7 @@ namespace BigSock {
/*
Adds a listener for a conditional item to this character's event.
*/
public void AddItemListener(ConditionalItemBase item) {
public void AddItemListener(IConditionalItem item) {
switch(item.Trigger) {
case TriggerType.Fire: OnFire += ((OnFireItemBase) item).Handler; break;
case TriggerType.Hit: OnHit += ((OnHitItemBase) item).Handler; break;
......@@ -294,7 +294,7 @@ namespace BigSock {
/*
Remove a listener for a conditional item from this character's event.
*/
public void RemoveItemListener(ConditionalItemBase item) {
public void RemoveItemListener(IConditionalItem item) {
switch(item.Trigger) {
case TriggerType.Fire: OnFire -= ((OnFireItemBase) item).Handler; break;
case TriggerType.Hit: OnHit -= ((OnHitItemBase) item).Handler; break;
......@@ -312,26 +312,28 @@ namespace BigSock {
Try to pick up an item.
*/
public bool TryPickUpItem(IItem item) {
if(Inventory.AddItem(item)) {
UpdateModifiers();
print($"[Character.TryPickUpItem()] {item.Name} picked up. ({Inventory.Items.Count}/{Inventory.Cap})");
if(Inventory.AddItem(item) != -1) {
//UpdateModifiers();
print($"[Character.TryPickUpItem()] {item.Name} picked up. ({Inventory.Backpack.Count}/{Inventory.BackpackCap})");
return true;
}
print($"[Character.TryPickUpItem()] {item.Name} NOT picked up. ({Inventory.Items.Count}/{Inventory.Cap})");
print($"[Character.TryPickUpItem()] {item.Name} NOT picked up. ({Inventory.Backpack.Count}/{Inventory.BackpackCap})");
return false;
}
/*
Try to drop an item.
!! Depricated, no use this method.
*/
public bool TryDropItem(IItem item) {
if(Inventory.RemoveItem(item)) {
UpdateModifiers();
print($"[Character.TryDropItem()] {item.Name} dropped. ({Inventory.Items.Count}/{Inventory.Cap})");
return true;
}
print($"[Character.TryDropItem()] {item.Name} NOT dropped. ({Inventory.Items.Count}/{Inventory.Cap})");
return false;
throw new NotImplementedException();
// if(Inventory.RemoveItem(item)) {
// //UpdateModifiers();
// print($"[Character.TryDropItem()] {item.Name} dropped. ({Inventory.Items.Count}/{Inventory.Cap})");
// return true;
// }
// print($"[Character.TryDropItem()] {item.Name} NOT dropped. ({Inventory.Items.Count}/{Inventory.Cap})");
// return false;
}
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment