Fix Fultons losing their beacon when split (#20179)
This commit is contained in:
@@ -70,6 +70,9 @@ namespace Content.Server.Stack
|
||||
stackComp.Unlimited = false;
|
||||
}
|
||||
|
||||
var ev = new StackSplitEvent(entity);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed partial class FultonComponent : Component
|
||||
/// <summary>
|
||||
/// Linked fulton beacon.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("beacon")]
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("beacon"), AutoNetworkedField]
|
||||
public EntityUid? Beacon;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -43,6 +43,8 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
SubscribeLocalEvent<FultonedComponent, EntGotInsertedIntoContainerMessage>(OnFultonContainerInserted);
|
||||
|
||||
SubscribeLocalEvent<FultonComponent, AfterInteractEvent>(OnFultonInteract);
|
||||
|
||||
SubscribeLocalEvent<FultonComponent, StackSplitEvent>(OnFultonSplit);
|
||||
}
|
||||
|
||||
private void OnFultonContainerInserted(EntityUid uid, FultonedComponent component, EntGotInsertedIntoContainerMessage args)
|
||||
@@ -161,6 +163,13 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
});
|
||||
}
|
||||
|
||||
private void OnFultonSplit(EntityUid uid, FultonComponent component, ref StackSplitEvent args)
|
||||
{
|
||||
var newFulton = EnsureComp<FultonComponent>(args.NewId);
|
||||
newFulton.Beacon = component.Beacon;
|
||||
Dirty(args.NewId, newFulton);
|
||||
}
|
||||
|
||||
protected virtual void UpdateAppearance(EntityUid uid, FultonedComponent fultoned)
|
||||
{
|
||||
return;
|
||||
|
||||
8
Content.Shared/Stacks/StackSplitEvent.cs
Normal file
8
Content.Shared/Stacks/StackSplitEvent.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Content.Shared.Stacks;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on the original stack entity when it is split to create another.
|
||||
/// </summary>
|
||||
/// <param name="NewId">The entity id of the new stack.</param>
|
||||
[ByRefEvent]
|
||||
public readonly record struct StackSplitEvent(EntityUid NewId);
|
||||
Reference in New Issue
Block a user