fix locks and deployable barriers (#14063)

This commit is contained in:
Nemanja
2023-02-13 07:22:37 -05:00
committed by GitHub
parent 42745b1c6e
commit 650ade0d4e
3 changed files with 23 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
namespace Content.Server.Security namespace Content.Server.Security.Components;
{
[RegisterComponent] [RegisterComponent]
public sealed class DeployableBarrierComponent : Component public sealed class DeployableBarrierComponent : Component
{ {
} }
}

View File

@@ -1,4 +1,7 @@
using Content.Server.Pulling;
using Content.Server.Security.Components;
using Content.Shared.Lock; using Content.Shared.Lock;
using Content.Shared.Pulling.Components;
using Content.Shared.Security; using Content.Shared.Security;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -7,6 +10,7 @@ namespace Content.Server.Security.Systems
public sealed class DeployableBarrierSystem : EntitySystem public sealed class DeployableBarrierSystem : EntitySystem
{ {
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly PullingSystem _pulling = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -17,28 +21,28 @@ namespace Content.Server.Security.Systems
private void OnStartup(EntityUid uid, DeployableBarrierComponent component, ComponentStartup args) private void OnStartup(EntityUid uid, DeployableBarrierComponent component, ComponentStartup args)
{ {
if (!EntityManager.TryGetComponent(component.Owner, out LockComponent? lockComponent)) if (!TryComp(uid, out LockComponent? lockComponent))
return; return;
ToggleBarrierDeploy(uid, component, lockComponent.Locked); ToggleBarrierDeploy(uid, lockComponent.Locked);
} }
private void OnLockToggled(EntityUid uid, DeployableBarrierComponent component, ref LockToggledEvent args) private void OnLockToggled(EntityUid uid, DeployableBarrierComponent component, ref LockToggledEvent args)
{ {
ToggleBarrierDeploy(uid, component, args.Locked); ToggleBarrierDeploy(uid, args.Locked);
} }
private void ToggleBarrierDeploy(EntityUid uid, DeployableBarrierComponent component, bool isDeployed) private void ToggleBarrierDeploy(EntityUid uid, bool isDeployed)
{ {
EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored = isDeployed; Transform(uid).Anchored = isDeployed;
if (!EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
return;
var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle; var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle;
_appearance.SetData(uid, DeployableBarrierVisuals.State, state, appearance); _appearance.SetData(uid, DeployableBarrierVisuals.State, state);
if (EntityManager.TryGetComponent(component.Owner, out PointLightComponent? light)) if (TryComp<SharedPullableComponent>(uid, out var pullable))
_pulling.TryStopPull(pullable);
if (TryComp(uid, out PointLightComponent? light))
light.Enabled = isDeployed; light.Enabled = isDeployed;
} }
} }

View File

@@ -128,7 +128,8 @@ public sealed class LockSystem : EntitySystem
_appearanceSystem.SetData(uid, StorageVisuals.Locked, true); _appearanceSystem.SetData(uid, StorageVisuals.Locked, true);
Dirty(lockComp); Dirty(lockComp);
RaiseLocalEvent(uid, new LockToggledEvent(true), true); var ev = new LockToggledEvent(true);
RaiseLocalEvent(uid, ref ev, true);
return true; return true;
} }
@@ -157,7 +158,8 @@ public sealed class LockSystem : EntitySystem
_appearanceSystem.SetData(uid, StorageVisuals.Locked, false); _appearanceSystem.SetData(uid, StorageVisuals.Locked, false);
Dirty(lockComp); Dirty(lockComp);
RaiseLocalEvent(uid, new LockToggledEvent(false), true); var ev = new LockToggledEvent(false);
RaiseLocalEvent(uid, ref ev, true);
} }