Weldable cleanup (#19809)

This commit is contained in:
metalgearsloth
2023-09-05 00:07:01 +10:00
committed by GitHub
parent 88454b046a
commit db1ff07821
24 changed files with 159 additions and 210 deletions

View File

@@ -1,9 +0,0 @@
using Content.Shared.Tools.Components;
namespace Content.Client.Tools.Components;
[RegisterComponent]
public sealed partial class WeldableComponent : SharedWeldableComponent
{
}

View File

@@ -1,4 +1,3 @@
using Content.Client.Tools.Components;
using Content.Shared.Tools.Components; using Content.Shared.Tools.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;

View File

@@ -2,7 +2,7 @@ using System.Linq;
using Content.IntegrationTests.Tests.Construction.Interaction; using Content.IntegrationTests.Tests.Construction.Interaction;
using Content.IntegrationTests.Tests.Interaction; using Content.IntegrationTests.Tests.Interaction;
using Content.IntegrationTests.Tests.Weldable; using Content.IntegrationTests.Tests.Weldable;
using Content.Server.Tools.Components; using Content.Shared.Tools.Components;
namespace Content.IntegrationTests.Tests.DoAfter; namespace Content.IntegrationTests.Tests.DoAfter;
@@ -100,11 +100,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
await SpawnTarget(WeldableTests.Locker); await SpawnTarget(WeldableTests.Locker);
var comp = Comp<WeldableComponent>(); var comp = Comp<WeldableComponent>();
Assert.Multiple(() => Assert.That(comp.IsWelded, Is.False);
{
Assert.That(comp.Weldable, Is.True);
Assert.That(comp.IsWelded, Is.False);
});
await Interact(Weld, awaitDoAfters: false); await Interact(Weld, awaitDoAfters: false);
await RunTicks(1); await RunTicks(1);

View File

@@ -1,5 +1,5 @@
using Content.IntegrationTests.Tests.Interaction; using Content.IntegrationTests.Tests.Interaction;
using Content.Server.Tools.Components; using Content.Shared.Tools.Components;
namespace Content.IntegrationTests.Tests.Weldable; namespace Content.IntegrationTests.Tests.Weldable;
@@ -16,11 +16,7 @@ public sealed class WeldableTests : InteractionTest
await SpawnTarget(Locker); await SpawnTarget(Locker);
var comp = Comp<WeldableComponent>(); var comp = Comp<WeldableComponent>();
Assert.Multiple(() => Assert.That(comp.IsWelded, Is.False);
{
Assert.That(comp.Weldable, Is.True);
Assert.That(comp.IsWelded, Is.False);
});
await Interact(Weld); await Interact(Weld);
Assert.That(comp.IsWelded, Is.True); Assert.That(comp.IsWelded, Is.True);

View File

@@ -18,7 +18,6 @@ using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems; using Content.Server.Storage.EntitySystems;
using Content.Server.Tabletop; using Content.Server.Tabletop;
using Content.Server.Tabletop.Components; using Content.Server.Tabletop.Components;
using Content.Server.Tools.Systems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Administration.Components; using Content.Shared.Administration.Components;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
@@ -39,6 +38,7 @@ using Content.Shared.Movement.Systems;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Tabletop.Components; using Content.Shared.Tabletop.Components;
using Content.Shared.Tools.Systems;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -677,7 +677,7 @@ public sealed partial class AdminVerbSystem
_entityStorageSystem.Insert(args.Target, locker, storage); _entityStorageSystem.Insert(args.Target, locker, storage);
_entityStorageSystem.ToggleOpen(args.Target, locker, storage); _entityStorageSystem.ToggleOpen(args.Target, locker, storage);
} }
_weldableSystem.ForceWeldedState(locker, true); _weldableSystem.SetWeldedState(locker, true);
}, },
Impact = LogImpact.Extreme, Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-locker-stuff-description"), Message = Loc.GetString("admin-smite-locker-stuff-description"),

View File

@@ -5,6 +5,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Atmos.Piping.Unary.Components namespace Content.Server.Atmos.Piping.Unary.Components
{ {
// The world if people documented their shit.
[RegisterComponent] [RegisterComponent]
public sealed partial class GasVentPumpComponent : Component public sealed partial class GasVentPumpComponent : Component
{ {
@@ -14,9 +15,6 @@ namespace Content.Server.Atmos.Piping.Unary.Components
[ViewVariables] [ViewVariables]
public bool IsDirty { get; set; } = false; public bool IsDirty { get; set; } = false;
[ViewVariables(VVAccess.ReadWrite)]
public bool Welded { get; set; } = false;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("inlet")] [DataField("inlet")]
public string Inlet { get; set; } = "pipe"; public string Inlet { get; set; } = "pipe";

View File

@@ -15,9 +15,6 @@ namespace Content.Server.Atmos.Piping.Unary.Components
[ViewVariables] [ViewVariables]
public bool IsDirty { get; set; } = false; public bool IsDirty { get; set; } = false;
[ViewVariables(VVAccess.ReadWrite)]
public bool Welded { get; set; } = false;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("outlet")] [DataField("outlet")]
public string OutletName { get; set; } = "pipe"; public string OutletName { get; set; } = "pipe";

View File

@@ -11,13 +11,13 @@ using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes; using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Tools.Systems;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.Monitor; using Content.Shared.Atmos.Monitor;
using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos.Visuals; using Content.Shared.Atmos.Visuals;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Tools.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -29,9 +29,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!; [Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!; [Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!; [Dependency] private readonly WeldableSystem _weldable = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -53,7 +54,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, AtmosDeviceUpdateEvent args) private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, AtmosDeviceUpdateEvent args)
{ {
//Bingo waz here //Bingo waz here
if (vent.Welded) if (_weldable.IsWelded(uid))
{ {
return; return;
} }
@@ -82,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
} }
var timeDelta = args.dt; var timeDelta = args.dt;
var pressureDelta = (float) timeDelta * vent.TargetPressureChange; var pressureDelta = timeDelta * vent.TargetPressureChange;
if (vent.PumpDirection == VentPumpDirection.Releasing && pipe.Air.Pressure > 0) if (vent.PumpDirection == VentPumpDirection.Releasing && pipe.Air.Pressure > 0)
{ {
@@ -255,7 +256,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return; return;
_ambientSoundSystem.SetAmbience(uid, true); _ambientSoundSystem.SetAmbience(uid, true);
if (vent.Welded) if (_weldable.IsWelded(uid))
{ {
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance); _appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance);
@@ -311,10 +312,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
args.GasMixtures = gasMixDict; args.GasMixtures = gasMixDict;
} }
private void OnWeldChanged(EntityUid uid, GasVentPumpComponent component, WeldableChangedEvent args) private void OnWeldChanged(EntityUid uid, GasVentPumpComponent component, ref WeldableChangedEvent args)
{ {
var isWelded = args.IsWelded;
component.Welded = isWelded;
UpdateState(uid, component); UpdateState(uid, component);
} }
} }

View File

@@ -10,12 +10,12 @@ using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes; using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Tools.Systems;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Unary.Visuals; using Content.Shared.Atmos.Piping.Unary.Visuals;
using Content.Shared.Atmos.Monitor; using Content.Shared.Atmos.Monitor;
using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Tools.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -26,10 +26,11 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{ {
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!; [Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!; [Dependency] private readonly WeldableSystem _weldable = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -46,7 +47,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args) private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args)
{ {
if (scrubber.Welded) if (_weldable.IsWelded(uid))
{ {
return; return;
} }
@@ -185,7 +186,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return; return;
_ambientSoundSystem.SetAmbience(uid, true); _ambientSoundSystem.SetAmbience(uid, true);
if (scrubber.Welded) if (_weldable.IsWelded(uid))
{ {
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
_appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Welded, appearance); _appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Welded, appearance);
@@ -205,10 +206,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
} }
} }
private void OnWeldChanged(EntityUid uid, GasVentScrubberComponent component, WeldableChangedEvent args) private void OnWeldChanged(EntityUid uid, GasVentScrubberComponent component, ref WeldableChangedEvent args)
{ {
var isWelded = args.IsWelded;
component.Welded = isWelded;
UpdateState(uid, component); UpdateState(uid, component);
} }
} }

View File

@@ -1,6 +1,7 @@
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Shared.Construction; using Content.Shared.Construction;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Tools.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Content.Server.Construction.Conditions namespace Content.Server.Construction.Conditions
@@ -14,10 +15,7 @@ namespace Content.Server.Construction.Conditions
public bool Condition(EntityUid uid, IEntityManager entityManager) public bool Condition(EntityUid uid, IEntityManager entityManager)
{ {
if (!entityManager.TryGetComponent(uid, out EntityStorageComponent? entityStorageComponent)) return entityManager.System<WeldableSystem>().IsWelded(uid);
return false;
return entityStorageComponent.IsWeldedShut == Welded;
} }
public bool DoExamine(ExaminedEvent args) public bool DoExamine(ExaminedEvent args)
@@ -25,11 +23,12 @@ namespace Content.Server.Construction.Conditions
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = IoCManager.Resolve<IEntityManager>();
var entity = args.Examined; var entity = args.Examined;
if (!entMan.TryGetComponent(entity, out EntityStorageComponent? entityStorage)) return false; if (!entMan.HasComponent<EntityStorageComponent>(entity))
return false;
var metaData = entMan.GetComponent<MetaDataComponent>(entity); var metaData = entMan.GetComponent<MetaDataComponent>(entity);
if (entityStorage.IsWeldedShut != Welded) if (entMan.System<WeldableSystem>().IsWelded(entity) != Welded)
{ {
if (Welded) if (Welded)
args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", metaData.EntityName)) + "\n"); args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", metaData.EntityName)) + "\n");

View File

@@ -27,6 +27,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Objectives\Interfaces\" /> <Folder Include="Objectives\Interfaces\" />
<Folder Include="Tools\Systems\" />
</ItemGroup> </ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" /> <Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
</Project> </Project>

View File

@@ -2,7 +2,6 @@ using Content.Server.Access;
using Content.Server.Atmos.Components; using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction; using Content.Server.Construction;
using Content.Server.Tools.Systems;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Doors; using Content.Shared.Doors;
using Content.Shared.Doors.Components; using Content.Shared.Doors.Components;
@@ -18,6 +17,7 @@ using Content.Shared.Tools;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.Tools.Systems;
namespace Content.Server.Doors.Systems; namespace Content.Server.Doors.Systems;
@@ -139,7 +139,7 @@ public sealed class DoorSystem : SharedDoorSystem
} }
} }
private void OnWeldChanged(EntityUid uid, DoorComponent component, WeldableChangedEvent args) private void OnWeldChanged(EntityUid uid, DoorComponent component, ref WeldableChangedEvent args)
{ {
if (component.State == DoorState.Closed) if (component.State == DoorState.Closed)
SetState(uid, DoorState.Welded, component); SetState(uid, DoorState.Welded, component);

View File

@@ -15,6 +15,7 @@ using Content.Shared.Hands.Components;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
using Content.Shared.Tools.Systems;
using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Events;
@@ -42,6 +43,7 @@ public sealed class NPCUtilitySystem : EntitySystem
[Dependency] private readonly PuddleSystem _puddle = default!; [Dependency] private readonly PuddleSystem _puddle = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!; [Dependency] private readonly SolutionContainerSystem _solutions = default!;
[Dependency] private readonly WeldableSystem _weldable = default!;
private EntityQuery<TransformComponent> _xformQuery; private EntityQuery<TransformComponent> _xformQuery;
@@ -195,7 +197,7 @@ public sealed class NPCUtilitySystem : EntitySystem
{ {
if (TryComp<EntityStorageComponent>(container.Owner, out var storageComponent)) if (TryComp<EntityStorageComponent>(container.Owner, out var storageComponent))
{ {
if (storageComponent is { IsWeldedShut: true, Open: false }) if (storageComponent is { Open: false } && _weldable.IsWelded(container.Owner))
{ {
return 0.0f; return 0.0f;
} }

View File

@@ -6,15 +6,18 @@ using Content.Shared.Lock;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Resist; using Content.Shared.Resist;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
namespace Content.Server.Resist; namespace Content.Server.Resist;
public sealed class ResistLockerSystem : EntitySystem public sealed class ResistLockerSystem : EntitySystem
{ {
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly LockSystem _lockSystem = default!;
[Dependency] private readonly EntityStorageSystem _entityStorage = default!; [Dependency] private readonly EntityStorageSystem _entityStorage = default!;
[Dependency] private readonly LockSystem _lockSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly WeldableSystem _weldable = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -31,7 +34,7 @@ public sealed class ResistLockerSystem : EntitySystem
if (!TryComp(uid, out EntityStorageComponent? storageComponent)) if (!TryComp(uid, out EntityStorageComponent? storageComponent))
return; return;
if (TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked || storageComponent.IsWeldedShut) if (TryComp<LockComponent>(uid, out var lockComponent) && lockComponent.Locked || _weldable.IsWelded(uid))
{ {
AttemptResist(args.Entity, uid, storageComponent, component); AttemptResist(args.Entity, uid, storageComponent, component);
} }
@@ -69,10 +72,11 @@ public sealed class ResistLockerSystem : EntitySystem
component.IsResisting = false; component.IsResisting = false;
if (TryComp<EntityStorageComponent>(uid, out var storageComponent)) if (HasComp<EntityStorageComponent>(uid))
{ {
if (storageComponent.IsWeldedShut) WeldableComponent? weldable = null;
storageComponent.IsWeldedShut = false; if (_weldable.IsWelded(uid, weldable))
_weldable.SetWeldedState(uid, false, weldable);
if (TryComp<LockComponent>(args.Args.Target.Value, out var lockComponent)) if (TryComp<LockComponent>(args.Args.Target.Value, out var lockComponent))
_lockSystem.Unlock(uid, args.Args.User, lockComponent); _lockSystem.Unlock(uid, args.Args.User, lockComponent);

View File

@@ -3,7 +3,6 @@ using Content.Server.Explosion.EntitySystems;
using Content.Server.Resist; using Content.Server.Resist;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Server.Tools.Systems;
using Content.Shared.Access.Components; using Content.Shared.Access.Components;
using Content.Shared.Coordinates; using Content.Shared.Coordinates;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
@@ -11,6 +10,7 @@ using Content.Shared.Lock;
using Content.Shared.Mind.Components; using Content.Shared.Mind.Components;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
using Content.Shared.Storage.EntitySystems; using Content.Shared.Storage.EntitySystems;
using Content.Shared.Tools.Systems;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -327,13 +327,12 @@ public sealed class BluespaceLockerSystem : EntitySystem
} }
else else
{ {
if (target.Value.storageComponent.IsWeldedShut) if (_weldableSystem.IsWelded(target.Value.uid))
{ {
// It gets bluespaced open... // It gets bluespaced open...
_weldableSystem.ForceWeldedState(target.Value.uid, false); _weldableSystem.SetWeldedState(target.Value.uid, false);
if (target.Value.storageComponent.IsWeldedShut)
target.Value.storageComponent.IsWeldedShut = false;
} }
LockComponent? lockComponent = null; LockComponent? lockComponent = null;
if (Resolve(target.Value.uid, ref lockComponent, false) && lockComponent.Locked) if (Resolve(target.Value.uid, ref lockComponent, false) && lockComponent.Locked)
_lockSystem.Unlock(target.Value.uid, target.Value.uid, lockComponent); _lockSystem.Unlock(target.Value.uid, target.Value.uid, lockComponent);

View File

@@ -3,7 +3,6 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction; using Content.Server.Construction;
using Content.Server.Construction.Components; using Content.Server.Construction.Components;
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Server.Tools.Systems;
using Content.Shared.Destructible; using Content.Shared.Destructible;
using Content.Shared.Foldable; using Content.Shared.Foldable;
using Content.Shared.Interaction; using Content.Shared.Interaction;
@@ -11,6 +10,7 @@ using Content.Shared.Lock;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
using Content.Shared.Storage.EntitySystems; using Content.Shared.Storage.EntitySystems;
using Content.Shared.Tools.Systems;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
@@ -44,7 +44,6 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
SubscribeLocalEvent<EntityStorageComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<EntityStorageComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt); SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale); SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale);
SubscribeLocalEvent<InsideEntityStorageComponent, ExhaleLocationEvent>(OnInsideExhale); SubscribeLocalEvent<InsideEntityStorageComponent, ExhaleLocationEvent>(OnInsideExhale);
@@ -97,12 +96,6 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
} }
} }
private void OnWelded(EntityUid uid, EntityStorageComponent component, WeldableChangedEvent args)
{
component.IsWeldedShut = args.IsWelded;
Dirty(component);
}
protected override void TakeGas(EntityUid uid, SharedEntityStorageComponent component) protected override void TakeGas(EntityUid uid, SharedEntityStorageComponent component)
{ {
if (!component.Airtight) if (!component.Airtight)

View File

@@ -1,48 +0,0 @@
using Content.Server.Tools.Systems;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Tools.Components;
/// <summary>
/// Allows users to weld/unweld doors, crates and lockers.
/// </summary>
[RegisterComponent]
[Access(typeof(WeldableSystem))]
public sealed partial class WeldableComponent : SharedWeldableComponent
{
/// <summary>
/// Tool quality for welding.
/// </summary>
[DataField("weldingQuality", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
[ViewVariables(VVAccess.ReadWrite)]
public string WeldingQuality = "Welding";
/// <summary>
/// Whether this entity can ever be welded shut.
/// </summary>
[DataField("weldable")]
[ViewVariables(VVAccess.ReadWrite)]
public bool Weldable = true;
/// <summary>
/// How much time does it take to weld/unweld entity.
/// </summary>
[DataField("time")]
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan WeldingTime = TimeSpan.FromSeconds(1f);
/// <summary>
/// Shown when welded entity is examined.
/// </summary>
[DataField("weldedExamineMessage")]
[ViewVariables(VVAccess.ReadWrite)]
public string? WeldedExamineMessage = "weldable-component-examine-is-welded";
/// <summary>
/// Is this entity currently welded shut?
/// </summary>
[DataField("isWelded")]
public bool IsWelded;
}

View File

@@ -119,12 +119,6 @@ public abstract partial class SharedEntityStorageComponent : Component
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public Container Contents = default!; public Container Contents = default!;
/// <summary>
/// Whether or not the storage has been welded shut
/// </summary>
[DataField("isWeldedShut"), ViewVariables(VVAccess.ReadWrite)]
public bool IsWeldedShut;
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]
@@ -140,16 +134,13 @@ public sealed class EntityStorageComponentState : ComponentState
public float EnteringRange; public float EnteringRange;
public bool IsWeldedShut; public EntityStorageComponentState(bool open, int capacity, bool isCollidableWhenOpen, bool openOnMove, float enteringRange)
public EntityStorageComponentState(bool open, int capacity, bool isCollidableWhenOpen, bool openOnMove, float enteringRange, bool isWeldedShut)
{ {
Open = open; Open = open;
Capacity = capacity; Capacity = capacity;
IsCollidableWhenOpen = isCollidableWhenOpen; IsCollidableWhenOpen = isCollidableWhenOpen;
OpenOnMove = openOnMove; OpenOnMove = openOnMove;
EnteringRange = enteringRange; EnteringRange = enteringRange;
IsWeldedShut = isWeldedShut;
} }
} }

View File

@@ -12,6 +12,7 @@ using Content.Shared.Movement.Events;
using Content.Shared.Placeable; using Content.Shared.Placeable;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
using Content.Shared.Tools.Systems;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Content.Shared.Wall; using Content.Shared.Wall;
using Content.Shared.Whitelist; using Content.Shared.Whitelist;
@@ -29,18 +30,19 @@ namespace Content.Shared.Storage.EntitySystems;
public abstract class SharedEntityStorageSystem : EntitySystem public abstract class SharedEntityStorageSystem : EntitySystem
{ {
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly INetManager _net = default!; [Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly PlaceableSurfaceSystem _placeableSurface = default!; [Dependency] private readonly PlaceableSurfaceSystem _placeableSurface = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!; [Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly SharedJointSystem _joints = default!; [Dependency] private readonly SharedJointSystem _joints = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly WeldableSystem _weldable = default!;
public const string ContainerName = "entity_storage"; public const string ContainerName = "entity_storage";
@@ -50,8 +52,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
component.Capacity, component.Capacity,
component.IsCollidableWhenOpen, component.IsCollidableWhenOpen,
component.OpenOnMove, component.OpenOnMove,
component.EnteringRange, component.EnteringRange);
component.IsWeldedShut);
} }
protected void OnHandleState(EntityUid uid, SharedEntityStorageComponent component, ref ComponentHandleState args) protected void OnHandleState(EntityUid uid, SharedEntityStorageComponent component, ref ComponentHandleState args)
@@ -63,7 +64,6 @@ public abstract class SharedEntityStorageSystem : EntitySystem
component.IsCollidableWhenOpen = state.IsCollidableWhenOpen; component.IsCollidableWhenOpen = state.IsCollidableWhenOpen;
component.OpenOnMove = state.OpenOnMove; component.OpenOnMove = state.OpenOnMove;
component.EnteringRange = state.EnteringRange; component.EnteringRange = state.EnteringRange;
component.IsWeldedShut = state.IsWeldedShut;
} }
protected virtual void OnComponentInit(EntityUid uid, SharedEntityStorageComponent component, ComponentInit args) protected virtual void OnComponentInit(EntityUid uid, SharedEntityStorageComponent component, ComponentInit args)
@@ -323,10 +323,10 @@ public abstract class SharedEntityStorageSystem : EntitySystem
if (!HasComp<HandsComponent>(user)) if (!HasComp<HandsComponent>(user))
return false; return false;
if (component.IsWeldedShut) if (_weldable.IsWelded(target))
{ {
if (!silent && !component.Contents.Contains(user) && _net.IsServer) if (!silent && !component.Contents.Contains(user))
Popup.PopupEntity(Loc.GetString("entity-storage-component-welded-shut-message"), target); Popup.PopupClient(Loc.GetString("entity-storage-component-welded-shut-message"), target, user);
return false; return false;
} }

View File

@@ -1,9 +1,10 @@
using Content.Server.Tools.Systems;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Tools.Systems;
using Robust.Shared.GameStates;
namespace Content.Server.Tools.Components; namespace Content.Shared.Tools.Components;
[RegisterComponent] [RegisterComponent, NetworkedComponent]
[Access(typeof(WeldableSystem))] [Access(typeof(WeldableSystem))]
public sealed partial class LayerChangeOnWeldComponent : Component public sealed partial class LayerChangeOnWeldComponent : Component
{ {

View File

@@ -1,10 +1,39 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Tools.Components; namespace Content.Shared.Tools.Components;
public abstract partial class SharedWeldableComponent : Component [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class WeldableComponent : Component
{ {
/// <summary>
/// Tool quality for welding.
/// </summary>
[DataField("weldingQuality", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
[ViewVariables(VVAccess.ReadWrite)]
public string WeldingQuality = "Welding";
/// <summary>
/// How much time does it take to weld/unweld entity.
/// </summary>
[DataField("time")]
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public TimeSpan WeldingTime = TimeSpan.FromSeconds(1f);
/// <summary>
/// Shown when welded entity is examined.
/// </summary>
[DataField("weldedExamineMessage")]
[ViewVariables(VVAccess.ReadWrite)]
public string? WeldedExamineMessage = "weldable-component-examine-is-welded";
/// <summary>
/// Is this entity currently welded shut?
/// </summary>
[DataField("isWelded"), AutoNetworkedField]
public bool IsWelded;
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -0,0 +1,17 @@
namespace Content.Shared.Tools.Systems;
/// <summary>
/// Checks that entity can be weld/unweld.
/// Raised twice: before do_after and after to check that entity still valid.
/// </summary>
public sealed class WeldableAttemptEvent : CancellableEntityEventArgs
{
public readonly EntityUid User;
public readonly EntityUid Tool;
public WeldableAttemptEvent(EntityUid user, EntityUid tool)
{
User = user;
Tool = tool;
}
}

View File

@@ -0,0 +1,12 @@
using Content.Shared.Tools.Components;
namespace Content.Shared.Tools.Systems;
/// <summary>
/// Raised when <see cref="WeldableComponent"/> has changed.
/// </summary>
[ByRefEvent]
public readonly record struct WeldableChangedEvent(bool IsWelded)
{
public readonly bool IsWelded = IsWelded;
}

View File

@@ -1,29 +1,28 @@
using Content.Server.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Server.Construction;
using Content.Server.Tools.Components;
using Content.Server.Wires;
using Content.Shared.Construction.Steps;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Tools;
using Content.Shared.Tools.Components; using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
using Content.Shared.Wires;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
using System.Linq; using LayerChangeOnWeldComponent = Content.Shared.Tools.Components.LayerChangeOnWeldComponent;
namespace Content.Server.Tools.Systems; namespace Content.Shared.Tools.Systems;
public sealed class WeldableSystem : EntitySystem public sealed class WeldableSystem : EntitySystem
{ {
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedToolSystem _toolSystem = default!; [Dependency] private readonly SharedToolSystem _toolSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ConstructionSystem _construction = default!;
public bool IsWelded(EntityUid uid, WeldableComponent? component = null)
{
if (!Resolve(uid, ref component, false))
return false;
return component.IsWelded;
}
public override void Initialize() public override void Initialize()
{ {
@@ -43,12 +42,14 @@ public sealed class WeldableSystem : EntitySystem
private void OnInteractUsing(EntityUid uid, WeldableComponent component, InteractUsingEvent args) private void OnInteractUsing(EntityUid uid, WeldableComponent component, InteractUsingEvent args)
{ {
// If any construction graph edges has its conditions meet and requires welding, then this construction takes priority // If any construction graph edges has its conditions meet and requires welding, then this construction takes priority
if (_construction.GetCurrentNode(uid)?.Edges.Any(x => _construction.CheckConditions(uid, x.Conditions) /* TODO: Whatever this is is not the way to do what you think you want to do.
&& x.Steps.Any(y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true) if (Enumerable.Any<ConstructionGraphEdge>(_construction.GetCurrentNode(uid)?.Edges, x => _construction.CheckConditions(uid, x.Conditions)
&& Enumerable.Any<ConstructionGraphStep>(x.Steps, y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true)
{ {
args.Handled = false; args.Handled = false;
return; return;
} }
*/
if (args.Handled) if (args.Handled)
return; return;
@@ -61,13 +62,9 @@ public sealed class WeldableSystem : EntitySystem
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return false; return false;
// Basic checks
if (!component.Weldable)
return false;
// Other component systems // Other component systems
var attempt = new WeldableAttemptEvent(user, tool); var attempt = new WeldableAttemptEvent(user, tool);
RaiseLocalEvent(uid, attempt, true); RaiseLocalEvent(uid, attempt);
if (attempt.Cancelled) if (attempt.Cancelled)
return false; return false;
@@ -100,16 +97,13 @@ public sealed class WeldableSystem : EntitySystem
if (!CanWeld(uid, args.Used.Value, args.User, component)) if (!CanWeld(uid, args.Used.Value, args.User, component))
return; return;
component.IsWelded = !component.IsWelded; SetWeldedState(uid, !component.IsWelded, component);
RaiseLocalEvent(uid, new WeldableChangedEvent(component.IsWelded), true);
UpdateAppearance(uid, component);
// Log success // Log success
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.User):user} {(!component.IsWelded ? "un" : "")}welded {ToPrettyString(uid):target}"); _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.User):user} {(!component.IsWelded ? "un" : "")}welded {ToPrettyString(uid):target}");
} }
private void OnWeldChanged(EntityUid uid, LayerChangeOnWeldComponent component, WeldableChangedEvent args) private void OnWeldChanged(EntityUid uid, LayerChangeOnWeldComponent component, ref WeldableChangedEvent args)
{ {
if (!TryComp<FixturesComponent>(uid, out var fixtures)) if (!TryComp<FixturesComponent>(uid, out var fixtures))
return; return;
@@ -139,51 +133,31 @@ public sealed class WeldableSystem : EntitySystem
_appearance.SetData(uid, WeldableVisuals.IsWelded, component.IsWelded, appearance); _appearance.SetData(uid, WeldableVisuals.IsWelded, component.IsWelded, appearance);
} }
public void ForceWeldedState(EntityUid uid, bool state, WeldableComponent? component = null) public void SetWeldedState(EntityUid uid, bool state, WeldableComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
if (component.IsWelded == state)
return;
component.IsWelded = state; component.IsWelded = state;
var ev = new WeldableChangedEvent(component.IsWelded);
RaiseLocalEvent(uid, new WeldableChangedEvent(component.IsWelded)); RaiseLocalEvent(uid, ref ev);
UpdateAppearance(uid, component); UpdateAppearance(uid, component);
Dirty(uid, component);
} }
public void SetWeldingTime(EntityUid uid, TimeSpan time, WeldableComponent? component = null) public void SetWeldingTime(EntityUid uid, TimeSpan time, WeldableComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
if (component.WeldingTime.Equals(time))
return;
component.WeldingTime = time; component.WeldingTime = time;
} Dirty(uid, component);
}
/// <summary>
/// Checks that entity can be weld/unweld.
/// Raised twice: before do_after and after to check that entity still valid.
/// </summary>
public sealed class WeldableAttemptEvent : CancellableEntityEventArgs
{
public readonly EntityUid User;
public readonly EntityUid Tool;
public WeldableAttemptEvent(EntityUid user, EntityUid tool)
{
User = user;
Tool = tool;
}
}
/// <summary>
/// Raised when <see cref="WeldableComponent.IsWelded"/> has changed.
/// </summary>
public sealed class WeldableChangedEvent : EntityEventArgs
{
public readonly bool IsWelded;
public WeldableChangedEvent(bool isWelded)
{
IsWelded = isWelded;
} }
} }