-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
531 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Content.Shared._White.TargetDoll; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client._White.TargetDoll; | ||
|
||
public sealed class TargetDollSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
public event Action<TargetDollComponent>? TargetDollStartup; | ||
public event Action? TargetDollShutdown; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<TargetDollComponent, LocalPlayerAttachedEvent>(HandlePlayerAttached); | ||
SubscribeLocalEvent<TargetDollComponent, LocalPlayerDetachedEvent>(HandlePlayerDetached); | ||
SubscribeLocalEvent<TargetDollComponent, ComponentStartup>(OnTargetingStartup); | ||
SubscribeLocalEvent<TargetDollComponent, ComponentShutdown>(OnTargetingShutdown); | ||
} | ||
|
||
private void HandlePlayerAttached(EntityUid uid, TargetDollComponent component, LocalPlayerAttachedEvent args) | ||
{ | ||
TargetDollStartup?.Invoke(component); | ||
} | ||
|
||
private void HandlePlayerDetached(EntityUid uid, TargetDollComponent component, LocalPlayerDetachedEvent args) | ||
{ | ||
TargetDollShutdown?.Invoke(); | ||
} | ||
|
||
private void OnTargetingStartup(EntityUid uid, TargetDollComponent component, ComponentStartup args) | ||
{ | ||
if (_playerManager.LocalEntity == uid) | ||
TargetDollStartup?.Invoke(component); | ||
} | ||
|
||
private void OnTargetingShutdown(EntityUid uid, TargetDollComponent component, ComponentShutdown args) | ||
{ | ||
if (_playerManager.LocalEntity == uid) | ||
TargetDollShutdown?.Invoke(); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
Content.Client/_White/UI/Systems/TargetDoll/TargetDollUIController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Content.Client.Gameplay; | ||
using Content.Client._White.TargetDoll; | ||
using Content.Client._White.UI.Systems.TargetDoll.Widgets; | ||
using Content.Shared._White.TargetDoll; | ||
using Robust.Client.UserInterface.Controllers; | ||
using Robust.Client.Player; | ||
|
||
namespace Content.Client._White.UI.Systems.TargetDoll; | ||
|
||
public sealed class TargetDollUIController : UIController, IOnStateEntered<GameplayState>, IOnSystemChanged<TargetDollSystem> | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IEntityNetworkManager _net = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
private TargetDollComponent? _targetingComponent; | ||
private TargetDollGui? TargetDollGui => UIManager.GetActiveUIWidgetOrNull<TargetDollGui>(); | ||
|
||
public void OnSystemLoaded(TargetDollSystem system) | ||
{ | ||
system.TargetDollStartup += AddTargetingControl; | ||
system.TargetDollShutdown += RemoveTargetingControl; | ||
} | ||
|
||
public void OnSystemUnloaded(TargetDollSystem system) | ||
{ | ||
system.TargetDollStartup -= AddTargetingControl; | ||
system.TargetDollShutdown -= RemoveTargetingControl; | ||
} | ||
|
||
public void OnStateEntered(GameplayState state) | ||
{ | ||
if (TargetDollGui == null) | ||
return; | ||
|
||
TargetDollGui.SetTargetDollVisible(_targetingComponent != null); | ||
|
||
if (_targetingComponent != null) | ||
TargetDollGui.SetBodyPartsVisible(_targetingComponent.Target); | ||
} | ||
|
||
public void AddTargetingControl(TargetDollComponent component) | ||
{ | ||
_targetingComponent = component; | ||
|
||
if (TargetDollGui == null) | ||
return; | ||
|
||
TargetDollGui.SetTargetDollVisible(_targetingComponent != null); | ||
|
||
if (_targetingComponent != null) | ||
TargetDollGui.SetBodyPartsVisible(_targetingComponent.Target); | ||
|
||
} | ||
|
||
public void RemoveTargetingControl() | ||
{ | ||
if (TargetDollGui != null) | ||
TargetDollGui.SetTargetDollVisible(false); | ||
|
||
_targetingComponent = null; | ||
} | ||
|
||
public void CycleTarget(BodyPart bodyPart) | ||
{ | ||
if (_playerManager.LocalEntity is not { } user | ||
|| _entManager.GetComponent<TargetDollComponent>(user) is not { } targetingComponent | ||
|| TargetDollGui == null) | ||
return; | ||
|
||
var player = _entManager.GetNetEntity(user); | ||
|
||
if (bodyPart == targetingComponent.Target) | ||
return; | ||
|
||
var msg = new TargetDollChangeEvent(player, bodyPart); | ||
_net.SendSystemNetworkMessage(msg); | ||
TargetDollGui?.SetBodyPartsVisible(bodyPart); | ||
} | ||
} |
Oops, something went wrong.