mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-01 21:51:17 +00:00
Interactable interface
This commit is contained in:
parent
49e58ff735
commit
54d9824581
27 changed files with 102 additions and 61 deletions
|
|
@ -5,8 +5,9 @@ using Cirno.Scripts;
|
||||||
|
|
||||||
public partial class Activable : Area2D, IActivable
|
public partial class Activable : Area2D, IActivable
|
||||||
{
|
{
|
||||||
public virtual void Activate(ActivationType activationType = ActivationType.Toggle)
|
public virtual bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("Activated");
|
//Debug.WriteLine("Activated");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1124,31 +1124,36 @@ stretch_mode = 5
|
||||||
|
|
||||||
[node name="l1_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
[node name="l1_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 256.0
|
offset_left = -13.915
|
||||||
|
offset_right = 242.085
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
texture = ExtResource("20_jmnog")
|
texture = ExtResource("20_jmnog")
|
||||||
|
|
||||||
[node name="l2_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
[node name="l2_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 256.0
|
offset_left = -37.65
|
||||||
|
offset_right = 218.35
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
texture = ExtResource("21_kvayf")
|
texture = ExtResource("21_kvayf")
|
||||||
|
|
||||||
[node name="l3_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
[node name="l3_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 256.0
|
offset_left = -80.0
|
||||||
|
offset_right = 176.0
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
texture = ExtResource("22_ypu2s")
|
texture = ExtResource("22_ypu2s")
|
||||||
|
|
||||||
[node name="l4_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
[node name="l4_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 256.0
|
offset_left = -100.0
|
||||||
|
offset_right = 156.0
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
texture = ExtResource("23_1hkdx")
|
texture = ExtResource("23_1hkdx")
|
||||||
|
|
||||||
[node name="l5_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
[node name="l5_forest" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro1"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 256.0
|
offset_left = -120.0
|
||||||
|
offset_right = 136.0
|
||||||
offset_bottom = 100.0
|
offset_bottom = 100.0
|
||||||
texture = ExtResource("24_mqbwl")
|
texture = ExtResource("24_mqbwl")
|
||||||
|
|
||||||
|
|
@ -1312,10 +1317,9 @@ stretch_mode = 5
|
||||||
|
|
||||||
[node name="Intro11-Crystal" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro11"]
|
[node name="Intro11-Crystal" type="TextureRect" parent="MarginContainer/ImagesContainer/Intro11"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = 41.0
|
offset_left = 150.0
|
||||||
offset_top = 34.0
|
offset_right = 198.0
|
||||||
offset_right = 89.0
|
offset_bottom = 32.0
|
||||||
offset_bottom = 66.0
|
|
||||||
texture = ExtResource("19_paaiq")
|
texture = ExtResource("19_paaiq")
|
||||||
stretch_mode = 5
|
stretch_mode = 5
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public partial class Interactable : Area2D, IInteractable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Activate()
|
public virtual bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -16,7 +16,7 @@ public partial class BlackCover : Sprite2D, IActivable
|
||||||
UpdateSprite();
|
UpdateSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
switch (activationType)
|
switch (activationType)
|
||||||
{
|
{
|
||||||
|
|
@ -36,6 +36,7 @@ public partial class BlackCover : Sprite2D, IActivable
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UpdateSprite();
|
UpdateSprite();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSprite()
|
private void UpdateSprite()
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public partial class BulletEmitter : Node2D, IActivable
|
||||||
_bulletSpawner.SpawnBullet(BulletResource.MakeBullet(this.GlobalPosition, Count, Spread, EmissionRotation));
|
_bulletSpawner.SpawnBullet(BulletResource.MakeBullet(this.GlobalPosition, Count, Spread, EmissionRotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
switch (activationType)
|
switch (activationType)
|
||||||
{
|
{
|
||||||
|
|
@ -77,5 +77,7 @@ public partial class BulletEmitter : Node2D, IActivable
|
||||||
case ActivationType.Destroy:
|
case ActivationType.Destroy:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ public partial class DialogueStarter : ChainActivable
|
||||||
DialogueEndAction();
|
DialogueEndAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
_dialogic.Connect("timeline_ended", Callable.From(OnTimelineEnded));
|
_dialogic.Connect("timeline_ended", Callable.From(OnTimelineEnded));
|
||||||
|
|
||||||
|
|
@ -43,6 +43,7 @@ public partial class DialogueStarter : ChainActivable
|
||||||
((Node)dialogicNode).ProcessMode = ProcessModeEnum.Always;
|
((Node)dialogicNode).ProcessMode = ProcessModeEnum.Always;
|
||||||
_gameManager.ChangeState(GameState.Dialogue);
|
_gameManager.ChangeState(GameState.Dialogue);
|
||||||
|
|
||||||
|
return true;
|
||||||
// Script dialogic = ResourceLoader.Load("res://addons/dialogic/Other/DialogicClass.gd") as Script;
|
// Script dialogic = ResourceLoader.Load("res://addons/dialogic/Other/DialogicClass.gd") as Script;
|
||||||
// var dialog = (Node) dialogic.Call("start","timeline");
|
// var dialog = (Node) dialogic.Call("start","timeline");
|
||||||
// AddChild(dialog);
|
// AddChild(dialog);
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public partial class HealthStation : Activable
|
||||||
_healingTimer = 0;
|
_healingTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
switch (activationType)
|
switch (activationType)
|
||||||
{
|
{
|
||||||
|
|
@ -90,6 +90,8 @@ public partial class HealthStation : Activable
|
||||||
// Destroys
|
// Destroys
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _on_area_entered(Area2D area)
|
private void _on_area_entered(Area2D area)
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ public partial class PlayerMover : ChainActivable
|
||||||
_gameManager = this.GetGameManager();
|
_gameManager = this.GetGameManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (_gameManager.Player is null) return;
|
if (_gameManager.Player is null) return false;
|
||||||
|
|
||||||
_ = MovePlayer();
|
_ = MovePlayer();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task MovePlayer()
|
private async Task MovePlayer()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Cirno.Scripts.Interactables;
|
||||||
using Cirno.Scripts.Resources.Events;
|
using Cirno.Scripts.Resources.Events;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
|
@ -63,8 +64,15 @@ public partial class ScriptableBase : Node2D, IActivable
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
Start();
|
Start();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanActivate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +76,7 @@ public partial class Teleporter : Activable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
switch (activationType)
|
switch (activationType)
|
||||||
{
|
{
|
||||||
|
|
@ -100,6 +100,8 @@ public partial class Teleporter : Activable
|
||||||
// Destroys
|
// Destroys
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareForReceiving()
|
public void PrepareForReceiving()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public partial class ActorSpawner : Node2D, IActivable
|
||||||
SpawnedActor = this.CreateSibling<Actor>(ActorPrefab);
|
SpawnedActor = this.CreateSibling<Actor>(ActorPrefab);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (!WaitForActorDeath)
|
if (!WaitForActorDeath)
|
||||||
{
|
{
|
||||||
|
|
@ -27,5 +27,7 @@ public partial class ActorSpawner : Node2D, IActivable
|
||||||
{
|
{
|
||||||
Spawn();
|
Spawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ public partial class Boss : Enemy, IActivable
|
||||||
_currentHealth -= amount;
|
_currentHealth -= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
_started = true;
|
_started = true;
|
||||||
if (_bossHud is not null)
|
if (_bossHud is not null)
|
||||||
|
|
@ -149,6 +149,8 @@ public partial class Boss : Enemy, IActivable
|
||||||
}
|
}
|
||||||
_gameManager.CameraTargetObject(_cameraMarker);
|
_gameManager.CameraTargetObject(_cameraMarker);
|
||||||
StartPhase(CurrentPhase);
|
StartPhase(CurrentPhase);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Switchphase(BossPhase phase)
|
private async Task Switchphase(BossPhase phase)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public partial class Chest : Interactable
|
||||||
|
|
||||||
private AnimatedSprite2D _sprite;
|
private AnimatedSprite2D _sprite;
|
||||||
|
|
||||||
public override bool Activate()
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
GD.Print("Attempting to open chest");
|
GD.Print("Attempting to open chest");
|
||||||
if (State != ChestState.Closed) return false;
|
if (State != ChestState.Closed) return false;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Cirno.Scripts.Components.FSM;
|
using Cirno.Scripts.Components.FSM;
|
||||||
|
using Cirno.Scripts.Interactables;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Cirno.Scripts.Components.Actors;
|
namespace Cirno.Scripts.Components.Actors;
|
||||||
|
|
@ -17,11 +18,11 @@ public partial class ActivationProvider : Area2D
|
||||||
|
|
||||||
[Export] private AudioStreamPlayer2D _errorSound;
|
[Export] private AudioStreamPlayer2D _errorSound;
|
||||||
|
|
||||||
[Signal]
|
//[Signal]
|
||||||
public delegate void InteractableAreaEnteredEventHandler(Interactable interactable);
|
//public delegate void InteractableAreaEnteredEventHandler(Interactable interactable);
|
||||||
|
|
||||||
[Signal]
|
//[Signal]
|
||||||
public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
|
//public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
|
||||||
|
|
||||||
public void Init(CharacterBody2D actor)
|
public void Init(CharacterBody2D actor)
|
||||||
{
|
{
|
||||||
|
|
@ -80,9 +81,9 @@ public partial class ActivationProvider : Area2D
|
||||||
private void _on_interaction_controller_area_entered(Area2D area)
|
private void _on_interaction_controller_area_entered(Area2D area)
|
||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
if (area.IsInGroup("Interactable") && area is Interactable interactable && interactable.CanActivate())
|
if (area.IsInGroup("Interactable") && area is IInteractable interactable && interactable.CanActivate())
|
||||||
{
|
{
|
||||||
EmitSignal(nameof(InteractableAreaEntered), interactable);
|
//EmitSignal(nameof(InteractableAreaEntered), interactable);
|
||||||
|
|
||||||
if (_selector == null) return;
|
if (_selector == null) return;
|
||||||
|
|
||||||
|
|
@ -93,9 +94,9 @@ public partial class ActivationProvider : Area2D
|
||||||
private void _on_interaction_controller_area_exited(Area2D area)
|
private void _on_interaction_controller_area_exited(Area2D area)
|
||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
if (area.IsInGroup("Interactable") && area is Interactable interactable)
|
if (area.IsInGroup("Interactable") && area is IInteractable interactable)
|
||||||
{
|
{
|
||||||
EmitSignal(nameof(InteractableAreaExited), interactable);
|
//EmitSignal(nameof(InteractableAreaExited), interactable);
|
||||||
|
|
||||||
if (_selector == null) return;
|
if (_selector == null) return;
|
||||||
_selector.RemoveInteractable(interactable);
|
_selector.RemoveInteractable(interactable);
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,10 @@ public partial class ElevatorProxy : Area2D, IActivable
|
||||||
|
|
||||||
public InteractionController CachedPlayer { get; private set; }
|
public InteractionController CachedPlayer { get; private set; }
|
||||||
|
|
||||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.Activated, (int)activationType);
|
EmitSignal(SignalName.Activated, (int)activationType);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _on_area_entered(Area2D area)
|
private void _on_area_entered(Area2D area)
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public partial class Door : Activable
|
||||||
//_solidShape.Disabled = state;
|
//_solidShape.Disabled = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
switch (activationType)
|
switch (activationType)
|
||||||
{
|
{
|
||||||
|
|
@ -108,6 +108,8 @@ public partial class Door : Activable
|
||||||
ToggleDoor();
|
ToggleDoor();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleDoor()
|
private void ToggleDoor()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
public interface IActivable
|
public interface IActivable
|
||||||
{
|
{
|
||||||
void Activate(ActivationType activationType = ActivationType.Toggle);
|
bool Activate(ActivationType activationType = ActivationType.Toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ActivationType
|
public enum ActivationType
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public partial class AlarmBox : Interactable
|
||||||
_sprite.Play("alarmed");
|
_sprite.Play("alarmed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Activate()
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (MeetsRequirements() && _alarmManager.IsAlarmOn)
|
if (MeetsRequirements() && _alarmManager.IsAlarmOn)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using Cirno.Scripts;
|
||||||
|
|
||||||
public partial class Computer : Interactable
|
public partial class Computer : Interactable
|
||||||
{
|
{
|
||||||
[Export] public Activable Target { get; set; }
|
[Export] public Activable Target { get; set; }
|
||||||
public override bool Activate()
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (MeetsRequirements())
|
if (MeetsRequirements())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
namespace Cirno.Scripts.Interactables;
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Interactables;
|
||||||
|
|
||||||
public interface IInteractable
|
public interface IInteractable
|
||||||
{
|
{
|
||||||
public bool Activate();
|
public bool Activate(ActivationType activationType = ActivationType.Toggle);
|
||||||
public bool CanActivate();
|
public bool CanActivate();
|
||||||
|
|
||||||
|
public Vector2 GetPosition();
|
||||||
//protected bool MeetsRequirements();
|
//protected bool MeetsRequirements();
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ public partial class ItemPickup : Interactable
|
||||||
{
|
{
|
||||||
[Export] public Array<LootItem> LootTable = new Array<LootItem>();
|
[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");
|
GD.Print("Attempting to Pickup Item");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace Cirno.Scripts.Interactables;
|
||||||
public partial class Switch : Interactable
|
public partial class Switch : Interactable
|
||||||
{
|
{
|
||||||
[Export] public Node2D Target { get; set; }
|
[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;
|
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
||||||
|
|
||||||
private AudioStreamPlayer2D _activationSound;
|
private AudioStreamPlayer2D _activationSound;
|
||||||
|
|
@ -19,7 +19,7 @@ public partial class Switch : Interactable
|
||||||
_activationSound = GetNodeOrNull<AudioStreamPlayer2D>(_activationSoundName);
|
_activationSound = GetNodeOrNull<AudioStreamPlayer2D>(_activationSoundName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Activate()
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (!MeetsRequirements()) return false;
|
if (!MeetsRequirements()) return false;
|
||||||
_activationSound?.Play();
|
_activationSound?.Play();
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public partial class Valve : Interactable
|
||||||
SetState(_activationState);
|
SetState(_activationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Activate()
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
if (MeetsRequirements() && Target is IActivable activatable)
|
if (MeetsRequirements() && Target is IActivable activatable)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public partial class Pickupper : Activable
|
||||||
_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||||
{
|
{
|
||||||
foreach (var item in LootTable)
|
foreach (var item in LootTable)
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +27,6 @@ public partial class Pickupper : Activable
|
||||||
//GetParent().QueueFree(); // TODO: send a signal instead
|
//GetParent().QueueFree(); // TODO: send a signal instead
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Cirno.Scripts.Interactables;
|
||||||
|
|
||||||
public partial class Selector : Node2D
|
public partial class Selector : Node2D
|
||||||
{
|
{
|
||||||
private Interactable _lastInteractable;
|
private Interactable _lastInteractable;
|
||||||
|
|
||||||
private List<Interactable> _interactables = new List<Interactable>();
|
private List<IInteractable> _interactables = [];
|
||||||
|
|
||||||
private int _selectedInteractable;
|
private int _selectedInteractable;
|
||||||
|
|
||||||
[Signal]
|
//[Signal]
|
||||||
public delegate void SelectedItemInteractableChangedEventHandler(Interactable interactable);
|
//public delegate void SelectedItemInteractableChangedEventHandler(IInteractable interactable);
|
||||||
|
|
||||||
public Interactable SelectedInteractable
|
public IInteractable SelectedInteractable
|
||||||
{
|
{
|
||||||
get =>
|
get =>
|
||||||
_interactables.Count > 0
|
_interactables.Count > 0
|
||||||
|
|
@ -79,12 +80,12 @@ public partial class Selector : Node2D
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotifyChanged(Interactable interactable)
|
private void NotifyChanged(IInteractable interactable)
|
||||||
{
|
{
|
||||||
EmitSignal(nameof(SelectedItemInteractableChanged), interactable);
|
//EmitSignal(nameof(SelectedItemInteractableChanged), interactable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddInteractable(Interactable interactable)
|
public void AddInteractable(IInteractable interactable)
|
||||||
{
|
{
|
||||||
if (!_interactables.Contains(interactable)) {
|
if (!_interactables.Contains(interactable)) {
|
||||||
_interactables.Add(interactable);
|
_interactables.Add(interactable);
|
||||||
|
|
@ -98,7 +99,7 @@ public partial class Selector : Node2D
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveInteractable(Interactable interactable)
|
public void RemoveInteractable(IInteractable interactable)
|
||||||
{
|
{
|
||||||
if (_interactables.Contains(interactable))
|
if (_interactables.Contains(interactable))
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +118,7 @@ public partial class Selector : Node2D
|
||||||
{
|
{
|
||||||
if (SelectedInteractable != null)
|
if (SelectedInteractable != null)
|
||||||
{
|
{
|
||||||
this.Position = SelectedInteractable.Position;
|
this.Position = SelectedInteractable.GetPosition();
|
||||||
this.Visible = true;
|
this.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
BIN
Tilesets/factory.aseprite
(Stored with Git LFS)
BIN
Tilesets/factory.aseprite
(Stored with Git LFS)
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue