You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/CSharp/Common/QuestBehaviour/DetectInventoryContains.cs

34 lines
960 B

using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Common.Quest;
public partial class DetectInventoryContains : QuestFulfillmentBase
{
[Export(PropertyHint.ArrayType)] private ItemInstance[] _itemsToContain = null!;
public override void _Ready()
{
QuestManager.Instance!.QuestsChanged += CheckInventory;
InventoryManager.Instance.playerInventory.InventoryContentsChanged += CheckInventory;
CheckInventory();
}
public override void _ExitTree()
{
QuestManager.Instance!.QuestsChanged -= CheckInventory;
InventoryManager.Instance.playerInventory.InventoryContentsChanged -= CheckInventory;
}
private void CheckInventory()
{
if (IsQuestActive() && InventoryManager.Instance.playerInventory.HasItems(_itemsToContain))
{
Fulfill();
}
}
}