forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from TheGrimbeeper/artifacts
Additional Artifact effects
- Loading branch information
Showing
8 changed files
with
385 additions
and
7 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactResurrectionTriggerComponent.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,14 @@ | ||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; | ||
|
||
/// <summary> | ||
/// Triggers when a nearby entity is resurrected | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ArtifactResurrectionTriggerComponent : Component | ||
{ | ||
/// <summary> | ||
/// How close to the resurrection the artifact has to be for it to trigger. | ||
/// </summary> | ||
[DataField("range")] | ||
public float Range = 15f; | ||
} |
41 changes: 41 additions & 0 deletions
41
...erver/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactResurrectionTriggerSystem.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.Triggers.Components; | ||
using Content.Shared.Mobs; | ||
|
||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; | ||
|
||
public sealed class ArtifactResurrectionTriggerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ArtifactSystem _artifact = default!; | ||
|
||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<MobStateChangedEvent>(OnMobStateChanged); | ||
} | ||
|
||
private void OnMobStateChanged(MobStateChangedEvent ev) | ||
{ | ||
if (ev.OldMobState != MobState.Dead || ev.NewMobState == MobState.Dead) | ||
return; | ||
|
||
var resurrectionXform = Transform(ev.Target); | ||
|
||
var toActivate = new List<Entity<ArtifactResurrectionTriggerComponent>>(); | ||
var query = EntityQueryEnumerator<ArtifactResurrectionTriggerComponent, TransformComponent>(); | ||
while (query.MoveNext(out var uid, out var trigger, out var xform)) | ||
{ | ||
if (!resurrectionXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance)) | ||
continue; | ||
|
||
if (distance > trigger.Range) | ||
continue; | ||
|
||
toActivate.Add((uid, trigger)); | ||
} | ||
|
||
foreach (var a in toActivate) | ||
{ | ||
_artifact.TryActivateArtifact(a); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.