mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-23 00:27:50 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Ports the lone abductor and possibly(?) the duo abductors. --- # TODO <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [X] Figure out why abductors aren't spawning as the abductor race. - [X] Make sure it's not a buggy mess. --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>  </p> </details> --- # Credits Thank to [Starlight ](https://discord.com/invite/wAyQKB78fH)for the original version! Darkrell, Rinary, and Landosaur made the funny little guys.  # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Darkrell, Rinary, Landosaur - add: The Abductors are here to replace your organs. Gleep Glorp! --------- Co-authored-by: gluesniffler <159397573+gluesniffler@users.noreply.github.com> Co-authored-by: Solstice <solsticeofthewinter@gmail.com> Co-authored-by: SX_7 <sn1.test.preria.2002@gmail.com> Co-authored-by: Theodore Lukin <66275205+pheenty@users.noreply.github.com> Co-authored-by: Piras314 <p1r4s@proton.me> Co-authored-by: Ilya246 <57039557+ilya246@users.noreply.github.com> (cherry picked from commit ea9f1526868289d20832989cb02f79c76c240918)
154 lines
5.7 KiB
C#
154 lines
5.7 KiB
C#
using Content.Client.Actions;
|
|
using Content.Client.Items;
|
|
using Content.Client.Message;
|
|
using Content.Client.Stylesheets;
|
|
using Content.Shared.DeviceNetwork.Components;
|
|
using Content.Shared.DeviceNetwork.Systems;
|
|
using Content.Shared.Input;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Input;
|
|
using Robust.Client.Player;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.NetworkConfigurator.Systems;
|
|
|
|
public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|
{
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
[Dependency] private readonly IOverlayManager _overlay = default!;
|
|
[Dependency] private readonly ActionsSystem _actions = default!;
|
|
[Dependency] private readonly IInputManager _inputManager = default!;
|
|
|
|
[ValidatePrototypeId<EntityPrototype>]
|
|
private const string Action = "ActionClearNetworkLinkOverlays";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ClearAllOverlaysEvent>(_ => ClearAllOverlays());
|
|
Subs.ItemStatus<NetworkConfiguratorComponent>(OnCollectItemStatus);
|
|
}
|
|
|
|
private Control OnCollectItemStatus(Entity<NetworkConfiguratorComponent> entity)
|
|
{
|
|
_inputManager.TryGetKeyBinding((ContentKeyFunctions.AltUseItemInHand), out var binding);
|
|
return new StatusControl(entity, binding?.GetKeyString() ?? "");
|
|
}
|
|
|
|
public bool ConfiguredListIsTracked(EntityUid uid, NetworkConfiguratorComponent? component = null)
|
|
{
|
|
return Resolve(uid, ref component)
|
|
&& component.ActiveDeviceList != null
|
|
&& HasComp<NetworkConfiguratorActiveLinkOverlayComponent>(component.ActiveDeviceList.Value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Toggles a device list's (tied to this network configurator) connection visualisation on and off.
|
|
/// </summary>
|
|
public void ToggleVisualization(EntityUid uid, bool toggle, NetworkConfiguratorComponent? component = null)
|
|
{
|
|
if (_playerManager.LocalEntity == null
|
|
|| !Resolve(uid, ref component)
|
|
|| component.ActiveDeviceList == null)
|
|
return;
|
|
|
|
if (!toggle)
|
|
{
|
|
RemComp<NetworkConfiguratorActiveLinkOverlayComponent>(component.ActiveDeviceList.Value);
|
|
if (!_overlay.TryGetOverlay(out NetworkConfiguratorLinkOverlay? overlay))
|
|
return;
|
|
|
|
overlay.Colors.Remove(component.ActiveDeviceList.Value);
|
|
if (overlay.Colors.Count > 0)
|
|
return;
|
|
|
|
_actions.RemoveAction(overlay.Action);
|
|
_overlay.RemoveOverlay<NetworkConfiguratorLinkOverlay>();
|
|
return;
|
|
}
|
|
|
|
if (!_overlay.HasOverlay<NetworkConfiguratorLinkOverlay>())
|
|
{
|
|
var overlay = new NetworkConfiguratorLinkOverlay();
|
|
_overlay.AddOverlay(overlay);
|
|
var player = _playerManager.LocalEntity.Value;
|
|
overlay.Action = Spawn(Action);
|
|
_actions.AddActionDirect(player, overlay.Action.Value);
|
|
}
|
|
|
|
EnsureComp<NetworkConfiguratorActiveLinkOverlayComponent>(component.ActiveDeviceList.Value);
|
|
}
|
|
|
|
public void ClearAllOverlays()
|
|
{
|
|
if (!_overlay.TryGetOverlay(out NetworkConfiguratorLinkOverlay? overlay))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var query = EntityQueryEnumerator<NetworkConfiguratorActiveLinkOverlayComponent>();
|
|
while (query.MoveNext(out var uid, out _))
|
|
{
|
|
RemCompDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(uid);
|
|
}
|
|
|
|
_actions.RemoveAction(overlay.Action);
|
|
_overlay.RemoveOverlay(overlay);
|
|
}
|
|
|
|
private sealed class StatusControl : Control
|
|
{
|
|
private readonly RichTextLabel _label;
|
|
private readonly NetworkConfiguratorComponent _configurator;
|
|
private readonly string _keyBindingName;
|
|
|
|
private bool? _linkModeActive = null;
|
|
|
|
public StatusControl(NetworkConfiguratorComponent configurator, string keyBindingName)
|
|
{
|
|
_configurator = configurator;
|
|
_keyBindingName = keyBindingName;
|
|
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
|
|
if (_configurator.ShowLabel) // Shitmed - Starlight Abductors: Allow hiding the label on multitools that dont need List mode.
|
|
AddChild(_label);
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
|
|
if (_linkModeActive != null && _linkModeActive == _configurator.LinkModeActive)
|
|
return;
|
|
|
|
_linkModeActive = _configurator.LinkModeActive;
|
|
|
|
if (!_configurator.ShowLabel) // Shitmed - Starlight Abductors: Allow hiding the label on multitools that dont need List mode.
|
|
return;
|
|
|
|
var modeLocString = _linkModeActive??false
|
|
? "network-configurator-examine-mode-link"
|
|
: "network-configurator-examine-mode-list";
|
|
|
|
_label.SetMarkup(Robust.Shared.Localization.Loc.GetString("network-configurator-item-status-label",
|
|
("mode", Robust.Shared.Localization.Loc.GetString(modeLocString)),
|
|
("keybinding", _keyBindingName)));
|
|
}
|
|
}
|
|
}
|
|
|
|
public sealed class ClearAllNetworkLinkOverlays : IConsoleCommand
|
|
{
|
|
public string Command => "clearnetworklinkoverlays";
|
|
public string Description => "Clear all network link overlays.";
|
|
public string Help => Command;
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
IoCManager.Resolve<IEntityManager>().System<NetworkConfiguratorSystem>().ClearAllOverlays();
|
|
}
|
|
}
|