From 7759d404c64b2f0701893dea9535cf73f8dc1a9c Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Thu, 28 Mar 2024 12:56:49 -0400 Subject: [PATCH] Fix arcade goodbye message implementation (#26514) --- .../BlockGame/BlockGameArcadeComponent.cs | 5 ----- .../Arcade/BlockGame/BlockGameArcadeSystem.cs | 17 +++----------- .../SpaceVillainArcadeComponent.cs | 5 ----- .../SpaceVillainArcadeSystem.cs | 22 ++++--------------- .../Arcade/Advertisements/blockgame.yml | 13 ----------- .../Arcade/Advertisements/spacevillain.yml | 13 ----------- .../Catalog/Arcade/Goodbyes/blockgame.yml | 15 +++++++++++++ .../Catalog/Arcade/Goodbyes/spacevillain.yml | 15 +++++++++++++ .../Structures/Machines/Computers/arcades.yml | 4 ++++ 9 files changed, 41 insertions(+), 68 deletions(-) create mode 100644 Resources/Prototypes/Catalog/Arcade/Goodbyes/blockgame.yml create mode 100644 Resources/Prototypes/Catalog/Arcade/Goodbyes/spacevillain.yml diff --git a/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs b/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs index e2acec52a3a3..5613d9154441 100644 --- a/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs +++ b/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs @@ -19,9 +19,4 @@ public sealed partial class BlockGameArcadeComponent : Component /// The players currently viewing (but not playing) the active session of NT-BG. /// public readonly List Spectators = new(); - - /// - /// Whether the game machine should thank (or otherwise talk to) the player when they leave - /// - public bool ShouldSayThankYou; } diff --git a/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs b/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs index 96001a484bc6..ad65c5cca6ba 100644 --- a/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs +++ b/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs @@ -2,7 +2,6 @@ using Content.Shared.UserInterface; using Content.Server.Advertise; using Content.Server.Advertise.Components; -using Content.Server.Advertise.EntitySystems; using Content.Shared.Arcade; using Robust.Server.GameObjects; using Robust.Shared.Player; @@ -12,7 +11,7 @@ namespace Content.Server.Arcade.BlockGame; public sealed class BlockGameArcadeSystem : EntitySystem { [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; - [Dependency] private readonly AdvertiseSystem _advertise = default!; + [Dependency] private readonly SpeakOnUIClosedSystem _speakOnUIClosed = default!; public override void Initialize() { @@ -92,16 +91,6 @@ private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, B component.Spectators.Remove(component.Player); UpdatePlayerStatus(uid, component.Player, blockGame: component); } - else - { - // Everybody's gone - component.Player = null; - if (component.ShouldSayThankYou && TryComp(uid, out var advertise)) - { - _advertise.SayAdvertisement(uid, advertise); - component.ShouldSayThankYou = false; - } - } UpdatePlayerStatus(uid, temp, blockGame: component); } @@ -115,7 +104,6 @@ private void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent compone _uiSystem.CloseAll(bui); component.Player = null; component.Spectators.Clear(); - component.ShouldSayThankYou = false; } private void OnPlayerAction(EntityUid uid, BlockGameArcadeComponent component, BlockGameMessages.BlockGamePlayerActionMessage msg) @@ -135,7 +123,8 @@ private void OnPlayerAction(EntityUid uid, BlockGameArcadeComponent component, B return; } - component.ShouldSayThankYou = true; + if (TryComp(uid, out var speakComponent)) + _speakOnUIClosed.TrySetFlag((uid, speakComponent)); component.Game.ProcessInput(msg.PlayerAction); } diff --git a/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeComponent.cs index c3a8877393e4..e93fcc6e8f19 100644 --- a/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeComponent.cs @@ -110,9 +110,4 @@ public sealed partial class SpaceVillainArcadeComponent : SharedSpaceVillainArca /// [ViewVariables(VVAccess.ReadWrite)] public int RewardAmount = 0; - - /// - /// Whether the game machine should thank (or otherwise talk to) the player when they leave - /// - public bool ShouldSayThankYou; } diff --git a/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeSystem.cs b/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeSystem.cs index 4d704b8a8117..f60d88ebf78b 100644 --- a/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeSystem.cs +++ b/Content.Server/Arcade/SpaceVillainGame/SpaceVillainArcadeSystem.cs @@ -2,7 +2,6 @@ using Content.Shared.UserInterface; using Content.Server.Advertise; using Content.Server.Advertise.Components; -using Content.Server.Advertise.EntitySystems; using static Content.Shared.Arcade.SharedSpaceVillainArcadeComponent; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -16,7 +15,7 @@ public sealed partial class SpaceVillainArcadeSystem : EntitySystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; - [Dependency] private readonly AdvertiseSystem _advertise = default!; + [Dependency] private readonly SpeakOnUIClosedSystem _speakOnUIClosed = default!; public override void Initialize() { @@ -26,7 +25,6 @@ public override void Initialize() SubscribeLocalEvent(OnAfterUIOpenSV); SubscribeLocalEvent(OnSVPlayerAction); SubscribeLocalEvent(OnSVillainPower); - SubscribeLocalEvent(OnBoundUIClosed); } /// @@ -84,7 +82,9 @@ private void OnSVPlayerAction(EntityUid uid, SpaceVillainArcadeComponent compone case PlayerAction.Heal: case PlayerAction.Recharge: component.Game.ExecutePlayerAction(uid, msg.PlayerAction, component); - component.ShouldSayThankYou = true; // Any sort of gameplay action counts + // Any sort of gameplay action counts + if (TryComp(uid, out var speakComponent)) + _speakOnUIClosed.TrySetFlag((uid, speakComponent)); break; case PlayerAction.NewGame: _audioSystem.PlayPvs(component.NewGameSound, uid, AudioParams.Default.WithVolume(-4f)); @@ -112,19 +112,5 @@ private void OnSVillainPower(EntityUid uid, SpaceVillainArcadeComponent componen if (_uiSystem.TryGetUi(uid, SpaceVillainArcadeUiKey.Key, out var bui)) _uiSystem.CloseAll(bui); - - component.ShouldSayThankYou = false; - } - - private void OnBoundUIClosed(Entity ent, ref BoundUIClosedEvent args) - { - if (args.UiKey is not SpaceVillainArcadeUiKey || (SpaceVillainArcadeUiKey) args.UiKey != SpaceVillainArcadeUiKey.Key) - return; - - if (ent.Comp.ShouldSayThankYou && TryComp(ent.Owner, out var advertise)) - { - _advertise.SayAdvertisement(ent.Owner, advertise); - ent.Comp.ShouldSayThankYou = false; - } } } diff --git a/Resources/Prototypes/Catalog/Arcade/Advertisements/blockgame.yml b/Resources/Prototypes/Catalog/Arcade/Advertisements/blockgame.yml index 226f0cb72b65..7fb036729517 100644 --- a/Resources/Prototypes/Catalog/Arcade/Advertisements/blockgame.yml +++ b/Resources/Prototypes/Catalog/Arcade/Advertisements/blockgame.yml @@ -14,16 +14,3 @@ - advertisement-block-game-11 - advertisement-block-game-12 - advertisement-block-game-13 -# thankyous: -# - thankyou-block-game-1 -# - thankyou-block-game-2 -# - thankyou-block-game-3 -# - thankyou-block-game-4 -# - thankyou-block-game-5 -# - thankyou-block-game-6 -# - thankyou-block-game-7 -# - thankyou-block-game-8 -# - thankyou-block-game-9 -# - thankyou-block-game-10 -# - thankyou-block-game-11 -# - thankyou-block-game-12 diff --git a/Resources/Prototypes/Catalog/Arcade/Advertisements/spacevillain.yml b/Resources/Prototypes/Catalog/Arcade/Advertisements/spacevillain.yml index bee4ca2baecc..7c94ab94f6bf 100644 --- a/Resources/Prototypes/Catalog/Arcade/Advertisements/spacevillain.yml +++ b/Resources/Prototypes/Catalog/Arcade/Advertisements/spacevillain.yml @@ -16,16 +16,3 @@ - advertisement-space-villain-13 - advertisement-space-villain-14 - advertisement-space-villain-15 -# thankyous: -# - thankyou-space-villain-1 -# - thankyou-space-villain-2 -# - thankyou-space-villain-3 -# - thankyou-space-villain-4 -# - thankyou-space-villain-5 -# - thankyou-space-villain-6 -# - thankyou-space-villain-7 -# - thankyou-space-villain-8 -# - thankyou-space-villain-9 -# - thankyou-space-villain-10 -# - thankyou-space-villain-11 -# - thankyou-space-villain-12 diff --git a/Resources/Prototypes/Catalog/Arcade/Goodbyes/blockgame.yml b/Resources/Prototypes/Catalog/Arcade/Goodbyes/blockgame.yml new file mode 100644 index 000000000000..460e8d13bff9 --- /dev/null +++ b/Resources/Prototypes/Catalog/Arcade/Goodbyes/blockgame.yml @@ -0,0 +1,15 @@ +- type: messagePack + id: BlockGameGoodbyes + messages: + - thankyou-block-game-1 + - thankyou-block-game-2 + - thankyou-block-game-3 + - thankyou-block-game-4 + - thankyou-block-game-5 + - thankyou-block-game-6 + - thankyou-block-game-7 + - thankyou-block-game-8 + - thankyou-block-game-9 + - thankyou-block-game-10 + - thankyou-block-game-11 + - thankyou-block-game-12 diff --git a/Resources/Prototypes/Catalog/Arcade/Goodbyes/spacevillain.yml b/Resources/Prototypes/Catalog/Arcade/Goodbyes/spacevillain.yml new file mode 100644 index 000000000000..09016afec31c --- /dev/null +++ b/Resources/Prototypes/Catalog/Arcade/Goodbyes/spacevillain.yml @@ -0,0 +1,15 @@ +- type: messagePack + id: SpaceVillainGoodbyes + messages: + - thankyou-space-villain-1 + - thankyou-space-villain-2 + - thankyou-space-villain-3 + - thankyou-space-villain-4 + - thankyou-space-villain-5 + - thankyou-space-villain-6 + - thankyou-space-villain-7 + - thankyou-space-villain-8 + - thankyou-space-villain-9 + - thankyou-space-villain-10 + - thankyou-space-villain-11 + - thankyou-space-villain-12 diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/arcades.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/arcades.yml index 2970e9f854d7..49f33d1cff4d 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/arcades.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/arcades.yml @@ -148,6 +148,8 @@ pack: SpaceVillainAds minWait: 60 # Arcades are noisy maxWait: 240 + - type: SpeakOnUIClosed + pack: SpaceVillainGoodbyes - type: entity id: SpaceVillainArcadeFilled @@ -190,3 +192,5 @@ pack: BlockGameAds minWait: 60 # Arcades are noisy maxWait: 240 + - type: SpeakOnUIClosed + pack: BlockGameGoodbyes