mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Door and forcefield in TB
This commit is contained in:
parent
650db8986c
commit
52756defba
18 changed files with 880 additions and 628 deletions
|
|
@ -1,17 +1,53 @@
|
|||
using Cirno.Scripts.Misc;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Misc;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Interactables;
|
||||
|
||||
[Tool]
|
||||
public partial class Interactable3D : Area3D, IInteractable
|
||||
{
|
||||
[Export] public Array<LootItem> Requirements = [];
|
||||
[Export] public Array<StringName> RequirementKeys = [];
|
||||
|
||||
public virtual bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
return true;
|
||||
return MeetsRequirements();
|
||||
}
|
||||
|
||||
protected virtual bool MeetsRequirements()
|
||||
{
|
||||
if (Requirements.Count != 0)
|
||||
{
|
||||
if (InventoryManager.Instance.HasItems(Requirements.Select(x => x.ItemKey.ToString()).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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (RequirementKeys.Count != 0)
|
||||
{
|
||||
if (InventoryManager.Instance.HasItems(RequirementKeys.Select(x => x.ToString()).ToList()))
|
||||
{
|
||||
GD.Print($"Requirements for activation of {this.Name} successfully met: {string.Join(",", RequirementKeys.Select(x => x))} ");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print($"Requirements for activation of {this.Name} not met: {string.Join(",", RequirementKeys.Select(x => x))} ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ public partial class Switch3D : Interactable3D
|
|||
public void _func_godot_apply_properties(Dictionary<string, string> props)
|
||||
{
|
||||
TargetGroup = props["target"];
|
||||
if (props.TryGetValue("key", out var prop))
|
||||
{
|
||||
RequirementKeys = [prop];
|
||||
}
|
||||
//TargetFunc = props["targetfunc"];
|
||||
//TargetName = props["targetname"];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue