forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 90
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 #1642 from TheGrimbeeper/artifact-expressions-trigger
New artifact trigger: Expressiveness
- Loading branch information
Showing
4 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...n/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactExpressionTriggerComponent.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 emotes | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ArtifactExpressionTriggerComponent : Component | ||
{ | ||
/// <summary> | ||
/// How close to the emote event the artifact has to be for it to trigger. | ||
/// </summary> | ||
[DataField("range")] | ||
public float Range = 2f; | ||
} |
38 changes: 38 additions & 0 deletions
38
...station/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactExpressionTriggerSystem.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,38 @@ | ||
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; | ||
using Content.Server.Chat.Systems; | ||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; | ||
|
||
public sealed class ArtifacExpressionTriggerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ArtifactSystem _artifact = default!; | ||
|
||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<TransformComponent, EmoteEvent>(OnEmote); | ||
} | ||
|
||
private void OnEmote(EntityUid emoter, TransformComponent component, EmoteEvent args) | ||
{ | ||
var emoterXform = Transform(emoter); | ||
|
||
var toActivate = new List<Entity<ArtifactExpressionTriggerComponent>>(); | ||
var query = EntityQueryEnumerator<ArtifactExpressionTriggerComponent, TransformComponent>(); | ||
|
||
while (query.MoveNext(out var uid, out var trigger, out var xform)) | ||
{ | ||
if (!emoterXform.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