mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 20:05:54 +00:00
Interactable interface
This commit is contained in:
parent
49e58ff735
commit
54d9824581
27 changed files with 102 additions and 61 deletions
|
|
@ -33,7 +33,7 @@ public partial class AlarmBox : Interactable
|
|||
_sprite.Play("alarmed");
|
||||
}
|
||||
|
||||
public override bool Activate()
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (MeetsRequirements() && _alarmManager.IsAlarmOn)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using Cirno.Scripts;
|
||||
|
||||
public partial class Computer : Interactable
|
||||
{
|
||||
[Export] public Activable Target { get; set; }
|
||||
public override bool Activate()
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (MeetsRequirements())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
namespace Cirno.Scripts.Interactables;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Interactables;
|
||||
|
||||
public interface IInteractable
|
||||
{
|
||||
public bool Activate();
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle);
|
||||
public bool CanActivate();
|
||||
|
||||
public Vector2 GetPosition();
|
||||
//protected bool MeetsRequirements();
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ public partial class ItemPickup : Interactable
|
|||
{
|
||||
[Export] public Array<LootItem> LootTable = new Array<LootItem>();
|
||||
|
||||
public override bool Activate()
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
GD.Print("Attempting to Pickup Item");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Cirno.Scripts.Interactables;
|
|||
public partial class Switch : Interactable
|
||||
{
|
||||
[Export] public Node2D Target { get; set; }
|
||||
[Export] public Array<Node2D> Targets { get; private set; } = new Array<Node2D>();
|
||||
[Export] public Array<Node2D> Targets { get; private set; } = [];
|
||||
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
||||
|
||||
private AudioStreamPlayer2D _activationSound;
|
||||
|
|
@ -19,7 +19,7 @@ public partial class Switch : Interactable
|
|||
_activationSound = GetNodeOrNull<AudioStreamPlayer2D>(_activationSoundName);
|
||||
}
|
||||
|
||||
public override bool Activate()
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (!MeetsRequirements()) return false;
|
||||
_activationSound?.Play();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public partial class Valve : Interactable
|
|||
SetState(_activationState);
|
||||
}
|
||||
|
||||
public override bool Activate()
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (MeetsRequirements() && Target is IActivable activatable)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue