Add door interaction system with requirements and HUD integration
This commit is contained in:
@@ -5,6 +5,7 @@ using GameCore.Combat.Effects;
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Events;
|
||||
using GameCore.Interaction;
|
||||
using GameCore.Inventory;
|
||||
using GameCore.Player;
|
||||
using Godot;
|
||||
@@ -23,6 +24,7 @@ public partial class HudPresenterComponent : Control, IPresenterComponent
|
||||
[Export] private Label _healthLabel;
|
||||
[Export] private Label _ammoLabel;
|
||||
[Export] private Label _weaponLabel;
|
||||
[Export] private Label _interactLabel;
|
||||
|
||||
private string _currentAmmoId;
|
||||
|
||||
@@ -45,6 +47,11 @@ public partial class HudPresenterComponent : Control, IPresenterComponent
|
||||
_world.Subscribe<EntityHealedEvent>(OnEntityHealed);
|
||||
_world.Subscribe<InventoryItemChangedEvent>(OnInventoryChanged);
|
||||
_world.Subscribe<WeaponEquippedEvent>(OnWeaponEquipped);
|
||||
|
||||
if (_interactLabel != null)
|
||||
{
|
||||
_interactLabel.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnWeaponEquipped(WeaponEquippedEvent e)
|
||||
@@ -113,6 +120,34 @@ public partial class HudPresenterComponent : Control, IPresenterComponent
|
||||
|
||||
public void SyncToPresentation(float delta)
|
||||
{
|
||||
if (_interactLabel != null)
|
||||
{
|
||||
var lookingAt = _world.GetComponent<IsLookingAtInteractableComponent>(_playerEntity);
|
||||
if (lookingAt != null)
|
||||
{
|
||||
var door = _world.GetComponent<DoorComponent>(lookingAt.Target);
|
||||
if (door != null)
|
||||
{
|
||||
var interactKey = "F";
|
||||
_interactLabel.Text = door.CurrentState switch
|
||||
{
|
||||
DoorComponent.DoorState.Locked => $"[{interactKey}] Interact (Locked)",
|
||||
DoorComponent.DoorState.Closed => $"[{interactKey}] Open Door",
|
||||
DoorComponent.DoorState.Open => $"[{interactKey}] Close Door",
|
||||
_ => ""
|
||||
};
|
||||
_interactLabel.Visible = !string.IsNullOrEmpty(_interactLabel.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
_interactLabel.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_interactLabel.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SyncToCore(float delta)
|
||||
|
||||
Reference in New Issue
Block a user