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:
AJCM-git
2024-02-01 08:17:02 -04:00
committed by GitHub
parent c0227bcb3b
commit b8f0ed3975
17 changed files with 714 additions and 724 deletions

View File

@@ -1,3 +1,4 @@
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
using Robust.Shared.Audio;
using Content.Shared.Polymorph;
using Robust.Shared.Prototypes;
@@ -8,7 +9,8 @@ namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
/// Artifact polymorphs surrounding entities when triggered.
/// </summary>
[RegisterComponent]
public sealed partial class PolyArtifactComponent : Component
[Access(typeof(PolyOthersArtifactSystem))]
public sealed partial class PolyOthersArtifactComponent : Component
{
/// <summary>
/// The polymorph effect to trigger.

View File

@@ -7,7 +7,7 @@ using Robust.Shared.Audio.Systems;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
public sealed class PolyArtifactSystem : EntitySystem
public sealed class PolyOthersArtifactSystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly MobStateSystem _mob = default!;
@@ -19,25 +19,25 @@ public sealed class PolyArtifactSystem : EntitySystem
/// </summary>
public override void Initialize()
{
SubscribeLocalEvent<PolyArtifactComponent, ArtifactActivatedEvent>(OnActivate);
SubscribeLocalEvent<PolyOthersArtifactComponent, ArtifactActivatedEvent>(OnActivate);
}
/// <summary>
/// Provided target is alive and is not a zombie, polymorphs the target.
/// </summary>
private void OnActivate(EntityUid uid, PolyArtifactComponent component, ArtifactActivatedEvent args)
private void OnActivate(Entity<PolyOthersArtifactComponent> ent, ref ArtifactActivatedEvent args)
{
var xform = Transform(uid);
var xform = Transform(ent);
var humanoids = new HashSet<Entity<HumanoidAppearanceComponent>>();
_lookup.GetEntitiesInRange(xform.Coordinates, component.Range, humanoids);
_lookup.GetEntitiesInRange(xform.Coordinates, ent.Comp.Range, humanoids);
foreach (var comp in humanoids)
{
var target = comp.Owner;
if (_mob.IsAlive(target))
{
_poly.PolymorphEntity(target, component.PolymorphPrototypeName);
_audio.PlayPvs(component.PolySound, uid);
_poly.PolymorphEntity(target, ent.Comp.PolymorphPrototypeName);
_audio.PlayPvs(ent.Comp.PolySound, ent);
}
}
}