Weldable cleanup (#19809)
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.Client.Tools.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class WeldableComponent : SharedWeldableComponent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Client.Tools.Components;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Linq;
|
||||
using Content.IntegrationTests.Tests.Construction.Interaction;
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.IntegrationTests.Tests.Weldable;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.DoAfter;
|
||||
|
||||
@@ -100,11 +100,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
|
||||
await SpawnTarget(WeldableTests.Locker);
|
||||
var comp = Comp<WeldableComponent>();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(comp.Weldable, Is.True);
|
||||
Assert.That(comp.IsWelded, Is.False);
|
||||
});
|
||||
|
||||
await Interact(Weld, awaitDoAfters: false);
|
||||
await RunTicks(1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.IntegrationTests.Tests.Interaction;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Weldable;
|
||||
|
||||
@@ -16,11 +16,7 @@ public sealed class WeldableTests : InteractionTest
|
||||
await SpawnTarget(Locker);
|
||||
var comp = Comp<WeldableComponent>();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(comp.Weldable, Is.True);
|
||||
Assert.That(comp.IsWelded, Is.False);
|
||||
});
|
||||
|
||||
await Interact(Weld);
|
||||
Assert.That(comp.IsWelded, Is.True);
|
||||
|
||||
@@ -18,7 +18,6 @@ using Content.Server.Storage.Components;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Server.Tabletop;
|
||||
using Content.Server.Tabletop.Components;
|
||||
using Content.Server.Tools.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
@@ -39,6 +38,7 @@ using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Tabletop.Components;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
@@ -677,7 +677,7 @@ public sealed partial class AdminVerbSystem
|
||||
_entityStorageSystem.Insert(args.Target, locker, storage);
|
||||
_entityStorageSystem.ToggleOpen(args.Target, locker, storage);
|
||||
}
|
||||
_weldableSystem.ForceWeldedState(locker, true);
|
||||
_weldableSystem.SetWeldedState(locker, true);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = Loc.GetString("admin-smite-locker-stuff-description"),
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
{
|
||||
// The world if people documented their shit.
|
||||
[RegisterComponent]
|
||||
public sealed partial class GasVentPumpComponent : Component
|
||||
{
|
||||
@@ -14,9 +15,6 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
[ViewVariables]
|
||||
public bool IsDirty { get; set; } = false;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Welded { get; set; } = false;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("inlet")]
|
||||
public string Inlet { get; set; } = "pipe";
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
[ViewVariables]
|
||||
public bool IsDirty { get; set; } = false;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Welded { get; set; } = false;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("outlet")]
|
||||
public string OutletName { get; set; } = "pipe";
|
||||
|
||||
@@ -11,13 +11,13 @@ using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Tools.Systems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.Atmos.Visuals;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -29,9 +29,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
||||
[Dependency] private readonly WeldableSystem _weldable = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -53,7 +54,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
//Bingo waz here
|
||||
if (vent.Welded)
|
||||
if (_weldable.IsWelded(uid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
}
|
||||
|
||||
var timeDelta = args.dt;
|
||||
var pressureDelta = (float) timeDelta * vent.TargetPressureChange;
|
||||
var pressureDelta = timeDelta * vent.TargetPressureChange;
|
||||
|
||||
if (vent.PumpDirection == VentPumpDirection.Releasing && pipe.Air.Pressure > 0)
|
||||
{
|
||||
@@ -255,7 +256,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
return;
|
||||
|
||||
_ambientSoundSystem.SetAmbience(uid, true);
|
||||
if (vent.Welded)
|
||||
if (_weldable.IsWelded(uid))
|
||||
{
|
||||
_ambientSoundSystem.SetAmbience(uid, false);
|
||||
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance);
|
||||
@@ -311,10 +312,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Tools.Systems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping.Unary.Visuals;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -26,10 +26,11 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
||||
[Dependency] private readonly WeldableSystem _weldable = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
if (scrubber.Welded)
|
||||
if (_weldable.IsWelded(uid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +186,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
return;
|
||||
|
||||
_ambientSoundSystem.SetAmbience(uid, true);
|
||||
if (scrubber.Welded)
|
||||
if (_weldable.IsWelded(uid))
|
||||
{
|
||||
_ambientSoundSystem.SetAmbience(uid, false);
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Construction.Conditions
|
||||
@@ -14,10 +15,7 @@ namespace Content.Server.Construction.Conditions
|
||||
|
||||
public bool Condition(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(uid, out EntityStorageComponent? entityStorageComponent))
|
||||
return false;
|
||||
|
||||
return entityStorageComponent.IsWeldedShut == Welded;
|
||||
return entityManager.System<WeldableSystem>().IsWelded(uid);
|
||||
}
|
||||
|
||||
public bool DoExamine(ExaminedEvent args)
|
||||
@@ -25,11 +23,12 @@ namespace Content.Server.Construction.Conditions
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
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);
|
||||
|
||||
if (entityStorage.IsWeldedShut != Welded)
|
||||
if (entMan.System<WeldableSystem>().IsWelded(entity) != Welded)
|
||||
{
|
||||
if (Welded)
|
||||
args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", metaData.EntityName)) + "\n");
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Objectives\Interfaces\" />
|
||||
<Folder Include="Tools\Systems\" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -2,7 +2,6 @@ using Content.Server.Access;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Tools.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Doors.Components;
|
||||
@@ -18,6 +17,7 @@ using Content.Shared.Tools;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Tools.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)
|
||||
SetState(uid, DoorState.Welded, component);
|
||||
|
||||
@@ -15,6 +15,7 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
@@ -42,6 +43,7 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
[Dependency] private readonly PuddleSystem _puddle = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
|
||||
[Dependency] private readonly WeldableSystem _weldable = default!;
|
||||
|
||||
private EntityQuery<TransformComponent> _xformQuery;
|
||||
|
||||
@@ -195,7 +197,7 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6,15 +6,18 @@ using Content.Shared.Lock;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Resist;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Tools.Systems;
|
||||
|
||||
namespace Content.Server.Resist;
|
||||
|
||||
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 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()
|
||||
{
|
||||
@@ -31,7 +34,7 @@ public sealed class ResistLockerSystem : EntitySystem
|
||||
if (!TryComp(uid, out EntityStorageComponent? storageComponent))
|
||||
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);
|
||||
}
|
||||
@@ -69,10 +72,11 @@ public sealed class ResistLockerSystem : EntitySystem
|
||||
|
||||
component.IsResisting = false;
|
||||
|
||||
if (TryComp<EntityStorageComponent>(uid, out var storageComponent))
|
||||
if (HasComp<EntityStorageComponent>(uid))
|
||||
{
|
||||
if (storageComponent.IsWeldedShut)
|
||||
storageComponent.IsWeldedShut = false;
|
||||
WeldableComponent? weldable = null;
|
||||
if (_weldable.IsWelded(uid, weldable))
|
||||
_weldable.SetWeldedState(uid, false, weldable);
|
||||
|
||||
if (TryComp<LockComponent>(args.Args.Target.Value, out var lockComponent))
|
||||
_lockSystem.Unlock(uid, args.Args.User, lockComponent);
|
||||
|
||||
@@ -3,7 +3,6 @@ using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Resist;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Tools.Systems;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.DoAfter;
|
||||
@@ -11,6 +10,7 @@ using Content.Shared.Lock;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -327,13 +327,12 @@ public sealed class BluespaceLockerSystem : EntitySystem
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target.Value.storageComponent.IsWeldedShut)
|
||||
if (_weldableSystem.IsWelded(target.Value.uid))
|
||||
{
|
||||
// It gets bluespaced open...
|
||||
_weldableSystem.ForceWeldedState(target.Value.uid, false);
|
||||
if (target.Value.storageComponent.IsWeldedShut)
|
||||
target.Value.storageComponent.IsWeldedShut = false;
|
||||
_weldableSystem.SetWeldedState(target.Value.uid, false);
|
||||
}
|
||||
|
||||
LockComponent? lockComponent = null;
|
||||
if (Resolve(target.Value.uid, ref lockComponent, false) && lockComponent.Locked)
|
||||
_lockSystem.Unlock(target.Value.uid, target.Value.uid, lockComponent);
|
||||
|
||||
@@ -3,7 +3,6 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Tools.Systems;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Foldable;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -11,6 +10,7 @@ using Content.Shared.Lock;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -44,7 +44,6 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
|
||||
|
||||
SubscribeLocalEvent<EntityStorageComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
|
||||
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
|
||||
|
||||
SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale);
|
||||
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)
|
||||
{
|
||||
if (!component.Airtight)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -119,12 +119,6 @@ public abstract partial class SharedEntityStorageComponent : Component
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
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]
|
||||
@@ -140,16 +134,13 @@ public sealed class EntityStorageComponentState : ComponentState
|
||||
|
||||
public float EnteringRange;
|
||||
|
||||
public bool IsWeldedShut;
|
||||
|
||||
public EntityStorageComponentState(bool open, int capacity, bool isCollidableWhenOpen, bool openOnMove, float enteringRange, bool isWeldedShut)
|
||||
public EntityStorageComponentState(bool open, int capacity, bool isCollidableWhenOpen, bool openOnMove, float enteringRange)
|
||||
{
|
||||
Open = open;
|
||||
Capacity = capacity;
|
||||
IsCollidableWhenOpen = isCollidableWhenOpen;
|
||||
OpenOnMove = openOnMove;
|
||||
EnteringRange = enteringRange;
|
||||
IsWeldedShut = isWeldedShut;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Placeable;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Wall;
|
||||
using Content.Shared.Whitelist;
|
||||
@@ -41,6 +42,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly WeldableSystem _weldable = default!;
|
||||
|
||||
public const string ContainerName = "entity_storage";
|
||||
|
||||
@@ -50,8 +52,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
component.Capacity,
|
||||
component.IsCollidableWhenOpen,
|
||||
component.OpenOnMove,
|
||||
component.EnteringRange,
|
||||
component.IsWeldedShut);
|
||||
component.EnteringRange);
|
||||
}
|
||||
|
||||
protected void OnHandleState(EntityUid uid, SharedEntityStorageComponent component, ref ComponentHandleState args)
|
||||
@@ -63,7 +64,6 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
component.IsCollidableWhenOpen = state.IsCollidableWhenOpen;
|
||||
component.OpenOnMove = state.OpenOnMove;
|
||||
component.EnteringRange = state.EnteringRange;
|
||||
component.IsWeldedShut = state.IsWeldedShut;
|
||||
}
|
||||
|
||||
protected virtual void OnComponentInit(EntityUid uid, SharedEntityStorageComponent component, ComponentInit args)
|
||||
@@ -323,10 +323,10 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
if (!HasComp<HandsComponent>(user))
|
||||
return false;
|
||||
|
||||
if (component.IsWeldedShut)
|
||||
if (_weldable.IsWelded(target))
|
||||
{
|
||||
if (!silent && !component.Contents.Contains(user) && _net.IsServer)
|
||||
Popup.PopupEntity(Loc.GetString("entity-storage-component-welded-shut-message"), target);
|
||||
if (!silent && !component.Contents.Contains(user))
|
||||
Popup.PopupClient(Loc.GetString("entity-storage-component-welded-shut-message"), target, user);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using Content.Server.Tools.Systems;
|
||||
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))]
|
||||
public sealed partial class LayerChangeOnWeldComponent : Component
|
||||
{
|
||||
@@ -1,10 +1,39 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
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]
|
||||
|
||||
17
Content.Shared/Tools/Systems/WeldableAttemptEvent.cs
Normal file
17
Content.Shared/Tools/Systems/WeldableAttemptEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
12
Content.Shared/Tools/Systems/WeldableChangedEvent.cs
Normal file
12
Content.Shared/Tools/Systems/WeldableChangedEvent.cs
Normal 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;
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Construction.Steps;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Shared.Physics;
|
||||
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
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = 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()
|
||||
{
|
||||
@@ -43,12 +42,14 @@ public sealed class WeldableSystem : EntitySystem
|
||||
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 (_construction.GetCurrentNode(uid)?.Edges.Any(x => _construction.CheckConditions(uid, x.Conditions)
|
||||
&& x.Steps.Any(y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true)
|
||||
/* TODO: Whatever this is is not the way to do what you think you want to do.
|
||||
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;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if (args.Handled)
|
||||
return;
|
||||
@@ -61,13 +62,9 @@ public sealed class WeldableSystem : EntitySystem
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
|
||||
// Basic checks
|
||||
if (!component.Weldable)
|
||||
return false;
|
||||
|
||||
// Other component systems
|
||||
var attempt = new WeldableAttemptEvent(user, tool);
|
||||
RaiseLocalEvent(uid, attempt, true);
|
||||
RaiseLocalEvent(uid, attempt);
|
||||
if (attempt.Cancelled)
|
||||
return false;
|
||||
|
||||
@@ -100,16 +97,13 @@ public sealed class WeldableSystem : EntitySystem
|
||||
if (!CanWeld(uid, args.Used.Value, args.User, component))
|
||||
return;
|
||||
|
||||
component.IsWelded = !component.IsWelded;
|
||||
RaiseLocalEvent(uid, new WeldableChangedEvent(component.IsWelded), true);
|
||||
|
||||
UpdateAppearance(uid, component);
|
||||
SetWeldedState(uid, !component.IsWelded, component);
|
||||
|
||||
// Log success
|
||||
_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))
|
||||
return;
|
||||
@@ -139,51 +133,31 @@ public sealed class WeldableSystem : EntitySystem
|
||||
_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))
|
||||
return;
|
||||
|
||||
if (component.IsWelded == state)
|
||||
return;
|
||||
|
||||
component.IsWelded = state;
|
||||
var ev = new WeldableChangedEvent(component.IsWelded);
|
||||
|
||||
RaiseLocalEvent(uid, new WeldableChangedEvent(component.IsWelded));
|
||||
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
UpdateAppearance(uid, component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
public void SetWeldingTime(EntityUid uid, TimeSpan time, WeldableComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
if (component.WeldingTime.Equals(time))
|
||||
return;
|
||||
|
||||
component.WeldingTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user