2024-06-09 18:19:57 +02:00
|
|
|
using Godot;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2025-01-30 17:24:40 +01:00
|
|
|
using System.Linq;
|
2025-02-07 14:58:59 +01:00
|
|
|
using Cirno.Scripts;
|
2025-01-30 17:24:40 +01:00
|
|
|
using Cirno.Scripts.Resources;
|
|
|
|
|
using Godot.Collections;
|
2024-06-09 18:19:57 +02:00
|
|
|
|
|
|
|
|
public partial class Interactable : Area2D
|
|
|
|
|
{
|
2025-01-30 17:24:40 +01:00
|
|
|
[Export] public Array<LootItem> Requirements = new Array<LootItem>();
|
|
|
|
|
|
|
|
|
|
protected InventoryManager _inventoryManager;
|
2025-01-20 21:58:59 +01:00
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
2025-02-07 14:58:59 +01:00
|
|
|
_inventoryManager = this.GetInventoryManager();
|
2025-01-20 21:58:59 +01:00
|
|
|
}
|
2024-06-09 18:19:57 +02:00
|
|
|
|
2025-01-30 17:24:40 +01:00
|
|
|
protected bool MeetsRequirements()
|
2024-06-09 18:19:57 +02:00
|
|
|
{
|
2025-01-30 17:24:40 +01:00
|
|
|
if (Requirements.Any())
|
2025-01-20 21:58:59 +01:00
|
|
|
{
|
2025-02-11 11:50:45 +01:00
|
|
|
if (_inventoryManager.HasItems(Requirements.Select(x => x.ItemKey).ToList()))
|
2025-01-30 17:24:40 +01:00
|
|
|
{
|
|
|
|
|
GD.Print($"Requirements for activation of {this.Name} successfully met: {string.Join(",", Requirements.Select(x => x.Item))} ");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GD.Print($"Requirements for activation of {this.Name} not met: {string.Join(",", Requirements.Select(x => x.Item))} ");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-20 21:58:59 +01:00
|
|
|
}
|
2025-01-30 17:24:40 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-30 17:43:39 +01:00
|
|
|
public virtual bool Activate()
|
2025-01-30 17:24:40 +01:00
|
|
|
{
|
2025-01-30 17:43:39 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool CanActivate()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
2024-06-09 18:19:57 +02:00
|
|
|
}
|
|
|
|
|
}
|