-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figures can now be activated remotely #32769
Merged
SlamBamActionman
merged 11 commits into
space-wizards:master
from
beck-thompson:figure-activate-update
Dec 16, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
da103d6
First commit
beck-thompson e61ff3c
Merge branch 'master' into figure-activate-update
beck-thompson b25244c
I'm silly
beck-thompson 9e7d20e
weh
beck-thompson d8517ab
will this work?
beck-thompson 6e4dc7f
Merge branch 'master' into figure-activate-update
beck-thompson e8b7af3
Better design
beck-thompson 98713f5
Merge branch 'master' into figure-activate-update
beck-thompson 0322877
Fixes!
beck-thompson 370cc39
rider :(
beck-thompson acaf5eb
L rider
beck-thompson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some documentation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it in the component! That's usually how I see it done (At least for this it would be copy pasted the same from the component). I feel like it should either be in one or the other and I guess I feel like component makes more sense. Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, it doesn't hurt but won't be a blocker.
Usually the components have the documentation since one system can handle multiple components.