Fix Fultons losing their beacon when split (#20179)

This commit is contained in:
DrSmugleaf
2023-09-17 17:22:26 -07:00
committed by GitHub
parent d4abaf277a
commit c558f00a74
4 changed files with 21 additions and 1 deletions

View File

@@ -70,6 +70,9 @@ namespace Content.Server.Stack
stackComp.Unlimited = false;
}
var ev = new StackSplitEvent(entity);
RaiseLocalEvent(uid, ref ev);
return entity;
}

View File

@@ -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>

View File

@@ -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;

View 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);