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.
36 lines
1.1 KiB
36 lines
1.1 KiB
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Babushka.scripts.CSharp.Common.Inventory;
|
|
using Babushka.scripts.CSharp.Common.Quest;
|
|
using Babushka.scripts.CSharp.GameEntity.Entities;
|
|
using Babushka.scripts.CSharp.GameEntity.Management;
|
|
|
|
public partial class DetectInventoryContains : QuestFulfillmentBase
|
|
{
|
|
[Export(PropertyHint.ArrayType)] private ItemInstance[] _itemsToContain = null!;
|
|
|
|
public override void _Ready()
|
|
{
|
|
QuestManager.Instance!.QuestsChanged += CheckInventory;
|
|
EntityManager.Instance.GetUniqueEntity<VesnaEntity>().inventory.InventoryContentsChanged += CheckInventory;
|
|
|
|
CheckInventory();
|
|
}
|
|
|
|
public override void _ExitTree()
|
|
{
|
|
QuestManager.Instance!.QuestsChanged -= CheckInventory;
|
|
EntityManager.Instance.GetUniqueEntity<VesnaEntity>().inventory.InventoryContentsChanged -= CheckInventory;
|
|
}
|
|
|
|
private void CheckInventory()
|
|
{
|
|
if (IsQuestActive() && EntityManager.Instance.GetUniqueEntity<VesnaEntity>().inventory.HasItems(_itemsToContain))
|
|
{
|
|
Fulfill();
|
|
}
|
|
}
|
|
}
|