Remove Comp.Owner from CableAnchorStateChangedEvent (#44629)

* Remove Comp.Owner from CableAnchorStateChangedEvent

* actually can be simplified
This commit is contained in:
B_Kirill 2026-07-13 16:09:30 +10:00 • committed by GitHub
parent 2ccee7bbb3
commit 96c11f9fd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 13 deletions

View file

@ -1,10 +1,8 @@
using Content.Server.Power.EntitySystems;
using Content.Shared.Power;
using Content.Shared.Tools;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using System.Diagnostics.Tracing;
using Content.Shared.Tools.Systems;
using Robust.Shared.Prototypes;
namespace Content.Server.Power.Components;
@ -28,10 +26,10 @@ public sealed partial class CableComponent : Component
/// Checked by <see cref="CablePlacerComponent"/> to determine if there is
/// already a cable of a type on a tile.
/// </summary>
[DataField("cableType")]
[DataField]
public CableType CableType = CableType.HighVoltage;
[DataField("cuttingDelay")]
[DataField]
public float CuttingDelay = 1f;
}
@ -41,18 +39,17 @@ public sealed partial class CableComponent : Component
[ByRefEvent]
public readonly struct CableAnchorStateChangedEvent
{
public readonly TransformComponent Transform;
public EntityUid Entity => Transform.Owner;
public bool Anchored => Transform.Anchored;
public readonly Entity<TransformComponent> Cable;
public bool Anchored => Cable.Comp.Anchored;
/// <summary>
/// If true, the entity is being detached to null-space
/// </summary>
public readonly bool Detaching;
public CableAnchorStateChangedEvent(TransformComponent transform, bool detaching = false)
public CableAnchorStateChangedEvent(Entity<TransformComponent> cable, bool detaching = false)
{
Cable = cable;
Detaching = detaching;
Transform = transform;
}
}

View file

@ -47,7 +47,7 @@ public sealed partial class CableSystem : EntitySystem
return;
var xform = Transform(uid);
var ev = new CableAnchorStateChangedEvent(xform);
var ev = new CableAnchorStateChangedEvent((uid, xform));
RaiseLocalEvent(uid, ref ev);
if (_electrocutionSystem.TryDoElectrifiedAct(uid, args.User))
@ -61,7 +61,7 @@ public sealed partial class CableSystem : EntitySystem
private void OnAnchorChanged(EntityUid uid, CableComponent cable, ref AnchorStateChangedEvent args)
{
var ev = new CableAnchorStateChangedEvent(args.Transform, args.Detaching);
var ev = new CableAnchorStateChangedEvent((uid, args.Transform), args.Detaching);
RaiseLocalEvent(uid, ref ev);
if (args.Anchored)

View file

@ -152,7 +152,7 @@ internal sealed partial class PowerMonitoringConsoleSystem : SharedPowerMonitori
public void OnCableAnchorStateChanged(EntityUid uid, CableComponent component, CableAnchorStateChangedEvent args)
{
var xform = args.Transform;
var xform = args.Cable.Comp;
if (xform.GridUid == null || !TryComp<MapGridComponent>(xform.GridUid, out var grid))
return;