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:
committed by
GitHub
parent
7b7562f75b
commit
3d19a991d8
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user