-
Notifications
You must be signed in to change notification settings - Fork 592
Group Howl Event #5453
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
Merged
Merged
Group Howl Event #5453
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3bef8bf
Group Howl Event
Ohelig dccf0c2
moves the species restrictions to the gamerule proto, and also limits…
Ohelig 0e3760d
Adds any player-controlled entity with the DogEmotes tag (corgi, mcgr…
Ohelig b37109b
ok, rewrite to make work for borgis and xenoborgis too, even though …
Ohelig aa757a5
comment
Ohelig 57bc9c6
Ghosts can also hear it
Ohelig e03f99f
rework target grid finder
Ohelig 01ed6b6
Merge branch 'starlight-dev' into GroupHowlEvent
Ohelig 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
17 changes: 17 additions & 0 deletions
17
Content.Server/_Starlight/GameTicking/Rules/Components/FullMoonHowlRuleComponent.cs
This file contains hidden or 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 Robust.Shared.Audio; | ||
|
|
||
| namespace Content.Server._Starlight.GameTicking.Rules.Components; | ||
|
|
||
| [RegisterComponent, Access(typeof(FullMoonHowlRule))] | ||
| public sealed partial class FullMoonHowlRuleComponent : Component | ||
| { | ||
| [DataField] | ||
| public SoundSpecifier HowlSound = new SoundCollectionSpecifier("VulpkaninHowls"); | ||
|
|
||
| /// <summary> | ||
| /// Eligible entities are matched by <see cref="Content.Shared.Inventory.InventoryComponent.SpeciesId"/>. | ||
| /// Vulpkanin and ProtoVulp both use "vulpkanin"; corgis/borgis use "dog"; puppies/McGriff use "puppy". | ||
| /// </summary> | ||
| [DataField] | ||
| public HashSet<string> EligibleInventorySpecies = new() { "vulpkanin", "dog", "puppy" }; | ||
| } |
104 changes: 104 additions & 0 deletions
104
Content.Server/_Starlight/GameTicking/Rules/FullMoonHowlRule.cs
This file contains hidden or 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,104 @@ | ||
| using Content.Server._Starlight.GameTicking.Rules.Components; | ||
| using Content.Server.StationEvents.Components; | ||
| using Content.Server.Chat.Managers; | ||
| using Content.Server.StationEvents.Events; | ||
| using Content.Shared.Chat; | ||
| using Content.Shared.Ghost; | ||
| using Content.Shared.GameTicking.Components; | ||
| using Content.Shared.Inventory; | ||
| using Content.Shared.Pinpointer; | ||
| using Content.Shared.Station.Components; | ||
| using Robust.Shared.Player; | ||
| using Robust.Shared.Random; | ||
| using Robust.Shared.Utility; | ||
|
|
||
| namespace Content.Server._Starlight.GameTicking.Rules; | ||
|
|
||
| public sealed partial class FullMoonHowlRule : StationEventSystem<FullMoonHowlRuleComponent> | ||
| { | ||
| [Dependency] private IChatManager _chatManager = default!; | ||
|
|
||
| protected override void Started(EntityUid uid, FullMoonHowlRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
| { | ||
| base.Started(uid, component, gameRule, args); | ||
|
|
||
| if (!TryComp<StationEventComponent>(uid, out var stationEvent)) | ||
| return; | ||
|
|
||
| var chosenStation = stationEvent.TargetStation; | ||
| if (chosenStation is null && !TryGetRandomStation(out chosenStation)) | ||
| return; | ||
|
|
||
| if (!TryComp<StationDataComponent>(chosenStation.Value, out var stationData)) | ||
| return; | ||
|
|
||
| var mainGrids = stationData.MainGrids; | ||
|
|
||
| EntityUid? mainGrid = null; | ||
| foreach (var grid in mainGrids) | ||
| { | ||
| if (!Exists(grid)) | ||
| continue; | ||
|
|
||
| mainGrid = grid; | ||
| break; | ||
| } | ||
|
|
||
| if (mainGrid is null) | ||
| return; | ||
|
|
||
| // Recipients are selected by map, not grid, so off-grid players on the station map may still hear the announcement. | ||
| var mainStationMap = Transform(mainGrid.Value).MapID; | ||
|
|
||
| var recipients = Filter.Empty().AddWhere(session => | ||
| { | ||
| if (session.AttachedEntity is null) | ||
| return false; | ||
|
|
||
| var attached = session.AttachedEntity.Value; | ||
|
|
||
| if (Transform(attached).MapID != mainStationMap) | ||
| return false; | ||
|
|
||
| // Ghosts are always eligible to hear the announcement, for observer/admin purposes. | ||
| if (HasComp<GhostComponent>(attached)) | ||
| return true; | ||
|
|
||
| if (TryComp<InventoryComponent>(attached, out var inv) | ||
| && inv.SpeciesId is { } speciesId | ||
| && component.EligibleInventorySpecies.Contains(speciesId)) | ||
| return true; | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| // Location candidates are restricted to beacon entities on main station grids only. | ||
| var beaconLocations = new List<string>(); | ||
| var beaconQuery = EntityQueryEnumerator<NavMapBeaconComponent, TransformComponent>(); | ||
| while (beaconQuery.MoveNext(out var ent, out var beacon, out var xform)) | ||
| { | ||
| if (!beacon.Enabled) | ||
| continue; | ||
|
|
||
| if (xform.GridUid is not { } gridUid || !mainGrids.Contains(gridUid)) | ||
| continue; | ||
|
|
||
| var locationName = !string.IsNullOrWhiteSpace(beacon.Text) | ||
| ? beacon.Text | ||
| : MetaData(ent).EntityName; | ||
|
|
||
| if (!string.IsNullOrWhiteSpace(locationName)) | ||
| beaconLocations.Add(locationName); | ||
| } | ||
|
|
||
| var location = beaconLocations.Count > 0 | ||
| ? RobustRandom.Pick(beaconLocations) | ||
| : Loc.GetString("station-event-fullmoonhowl-default-location"); | ||
|
|
||
| var message = Loc.GetString("station-event-fullmoonhowl-announcement", ("location", (object) location)); | ||
| // Send as styled chat text to avoid default announcement header and keep the tone. | ||
| var wrappedMessage = $"[font color=#ADD8E6][italic]{FormattedMessage.EscapeText(message)}[/italic][/font]"; | ||
| _chatManager.ChatMessageToManyFiltered(recipients, ChatChannel.Radio, message, wrappedMessage, default, false, true, Color.FromHex("#ADD8E6")); | ||
| Audio.PlayGlobal(component.HowlSound, recipients, true); | ||
| } | ||
| } | ||
2 changes: 2 additions & 0 deletions
2
Resources/Locale/en-US/_Starlight/station-events/events/fullmoonhowl.ftl
This file contains hidden or 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,2 @@ | ||
| station-event-fullmoonhowl-announcement = You feel the effects of a full moon and get a sudden urge to gather near { $location } for a group howl. | ||
| station-event-fullmoonhowl-default-location = Bar | ||
|
Ohelig marked this conversation as resolved.
|
||
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.