mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 08:55:54 +00:00
Refactored switches and chests and mapping
This commit is contained in:
parent
295d32e66d
commit
cc5376e94e
14 changed files with 158 additions and 91 deletions
|
|
@ -1,28 +1,43 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class Interactable : Area2D
|
||||
{
|
||||
[Export] public Activable Target { get; set; }
|
||||
[Export] public bool RequiresKeycard { get; set; }
|
||||
private InventoryManager _inventoryManager;
|
||||
[Export] public Array<LootItem> Requirements = new Array<LootItem>();
|
||||
|
||||
protected InventoryManager _inventoryManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
protected bool MeetsRequirements()
|
||||
{
|
||||
if (RequiresKeycard) {
|
||||
if (_inventoryManager.RedKeycard) {
|
||||
Target?.Activate();
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Requirements.Any())
|
||||
{
|
||||
Target?.Activate();
|
||||
if (_inventoryManager.HasItems(Requirements.Select(x => x.Item).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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Activate()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue