Fix embedded projectile deletion not being tracked by container (#36123)
* Remove deleted projectiles from the container tracking them * Gotta dirty the container * Remove the container component when all embedded projectiles are gone * Add test * No clientside deletion of networked entities * Move cleanup logic before deletion
This commit is contained in:
@@ -39,6 +39,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, ThrowDoHitEvent>(OnEmbedThrowDoHit);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, RemoveEmbeddedProjectileEvent>(OnEmbedRemove);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, ComponentShutdown>(OnEmbeddableCompShutdown);
|
||||
|
||||
SubscribeLocalEvent<EmbeddedContainerComponent, EntityTerminatingEvent>(OnEmbeddableTermination);
|
||||
}
|
||||
@@ -75,6 +76,11 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
_hands.TryPickupAnyHand(args.User, embeddable);
|
||||
}
|
||||
|
||||
private void OnEmbeddableCompShutdown(Entity<EmbeddableProjectileComponent> embeddable, ref ComponentShutdown arg)
|
||||
{
|
||||
EmbedDetach(embeddable, embeddable.Comp);
|
||||
}
|
||||
|
||||
private void OnEmbedThrowDoHit(Entity<EmbeddableProjectileComponent> embeddable, ref ThrowDoHitEvent args)
|
||||
{
|
||||
if (!embeddable.Comp.EmbedOnThrow)
|
||||
@@ -130,16 +136,21 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
if (component.DeleteOnRemove)
|
||||
{
|
||||
QueueDel(uid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.EmbeddedIntoUid is not null)
|
||||
{
|
||||
if (TryComp<EmbeddedContainerComponent>(component.EmbeddedIntoUid.Value, out var embeddedContainer))
|
||||
{
|
||||
embeddedContainer.EmbeddedObjects.Remove(uid);
|
||||
Dirty(component.EmbeddedIntoUid.Value, embeddedContainer);
|
||||
if (embeddedContainer.EmbeddedObjects.Count == 0)
|
||||
RemCompDeferred<EmbeddedContainerComponent>(component.EmbeddedIntoUid.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (component.DeleteOnRemove && _net.IsServer)
|
||||
{
|
||||
QueueDel(uid);
|
||||
return;
|
||||
}
|
||||
|
||||
var xform = Transform(uid);
|
||||
|
||||
Reference in New Issue
Block a user