mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +03:00
Lots of stuff. Also moved everything I could to the _Shitmed namespace
as I do in Goob. Will make future ports way faster
# Changelog
🆑 Mocho
- add: Added some fun organs and other thingies, check out the Goob PRs
if you want more details.
- fix: Fixed tons of issues with shitmed. Too many for the changelog in
fact.
(cherry picked from commit 3c9db94102cb25b28a83d51ac8d659fa31fe7d12)
83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
using Content.Client.Gameplay;
|
|
using Content.Client._Shitmed.UserInterface.Systems.Targeting.Widgets;
|
|
using Content.Shared._Shitmed.Targeting;
|
|
using Content.Client._Shitmed.Targeting;
|
|
using Content.Shared._Shitmed.Targeting.Events;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using Robust.Client.Player;
|
|
|
|
namespace Content.Client._Shitmed.UserInterface.Systems.Targeting;
|
|
|
|
public sealed class TargetingUIController : UIController, IOnStateEntered<GameplayState>, IOnSystemChanged<TargetingSystem>
|
|
{
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
[Dependency] private readonly IEntityNetworkManager _net = default!;
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
|
|
private TargetingComponent? _targetingComponent;
|
|
private TargetingControl? TargetingControl => UIManager.GetActiveUIWidgetOrNull<TargetingControl>();
|
|
|
|
public void OnSystemLoaded(TargetingSystem system)
|
|
{
|
|
system.TargetingStartup += AddTargetingControl;
|
|
system.TargetingShutdown += RemoveTargetingControl;
|
|
system.TargetChange += CycleTarget;
|
|
}
|
|
|
|
public void OnSystemUnloaded(TargetingSystem system)
|
|
{
|
|
system.TargetingStartup -= AddTargetingControl;
|
|
system.TargetingShutdown -= RemoveTargetingControl;
|
|
system.TargetChange -= CycleTarget;
|
|
}
|
|
|
|
public void OnStateEntered(GameplayState state)
|
|
{
|
|
if (TargetingControl == null)
|
|
return;
|
|
|
|
TargetingControl.SetTargetDollVisible(_targetingComponent != null);
|
|
|
|
if (_targetingComponent != null)
|
|
TargetingControl.SetBodyPartsVisible(_targetingComponent.Target);
|
|
}
|
|
|
|
public void AddTargetingControl(TargetingComponent component)
|
|
{
|
|
_targetingComponent = component;
|
|
|
|
if (TargetingControl != null)
|
|
{
|
|
TargetingControl.SetTargetDollVisible(_targetingComponent != null);
|
|
|
|
if (_targetingComponent != null)
|
|
TargetingControl.SetBodyPartsVisible(_targetingComponent.Target);
|
|
}
|
|
|
|
}
|
|
|
|
public void RemoveTargetingControl()
|
|
{
|
|
if (TargetingControl != null)
|
|
TargetingControl.SetTargetDollVisible(false);
|
|
|
|
_targetingComponent = null;
|
|
}
|
|
|
|
public void CycleTarget(TargetBodyPart bodyPart)
|
|
{
|
|
if (_playerManager.LocalEntity is not { } user
|
|
|| _entManager.GetComponent<TargetingComponent>(user) is not { } targetingComponent
|
|
|| TargetingControl == null)
|
|
return;
|
|
|
|
var player = _entManager.GetNetEntity(user);
|
|
if (bodyPart != targetingComponent.Target)
|
|
{
|
|
var msg = new TargetChangeEvent(player, bodyPart);
|
|
_net.SendSystemNetworkMessage(msg);
|
|
TargetingControl?.SetBodyPartsVisible(bodyPart);
|
|
}
|
|
}
|
|
}
|