cirnogodot/Scenes/Interactable.cs

49 lines
1,014 B
C#
Raw Normal View History

2024-06-09 18:19:57 +02:00
using Godot;
using System;
using System.Diagnostics;
using System.Linq;
2025-02-07 14:58:59 +01:00
using Cirno.Scripts;
using Cirno.Scripts.Resources;
using Godot.Collections;
2024-06-09 18:19:57 +02:00
public partial class Interactable : Area2D
{
[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
protected bool MeetsRequirements()
2024-06-09 18:19:57 +02: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()))
{
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
}
return true;
}
2025-01-30 17:43:39 +01:00
public virtual bool Activate()
{
2025-01-30 17:43:39 +01:00
return true;
}
public virtual bool CanActivate()
{
return true;
2024-06-09 18:19:57 +02:00
}
}