forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polymorph Artifact Effect (space-wizards#20660)
Co-authored-by: Nemanja <[email protected]>
- Loading branch information
1 parent
e7a453e
commit ad17adf
Showing
5 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/PolyArtifactComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Robust.Shared.Audio; | ||
using Content.Shared.Polymorph; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; | ||
|
||
/// <summary> | ||
/// Artifact polymorphs surrounding entities when triggered. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class PolyArtifactComponent : Component | ||
{ | ||
/// <summary> | ||
/// The polymorph effect to trigger. | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<PolymorphPrototype> PolymorphPrototypeName = "ArtifactMonkey"; | ||
|
||
/// <summary> | ||
/// range of the effect. | ||
/// </summary> | ||
[DataField] | ||
public float Range = 2f; | ||
|
||
/// <summary> | ||
/// Sound to play on polymorph. | ||
/// </summary> | ||
[DataField] | ||
public SoundSpecifier PolySound = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/Magic/staff_animation.ogg"); | ||
} |
41 changes: 41 additions & 0 deletions
41
Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/PolyArtifactSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; | ||
using Content.Server.Xenoarchaeology.XenoArtifacts.Events; | ||
using Content.Shared.Humanoid; | ||
using Content.Server.Polymorph.Systems; | ||
using Content.Shared.Mobs.Systems; | ||
using Content.Shared.Polymorph; | ||
|
||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; | ||
|
||
public sealed class PolyArtifactSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly EntityLookupSystem _lookup = default!; | ||
[Dependency] private readonly MobStateSystem _mob = default!; | ||
[Dependency] private readonly PolymorphSystem _poly = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
|
||
/// <summary> | ||
/// On effect trigger polymorphs targets in range. | ||
/// </summary> | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<PolyArtifactComponent, 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) | ||
{ | ||
var xform = Transform(uid); | ||
foreach (var comp in _lookup.GetComponentsInRange<HumanoidAppearanceComponent>(xform.Coordinates, component.Range)) | ||
{ | ||
var target = comp.Owner; | ||
if (_mob.IsAlive(target)) | ||
{ | ||
_poly.PolymorphEntity(target, component.PolymorphPrototypeName); | ||
_audio.PlayPvs(component.PolySound, uid); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters