Skip to content

Commit

Permalink
Cherry-picked commit c584f64 from space-wizards/space-station-14/master
Browse files Browse the repository at this point in the history
  • Loading branch information
SimpleStation14 authored and metalgearsloth committed Mar 19, 2024
1 parent 3bf08c7 commit 52f178d
Show file tree
Hide file tree
Showing 53 changed files with 796 additions and 1,356 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.

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 @@ -83,9 +83,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 @@ -123,21 +122,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 @@ -146,8 +145,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
15 changes: 7 additions & 8 deletions Content.Server/Objectives/Systems/StealConditionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Shared.Pulling.Components;
using Content.Shared.Objectives;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Mobs.Components;
using Content.Shared.Movement.Pulling.Components;

namespace Content.Server.Objectives.Systems;

Expand Down Expand Up @@ -100,19 +99,19 @@ private float GetProgress(MindComponent mind, StealConditionComponent condition)
var count = 0;

//check pulling object
if (TryComp<SharedPullerComponent>(mind.OwnedEntity, out var pull)) //TO DO: to make the code prettier? don't like the repetition
if (TryComp<PullerComponent>(mind.OwnedEntity, out var pull)) //TO DO: to make the code prettier? don't like the repetition
{
var pullid = pull.Pulling;
if (pullid != null)
var pulledEntity = pull.Pulling;
if (pulledEntity != null)
{
// check if this is the item
if (CheckStealTarget(pullid.Value, condition)) count++;
if (CheckStealTarget(pulledEntity.Value, condition)) count++;

//we don't check the inventories of sentient entity
if (!TryComp<MindContainerComponent>(pullid, out var pullMind))
if (!HasComp<MindContainerComponent>(pulledEntity))
{
// if it is a container check its contents
if (_containerQuery.TryGetComponent(pullid, out var containerManager))
if (_containerQuery.TryGetComponent(pulledEntity, out var containerManager))
stack.Push(containerManager);
}
}
Expand Down
Loading

0 comments on commit 52f178d

Please sign in to comment.