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.
Figures can now be activated remotely (space-wizards#32769)
* First commit * I'm silly * weh * will this work? * Better design * Fixes! * rider :( * L rider
- Loading branch information
1 parent
001b0ed
commit 74e9576
Showing
5 changed files
with
114 additions
and
105 deletions.
There are no files selected for viewing
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,17 @@ | ||
using Content.Shared.Dataset; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Chat; | ||
|
||
/// <summary> | ||
/// Makes the entity speak when triggered. If the item has UseDelay component, the system will respect that cooldown. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class SpeakOnTriggerComponent : Component | ||
{ | ||
/// <summary> | ||
/// The identifier for the dataset prototype containing messages to be spoken by this entity. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public ProtoId<LocalizedDatasetPrototype> Pack = string.Empty; | ||
} |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
using Content.Server.Explosion.EntitySystems; | ||
using Content.Shared.Timing; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.Chat.Systems; | ||
|
||
public sealed class SpeakOnTriggerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly UseDelaySystem _useDelay = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<SpeakOnTriggerComponent, TriggerEvent>(OnTrigger); | ||
} | ||
|
||
private void OnTrigger(Entity<SpeakOnTriggerComponent> ent, ref TriggerEvent args) | ||
{ | ||
TrySpeak(ent); | ||
args.Handled = true; | ||
} | ||
|
||
private void TrySpeak(Entity<SpeakOnTriggerComponent> ent) | ||
{ | ||
// If it doesn't have the use delay component, still send the message. | ||
if (TryComp<UseDelayComponent>(ent.Owner, out var useDelay) && _useDelay.IsDelayed((ent.Owner, useDelay))) | ||
return; | ||
|
||
if (!_prototypeManager.TryIndex(ent.Comp.Pack, out var messagePack)) | ||
return; | ||
|
||
var message = Loc.GetString(_random.Pick(messagePack.Values)); | ||
_chat.TrySendInGameICMessage(ent.Owner, message, InGameICChatType.Speak, true); | ||
|
||
if (useDelay != null) | ||
_useDelay.TryResetDelay((ent.Owner, useDelay)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.