Added more quest stuff including dialogic quest condition
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
@@ -120,12 +121,29 @@ public partial class InventoryInstance : Node
|
||||
{
|
||||
if (destinationSlot < 0 || destinationSlot >= _slots.Count)
|
||||
return InventoryActionResult.DestinationDoesNotExists;
|
||||
|
||||
|
||||
if (!_slots[destinationSlot].IsEmpty())
|
||||
return InventoryActionResult.DestinationFull;
|
||||
|
||||
|
||||
_slots[destinationSlot].itemInstance = itemInstance;
|
||||
EmitSignal(SignalName.InventoryContentsChanged);
|
||||
return InventoryActionResult.Success;
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalItemsOfBlueprint(ItemResource blueprint)
|
||||
{
|
||||
return _slots
|
||||
.Where(i => !i.IsEmpty() && i.itemInstance!.blueprint == blueprint)
|
||||
.Sum(i => i.itemInstance!.amount);
|
||||
}
|
||||
|
||||
public bool HasItems(ItemInstance item)
|
||||
{
|
||||
return TotalItemsOfBlueprint(item.blueprint) >= item.amount;
|
||||
}
|
||||
|
||||
public bool HasItems(IEnumerable<ItemInstance> items)
|
||||
{
|
||||
return items.All(HasItems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Godot;
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
public class ItemInstance
|
||||
// Do not instantiate this resource
|
||||
// But it has to be a resource because Godot
|
||||
[GlobalClass]
|
||||
public partial class ItemInstance: Resource
|
||||
{
|
||||
public ItemResource blueprint;
|
||||
public int amount = 1;
|
||||
[Export] public ItemResource blueprint;
|
||||
[Export] public int amount = 1;
|
||||
|
||||
public ItemInstance Clone()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user