Cleanups PolymorphSystem/Components/Prototypes (#23721)
* Cleanups PolymorphSystem * forgot this * Nah * Fix test --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
using Content.Server.Polymorph.Components;
|
||||
using Content.Shared.Polymorph;
|
||||
using Content.Shared.Projectiles;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Polymorph.Systems;
|
||||
|
||||
public partial class PolymorphSystem
|
||||
{
|
||||
// Need to do this so we don't get a collection enumeration error in physics by polymorphing
|
||||
// an entity we're colliding with
|
||||
/// <summary>
|
||||
/// Need to do this so we don't get a collection enumeration error in physics by polymorphing
|
||||
/// an entity we're colliding with
|
||||
/// </summary>
|
||||
private Queue<PolymorphQueuedData> _queuedPolymorphUpdates = new();
|
||||
|
||||
private void InitializeCollide()
|
||||
{
|
||||
SubscribeLocalEvent<PolymorphOnCollideComponent, StartCollideEvent>(OnPolymorphCollide);
|
||||
}
|
||||
|
||||
public void UpdateCollide()
|
||||
{
|
||||
while (_queuedPolymorphUpdates.TryDequeue(out var data))
|
||||
@@ -20,25 +29,18 @@ public partial class PolymorphSystem
|
||||
|
||||
var ent = PolymorphEntity(data.Ent, data.Polymorph);
|
||||
if (ent != null)
|
||||
{
|
||||
_audio.PlayPvs(data.Sound, ent.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeCollide()
|
||||
{
|
||||
SubscribeLocalEvent<PolymorphOnCollideComponent, StartCollideEvent>(OnPolymorphCollide);
|
||||
}
|
||||
|
||||
private void OnPolymorphCollide(EntityUid uid, PolymorphOnCollideComponent component, ref StartCollideEvent args)
|
||||
{
|
||||
if (args.OurFixtureId != SharedProjectileSystem.ProjectileFixture)
|
||||
return;
|
||||
|
||||
var other = args.OtherEntity;
|
||||
if (!component.Whitelist.IsValid(other)
|
||||
|| component.Blacklist != null && component.Blacklist.IsValid(other))
|
||||
if (!component.Whitelist.IsValid(other, EntityManager)
|
||||
|| component.Blacklist != null && component.Blacklist.IsValid(other, EntityManager))
|
||||
return;
|
||||
|
||||
_queuedPolymorphUpdates.Enqueue(new (other, component.Sound, component.Polymorph));
|
||||
@@ -49,9 +51,9 @@ public struct PolymorphQueuedData
|
||||
{
|
||||
public EntityUid Ent;
|
||||
public SoundSpecifier Sound;
|
||||
public string Polymorph;
|
||||
public ProtoId<PolymorphPrototype> Polymorph;
|
||||
|
||||
public PolymorphQueuedData(EntityUid ent, SoundSpecifier sound, string polymorph)
|
||||
public PolymorphQueuedData(EntityUid ent, SoundSpecifier sound, ProtoId<PolymorphPrototype> polymorph)
|
||||
{
|
||||
Ent = ent;
|
||||
Sound = sound;
|
||||
|
||||
Reference in New Issue
Block a user