From f7d7f5cc7fb8e41ec19281ef45c90b59e384355e Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 16 Sep 2023 16:54:46 +1200 Subject: [PATCH] Rename DummyPuppet to VentriloquistPuppet (#19777) --- Content.Server/Puppet/PuppetDummySystem.cs | 100 ------------------ .../Puppet/VentriloquistPuppetSystem.cs | 96 +++++++++++++++++ Content.Server/Speech/Muting/MutingSystem.cs | 8 +- Content.Shared/Puppet/PuppetDummyComponent.cs | 11 -- .../Puppet/SharedPuppetDummySystem.cs | 71 ------------- .../Puppet/SharedVentriloquistPuppetSystem.cs | 36 +++++++ .../Puppet/VentriloquistPuppetComponent.cs | 8 ++ Resources/Locale/en-US/dummy/dummy.ftl | 7 -- .../en-US/ventriloquist/ventriloquist.ftl | 8 ++ .../Entities/Objects/Fun/puppet.yml | 2 +- 10 files changed, 153 insertions(+), 194 deletions(-) delete mode 100644 Content.Server/Puppet/PuppetDummySystem.cs create mode 100644 Content.Server/Puppet/VentriloquistPuppetSystem.cs delete mode 100644 Content.Shared/Puppet/PuppetDummyComponent.cs delete mode 100644 Content.Shared/Puppet/SharedPuppetDummySystem.cs create mode 100644 Content.Shared/Puppet/SharedVentriloquistPuppetSystem.cs create mode 100644 Content.Shared/Puppet/VentriloquistPuppetComponent.cs delete mode 100644 Resources/Locale/en-US/dummy/dummy.ftl create mode 100644 Resources/Locale/en-US/ventriloquist/ventriloquist.ftl diff --git a/Content.Server/Puppet/PuppetDummySystem.cs b/Content.Server/Puppet/PuppetDummySystem.cs deleted file mode 100644 index ce1e7d21d8..0000000000 --- a/Content.Server/Puppet/PuppetDummySystem.cs +++ /dev/null @@ -1,100 +0,0 @@ -using Content.Server.Ghost.Roles.Components; -using Content.Server.Popups; -using Content.Shared.Interaction.Events; -using Content.Shared.Puppet; -using Content.Shared.Hands.Components; -using Content.Server.Speech.Muting; -using Content.Shared.CombatMode; -using Content.Shared.Hands; - -namespace Content.Server.Puppet -{ - public sealed class PuppetDummySystem : SharedPuppetDummySystem - { - [Dependency] private readonly PopupSystem _popupSystem = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnDropped); - SubscribeLocalEvent(OnUseInHand); - SubscribeLocalEvent(OnUnequippedHand); - } - - /// - /// When used user inserts hand into dummy and the dummy can speak, when used again the user removes hand - /// from dummy and the dummy cannot speak. - /// - /// - /// - /// - private void OnUseInHand(EntityUid uid, PuppetDummyComponent component, UseInHandEvent args) - { - if (args.Handled) - return; - - var userHands = Comp(args.User); - - if (userHands.ActiveHandEntity == uid && HasComp(uid)) - { - RemComp(uid); - _popupSystem.PopupEntity(Loc.GetString("dummy-insert-hand"), uid, args.User); - _popupSystem.PopupEntity(Loc.GetString("dummy-inserted-hand"), uid, uid); - AddComp(uid); - - if (!HasComp(uid)) - { - EnsureComp(uid); - var ghostRole = AddComp(uid); - ghostRole.RoleName = Loc.GetString("dummy-role-name"); - ghostRole.RoleDescription = Loc.GetString("dummy-role-description"); - } - - } - - else if (userHands.ActiveHandEntity == uid && !HasComp(uid)) - { - _popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User); - MuteDummy(uid, component); - } - - args.Handled = true; - } - - /// - /// When dropped the dummy is muted again. - /// - private void OnDropped(EntityUid uid, PuppetDummyComponent component, DroppedEvent args) - { - if (HasComp(uid)) - return; - - _popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User); - MuteDummy(uid, component); - } - - /// - /// When unequipped from a hand slot the dummy is muted again. - /// - private void OnUnequippedHand(EntityUid uid, PuppetDummyComponent component, GotUnequippedHandEvent args) - { - if (HasComp(uid)) - return; - - _popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User); - MuteDummy(uid, component); - } - - /// - /// Mutes the dummy. - /// - private void MuteDummy(EntityUid uid, PuppetDummyComponent component) - { - _popupSystem.PopupEntity(Loc.GetString("dummy-removed-hand"), uid, uid); - AddComp(uid); - RemComp(uid); - } - } -} - diff --git a/Content.Server/Puppet/VentriloquistPuppetSystem.cs b/Content.Server/Puppet/VentriloquistPuppetSystem.cs new file mode 100644 index 0000000000..68d660fd1b --- /dev/null +++ b/Content.Server/Puppet/VentriloquistPuppetSystem.cs @@ -0,0 +1,96 @@ +using Content.Server.Ghost.Roles.Components; +using Content.Server.Popups; +using Content.Shared.Interaction.Events; +using Content.Shared.Puppet; +using Content.Server.Speech.Muting; +using Content.Shared.CombatMode; +using Content.Shared.Hands; + +namespace Content.Server.Puppet +{ + public sealed class VentriloquistPuppetSystem : SharedVentriloquistPuppetSystem + { + [Dependency] private readonly PopupSystem _popupSystem = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnDropped); + SubscribeLocalEvent(OnUseInHand); + SubscribeLocalEvent(OnUnequippedHand); + } + + /// + /// When used user inserts hand into dummy and the dummy can speak, when used again the user removes hand + /// from dummy and the dummy cannot speak. + /// + private void OnUseInHand(EntityUid uid, VentriloquistPuppetComponent component, UseInHandEvent args) + { + if (args.Handled) + return; + + // TODO stop using mute component as a toggle for this component's functionality. + // TODO disable dummy when the user dies or cannot interact. + // Then again, this is all quite cursed code, so maybe its a cursed ventriloquist puppet. + + if (!RemComp(uid)) + { + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-remove-hand"), uid, args.User); + MuteDummy(uid, component); + return; + } + + // TODO why does this need a combat component??? + EnsureComp(uid); + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-insert-hand"), uid, args.User); + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-inserted-hand"), uid, uid); + + if (!HasComp(uid)) + { + AddComp(uid); + var ghostRole = EnsureComp(uid); + ghostRole.RoleName = Loc.GetString("ventriloquist-puppet-role-name"); + ghostRole.RoleDescription = Loc.GetString("ventriloquist-puppet-role-description"); + } + + args.Handled = true; + } + + /// + /// When dropped the dummy is muted again. + /// + private void OnDropped(EntityUid uid, VentriloquistPuppetComponent component, DroppedEvent args) + { + if (HasComp(uid)) + return; + + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-remove-hand"), uid, args.User); + MuteDummy(uid, component); + } + + /// + /// When unequipped from a hand slot the dummy is muted again. + /// + private void OnUnequippedHand(EntityUid uid, VentriloquistPuppetComponent component, GotUnequippedHandEvent args) + { + if (HasComp(uid)) + return; + + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-remove-hand"), uid, args.User); + MuteDummy(uid, component); + } + + /// + /// Mutes the dummy. + /// + private void MuteDummy(EntityUid uid, VentriloquistPuppetComponent component) + { + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-removed-hand"), uid, uid); + EnsureComp(uid); + RemComp(uid); + RemComp(uid); + } + } +} + diff --git a/Content.Server/Speech/Muting/MutingSystem.cs b/Content.Server/Speech/Muting/MutingSystem.cs index 5023957c4b..b743d9eda8 100644 --- a/Content.Server/Speech/Muting/MutingSystem.cs +++ b/Content.Server/Speech/Muting/MutingSystem.cs @@ -46,12 +46,12 @@ namespace Content.Server.Speech.Muting private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args) { + // TODO something better than this. + if (HasComp(uid)) _popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid); - - if (HasComp(uid)) - _popupSystem.PopupEntity(Loc.GetString("dummy-cant-speak"), uid, uid); - + else if (HasComp(uid)) + _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-cant-speak"), uid, uid); else _popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid); diff --git a/Content.Shared/Puppet/PuppetDummyComponent.cs b/Content.Shared/Puppet/PuppetDummyComponent.cs deleted file mode 100644 index 87dbf69109..0000000000 --- a/Content.Shared/Puppet/PuppetDummyComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Robust.Shared.GameStates; - -namespace Content.Shared.Puppet -{ - [RegisterComponent, NetworkedComponent] - public sealed partial class PuppetDummyComponent : Component - { - [DataField("enabled")] - public bool Enabled = false; - } -} diff --git a/Content.Shared/Puppet/SharedPuppetDummySystem.cs b/Content.Shared/Puppet/SharedPuppetDummySystem.cs deleted file mode 100644 index ededcbcd5a..0000000000 --- a/Content.Shared/Puppet/SharedPuppetDummySystem.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Content.Shared.ActionBlocker; -using Content.Shared.Hands; -using Content.Shared.Interaction.Events; -using Content.Shared.Item; -using Content.Shared.Emoting; -using Content.Shared.Movement.Events; - -namespace Content.Shared.Puppet -{ - public abstract class SharedPuppetDummySystem : EntitySystem - { - [Dependency] private readonly ActionBlockerSystem _blocker = default!; - - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnUseAttempt); - SubscribeLocalEvent(OnInteractAttempt); - SubscribeLocalEvent(OnDropAttempt); - SubscribeLocalEvent(OnPickupAttempt); - SubscribeLocalEvent(OnMoveAttempt); - SubscribeLocalEvent(OnEmoteAttempt); - SubscribeLocalEvent(OnChangeDirectionAttempt); - SubscribeLocalEvent(OnStartup); - } - - private void OnStartup(EntityUid uid, PuppetDummyComponent component, ComponentStartup args) - { - _blocker.UpdateCanMove(uid); - } - - private void OnMoveAttempt(EntityUid uid, PuppetDummyComponent component, UpdateCanMoveEvent args) - { - if (component.LifeStage > ComponentLifeStage.Running) - return; - - args.Cancel(); - } - - private void OnChangeDirectionAttempt(EntityUid uid, PuppetDummyComponent component, ChangeDirectionAttemptEvent args) - { - args.Cancel(); - } - - private void OnUseAttempt(EntityUid uid, PuppetDummyComponent component, UseAttemptEvent args) - { - args.Cancel(); - } - - private void OnEmoteAttempt(EntityUid uid, PuppetDummyComponent component, EmoteAttemptEvent args) - { - args.Cancel(); - } - - private void OnInteractAttempt(EntityUid uid, PuppetDummyComponent component, InteractionAttemptEvent args) - { - args.Cancel(); - } - - private void OnDropAttempt(EntityUid uid, PuppetDummyComponent component, DropAttemptEvent args) - { - args.Cancel(); - } - - private void OnPickupAttempt(EntityUid uid, PuppetDummyComponent component, PickupAttemptEvent args) - { - args.Cancel(); - } - } -} - diff --git a/Content.Shared/Puppet/SharedVentriloquistPuppetSystem.cs b/Content.Shared/Puppet/SharedVentriloquistPuppetSystem.cs new file mode 100644 index 0000000000..430c2b1b17 --- /dev/null +++ b/Content.Shared/Puppet/SharedVentriloquistPuppetSystem.cs @@ -0,0 +1,36 @@ +using Content.Shared.ActionBlocker; +using Content.Shared.Hands; +using Content.Shared.Interaction.Events; +using Content.Shared.Item; +using Content.Shared.Emoting; +using Content.Shared.Movement.Events; + +namespace Content.Shared.Puppet; + +public abstract class SharedVentriloquistPuppetSystem : EntitySystem +{ + [Dependency] private readonly ActionBlockerSystem _blocker = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(Cancel); + SubscribeLocalEvent(OnStartup); + } + + private void OnStartup(EntityUid uid, VentriloquistPuppetComponent component, ComponentStartup args) + { + _blocker.UpdateCanMove(uid); + } + + private void Cancel(EntityUid uid, VentriloquistPuppetComponent component, T args) where T : CancellableEntityEventArgs + { + args.Cancel(); + } +} \ No newline at end of file diff --git a/Content.Shared/Puppet/VentriloquistPuppetComponent.cs b/Content.Shared/Puppet/VentriloquistPuppetComponent.cs new file mode 100644 index 0000000000..8f9239d50f --- /dev/null +++ b/Content.Shared/Puppet/VentriloquistPuppetComponent.cs @@ -0,0 +1,8 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Puppet; + +[RegisterComponent, NetworkedComponent] +public sealed partial class VentriloquistPuppetComponent : Component +{ +} \ No newline at end of file diff --git a/Resources/Locale/en-US/dummy/dummy.ftl b/Resources/Locale/en-US/dummy/dummy.ftl deleted file mode 100644 index 9c77d362c1..0000000000 --- a/Resources/Locale/en-US/dummy/dummy.ftl +++ /dev/null @@ -1,7 +0,0 @@ -dummy-cant-speak = You cannot speak without a helping hand. -dummy-insert-hand = You insert your hand. -dummy-remove-hand = You remove your hand. -dummy-inserted-hand = You have a helping hand. -dummy-removed-hand = you have lost your helping hand. -dummy-role-name = A dummy -dummy-role-description = Become a dummy, dummy! diff --git a/Resources/Locale/en-US/ventriloquist/ventriloquist.ftl b/Resources/Locale/en-US/ventriloquist/ventriloquist.ftl new file mode 100644 index 0000000000..5b46e25456 --- /dev/null +++ b/Resources/Locale/en-US/ventriloquist/ventriloquist.ftl @@ -0,0 +1,8 @@ +ventriloquist-puppet-insert-hand = You insert your hand into the puppet. +ventriloquist-puppet-remove-hand = You remove your hand from the puppet. + +ventriloquist-puppet-cant-speak = You cannot speak without a helping hand. +ventriloquist-puppet-inserted-hand = You have a helping hand. +ventriloquist-puppet-removed-hand = you have lost your helping hand. +ventriloquist-puppet-role-name = A dummy +ventriloquist-puppet-role-description = Become a dummy, dummy! diff --git a/Resources/Prototypes/Entities/Objects/Fun/puppet.yml b/Resources/Prototypes/Entities/Objects/Fun/puppet.yml index 845a4b97c6..2757689a30 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/puppet.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/puppet.yml @@ -12,7 +12,7 @@ - type: Input context: "human" - type: DoAfter - - type: PuppetDummy + - type: VentriloquistPuppet - type: Item size: 30 - type: Muted