Skip to content

Commit

Permalink
Merge branch 'master' into space-wizards_space-station-14_26279_2024-…
Browse files Browse the repository at this point in the history
…04-22
  • Loading branch information
VMSolidus authored Jul 9, 2024
2 parents 846d8a1 + 24f36c1 commit b4a6048
Show file tree
Hide file tree
Showing 63 changed files with 977 additions and 1,450 deletions.
23 changes: 12 additions & 11 deletions Content.Client/Alerts/ClientAlertsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Robust.Client.Player;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client.Alerts;

Expand All @@ -12,6 +13,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
{
public AlertOrderPrototype? AlertOrder { get; set; }

[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

Expand Down Expand Up @@ -49,24 +51,23 @@ public IReadOnlyDictionary<AlertKey, AlertState>? ActiveAlerts

protected override void AfterShowAlert(Entity<AlertsComponent> alerts)
{
if (_playerManager.LocalEntity != alerts.Owner)
return;

SyncAlerts?.Invoke(this, alerts.Comp.Alerts);
UpdateHud(alerts);
}

protected override void AfterClearAlert(Entity<AlertsComponent> alertsComponent)
protected override void AfterClearAlert(Entity<AlertsComponent> alerts)
{
if (_playerManager.LocalEntity != alertsComponent.Owner)
return;
UpdateHud(alerts);
}

SyncAlerts?.Invoke(this, alertsComponent.Comp.Alerts);
private void ClientAlertsHandleState(Entity<AlertsComponent> alerts, ref AfterAutoHandleStateEvent args)
{
UpdateHud(alerts);
}

private void ClientAlertsHandleState(EntityUid uid, AlertsComponent component, ref AfterAutoHandleStateEvent args)
private void UpdateHud(Entity<AlertsComponent> entity)
{
if (_playerManager.LocalEntity == uid)
SyncAlerts?.Invoke(this, component.Alerts);
if (_playerManager.LocalEntity == entity.Owner)
SyncAlerts?.Invoke(this, entity.Comp.Alerts);
}

private void OnPlayerAttached(EntityUid uid, AlertsComponent component, LocalPlayerAttachedEvent args)
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Pulling.Components;
using Robust.Client.GameObjects;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Shared.Physics.Components;
Expand All @@ -24,7 +25,7 @@ public override void Initialize()

SubscribeLocalEvent<InputMoverComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
SubscribeLocalEvent<MovementRelayTargetComponent, UpdateIsPredictedEvent>(OnUpdateRelayTargetPredicted);
SubscribeLocalEvent<SharedPullableComponent, UpdateIsPredictedEvent>(OnUpdatePullablePredicted);
SubscribeLocalEvent<PullableComponent, UpdateIsPredictedEvent>(OnUpdatePullablePredicted);
}

private void OnUpdatePredicted(EntityUid uid, InputMoverComponent component, ref UpdateIsPredictedEvent args)
Expand All @@ -40,7 +41,7 @@ private void OnUpdateRelayTargetPredicted(EntityUid uid, MovementRelayTargetComp
args.IsPredicted = true;
}

private void OnUpdatePullablePredicted(EntityUid uid, SharedPullableComponent component, ref UpdateIsPredictedEvent args)
private void OnUpdatePullablePredicted(EntityUid uid, PullableComponent component, ref UpdateIsPredictedEvent args)
{
// Enable prediction if an entity is being pulled by the player.
// Disable prediction if an entity is being pulled by some non-player entity.
Expand Down
21 changes: 0 additions & 21 deletions Content.Client/Pulling/PullingSystem.cs

This file was deleted.

16 changes: 16 additions & 0 deletions Content.Client/Remotes/EntitySystems/DoorRemoteSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Client.Remote.UI;
using Content.Client.Items;
using Content.Shared.Remotes.EntitySystems;
using Content.Shared.Remotes.Components;

namespace Content.Client.Remotes.EntitySystems;

public sealed class DoorRemoteSystem : SharedDoorRemoteSystem
{
public override void Initialize()
{
base.Initialize();

Subs.ItemStatus<DoorRemoteComponent>(ent => new DoorRemoteStatusControl(ent));
}
}
46 changes: 46 additions & 0 deletions Content.Client/Remotes/UI/DoorRemoteStatusControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Remotes.Components;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;

namespace Content.Client.Remote.UI;

public sealed class DoorRemoteStatusControl : Control
{
private readonly Entity<DoorRemoteComponent> _entity;
private readonly RichTextLabel _label;

// set to toggle bolts initially just so that it updates on first pickup of remote
private OperatingMode PrevOperatingMode = OperatingMode.placeholderForUiUpdates;

public DoorRemoteStatusControl(Entity<DoorRemoteComponent> entity)
{
_entity = entity;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

// only updates the UI if any of the details are different than they previously were
if (PrevOperatingMode == _entity.Comp.Mode)
return;

PrevOperatingMode = _entity.Comp.Mode;

// Update current volume and injector state
var modeStringLocalized = Loc.GetString(_entity.Comp.Mode switch
{
OperatingMode.OpenClose => "door-remote-open-close-text",
OperatingMode.ToggleBolts => "door-remote-toggle-bolt-text",
OperatingMode.ToggleEmergencyAccess => "door-remote-emergency-access-text",
_ => "door-remote-invalid-text"
});

_label.SetMarkup(Loc.GetString("door-remote-mode-label", ("modeString", modeStringLocalized)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.Movement.Events;
using Content.Shared.Physics.Pull;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Throwing;

namespace Content.Client.Replay.Spectator;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Throwing/ThrownItemVisualizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void Initialize()

private void OnAutoHandleState(EntityUid uid, ThrownItemComponent component, ref AfterAutoHandleStateEvent args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite))
if (!TryComp<SpriteComponent>(uid, out var sprite) || !component.Animate)
return;

var animationPlayer = EnsureComp<AnimationPlayerComponent>(uid);
Expand Down
4 changes: 2 additions & 2 deletions Content.IntegrationTests/Tests/Puller/PullerTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Content.Shared.Hands.Components;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Prototypes;
using Content.Shared.Pulling.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;

Expand Down Expand Up @@ -29,7 +29,7 @@ await server.WaitAssertion(() =>
{
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
{
if (!proto.TryGetComponent(out SharedPullerComponent? puller))
if (!proto.TryGetComponent(out PullerComponent? puller))
continue;

if (!puller.NeedsHands)
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Alert/Click/StopBeingPulled.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Shared.ActionBlocker;
using Content.Shared.Alert;
using Content.Shared.Pulling.Components;
using Content.Shared.Pulling;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Systems;
using JetBrains.Annotations;

namespace Content.Server.Alert.Click
Expand All @@ -20,9 +20,9 @@ public void AlertClicked(EntityUid player)
if (!entityManager.System<ActionBlockerSystem>().CanInteract(player, null))
return;

if (entityManager.TryGetComponent(player, out SharedPullableComponent? playerPullable))
if (entityManager.TryGetComponent(player, out PullableComponent? playerPullable))
{
entityManager.System<SharedPullingSystem>().TryStopPull(playerPullable);
entityManager.System<PullingSystem>().TryStopPull(player, playerPullable, user: player);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions Content.Server/Alert/Click/StopPulling.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Content.Shared.Alert;
using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Systems;
using JetBrains.Annotations;

namespace Content.Server.Alert.Click
Expand All @@ -15,12 +15,12 @@ public sealed partial class StopPulling : IAlertClick
public void AlertClicked(EntityUid player)
{
var entManager = IoCManager.Resolve<IEntityManager>();
var ps = entManager.System<PullingSystem>();

var ps = entManager.System<SharedPullingSystem>();
var playerTarget = ps.GetPulled(player);
if (playerTarget != default && entManager.TryGetComponent(playerTarget, out SharedPullableComponent? playerPullable))
if (entManager.TryGetComponent(player, out PullerComponent? puller) &&
entManager.TryGetComponent(puller.Pulling, out PullableComponent? pullableComp))
{
ps.TryStopPull(playerPullable);
ps.TryStopPull(puller.Pulling.Value, pullableComp, user: player);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Electrocution/ElectrocutionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using Content.Shared.Maps;
using Content.Shared.Mobs;
using Content.Shared.Popups;
using Content.Shared.Pulling.Components;
using Content.Shared.Speech.EntitySystems;
using Content.Shared.StatusEffect;
using Content.Shared.Stunnable;
Expand All @@ -32,6 +31,8 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using PullableComponent = Content.Shared.Movement.Pulling.Components.PullableComponent;
using PullerComponent = Content.Shared.Movement.Pulling.Components.PullerComponent;

namespace Content.Server.Electrocution;

Expand Down Expand Up @@ -475,14 +476,14 @@ private void GetChainedElectrocutionTargetsRecurse(
all.Add((entity, depth));
visited.Add(entity);

if (TryComp<SharedPullableComponent>(entity, out var pullable) &&
if (TryComp<PullableComponent>(entity, out var pullable) &&
pullable.Puller is { Valid: true } pullerId &&
!visited.Contains(pullerId))
{
GetChainedElectrocutionTargetsRecurse(pullerId, depth + 1, visited, all);
}

if (TryComp<SharedPullerComponent>(entity, out var puller) &&
if (TryComp<PullerComponent>(entity, out var puller) &&
puller.Pulling is { Valid: true } pullingId &&
!visited.Contains(pullingId))
{
Expand Down
23 changes: 12 additions & 11 deletions Content.Server/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using Content.Server.Inventory;
using Content.Server.Pulling;
using Content.Server.Stack;
using Content.Server.Stunnable;
using Content.Shared.ActionBlocker;
Expand All @@ -11,8 +10,9 @@
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Input;
using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Stacks;
using Content.Shared.Throwing;
using Robust.Shared.GameStates;
Expand Down Expand Up @@ -84,9 +84,8 @@ private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent a
return;

// Break any pulls
if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled &&
TryComp(pulled, out SharedPullableComponent? pullable))
_pullingSystem.TryStopPull(pullable);
if (TryComp(uid, out PullerComponent? puller) && TryComp(puller.Pulling, out PullableComponent? pullable))
_pullingSystem.TryStopPull(puller.Pulling.Value, pullable);

if (!_handsSystem.TryDrop(uid, component.ActiveHand!, null, checkActionBlocker: false))
return;
Expand Down Expand Up @@ -124,21 +123,21 @@ private void HandleBodyPartRemoved(EntityUid uid, HandsComponent component, ref

private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args)
{
if (args.Puller.Owner != uid)
if (args.PullerUid != uid)
return;

if (TryComp<SharedPullerComponent>(args.Puller.Owner, out var pullerComp) && !pullerComp.NeedsHands)
if (TryComp<PullerComponent>(args.PullerUid, out var pullerComp) && !pullerComp.NeedsHands)
return;

if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled.Owner, uid))
if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.PulledUid, uid))
{
DebugTools.Assert("Unable to find available hand when starting pulling??");
}
}

private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args)
{
if (args.Puller.Owner != uid)
if (args.PullerUid != uid)
return;

// Try find hand that is doing this pull.
Expand All @@ -147,8 +146,10 @@ private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStop
{
if (hand.HeldEntity == null
|| !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem)
|| virtualItem.BlockingEntity != args.Pulled.Owner)
|| virtualItem.BlockingEntity != args.PulledUid)
{
continue;
}

QueueDel(hand.HeldEntity.Value);
break;
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/NPC/HTN/Preconditions/PulledPrecondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Pulling;
using PullingSystem = Content.Shared.Movement.Pulling.Systems.PullingSystem;

namespace Content.Server.NPC.HTN.Preconditions;

Expand All @@ -7,14 +8,14 @@ namespace Content.Server.NPC.HTN.Preconditions;
/// </summary>
public sealed partial class PulledPrecondition : HTNPrecondition
{
private SharedPullingSystem _pulling = default!;
private PullingSystem _pulling = default!;

[ViewVariables(VVAccess.ReadWrite)] [DataField("isPulled")] public bool IsPulled = true;

public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
_pulling = sysManager.GetEntitySystem<SharedPullingSystem>();
_pulling = sysManager.GetEntitySystem<PullingSystem>();
}

public override bool IsMet(NPCBlackboard blackboard)
Expand Down
Loading

0 comments on commit b4a6048

Please sign in to comment.