Show held item next to cursor (option). (#4658)

* Show held item next to cursor (option).

* UI scale

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2021-10-22 04:26:02 +02:00
committed by GitHub
parent 7b7562f75b
commit 3d19a991d8
7 changed files with 105 additions and 4 deletions

View File

@@ -67,9 +67,7 @@ namespace Content.Client.Hands
public HandsGuiState GetGuiState()
{
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || !player.TryGetComponent(out HandsComponent? hands))
if (GetPlayerHandsComponent() is not { } hands)
return new HandsGuiState(Array.Empty<GuiHand>());
var states = hands.Hands
@@ -79,6 +77,24 @@ namespace Content.Client.Hands
return new HandsGuiState(states, hands.ActiveHand);
}
public IEntity? GetActiveHandEntity()
{
if (GetPlayerHandsComponent() is not { ActiveHand: { } active } hands)
return null;
return hands.GetHand(active).HeldEntity;
}
private HandsComponent? GetPlayerHandsComponent()
{
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || !player.TryGetComponent(out HandsComponent? hands))
return null;
return hands;
}
public void UIHandClick(HandsComponent hands, string handName)
{
if (!hands.TryGetHand(handName, out var pressedHand))