Rename DummyPuppet to VentriloquistPuppet (#19777)

This commit is contained in:
Leon Friedrich
2023-09-16 16:54:46 +12:00
committed by GitHub
parent a9cc99f80c
commit f7d7f5cc7f
10 changed files with 153 additions and 194 deletions

View File

@@ -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<PuppetDummyComponent, DroppedEvent>(OnDropped);
SubscribeLocalEvent<PuppetDummyComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<PuppetDummyComponent, GotUnequippedHandEvent>(OnUnequippedHand);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="args"></param>
private void OnUseInHand(EntityUid uid, PuppetDummyComponent component, UseInHandEvent args)
{
if (args.Handled)
return;
var userHands = Comp<HandsComponent>(args.User);
if (userHands.ActiveHandEntity == uid && HasComp<MutedComponent>(uid))
{
RemComp<MutedComponent>(uid);
_popupSystem.PopupEntity(Loc.GetString("dummy-insert-hand"), uid, args.User);
_popupSystem.PopupEntity(Loc.GetString("dummy-inserted-hand"), uid, uid);
AddComp<CombatModeComponent>(uid);
if (!HasComp<GhostTakeoverAvailableComponent>(uid))
{
EnsureComp<GhostTakeoverAvailableComponent>(uid);
var ghostRole = AddComp<GhostRoleComponent>(uid);
ghostRole.RoleName = Loc.GetString("dummy-role-name");
ghostRole.RoleDescription = Loc.GetString("dummy-role-description");
}
}
else if (userHands.ActiveHandEntity == uid && !HasComp<MutedComponent>(uid))
{
_popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
args.Handled = true;
}
/// <summary>
/// When dropped the dummy is muted again.
/// </summary>
private void OnDropped(EntityUid uid, PuppetDummyComponent component, DroppedEvent args)
{
if (HasComp<MutedComponent>(uid))
return;
_popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
/// <summary>
/// When unequipped from a hand slot the dummy is muted again.
/// </summary>
private void OnUnequippedHand(EntityUid uid, PuppetDummyComponent component, GotUnequippedHandEvent args)
{
if (HasComp<MutedComponent>(uid))
return;
_popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
/// <summary>
/// Mutes the dummy.
/// </summary>
private void MuteDummy(EntityUid uid, PuppetDummyComponent component)
{
_popupSystem.PopupEntity(Loc.GetString("dummy-removed-hand"), uid, uid);
AddComp<MutedComponent>(uid);
RemComp<CombatModeComponent>(uid);
}
}
}

View File

@@ -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<VentriloquistPuppetComponent, DroppedEvent>(OnDropped);
SubscribeLocalEvent<VentriloquistPuppetComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<VentriloquistPuppetComponent, GotUnequippedHandEvent>(OnUnequippedHand);
}
/// <summary>
/// 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.
/// </summary>
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<MutedComponent>(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<CombatModeComponent>(uid);
_popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-insert-hand"), uid, args.User);
_popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-inserted-hand"), uid, uid);
if (!HasComp<GhostTakeoverAvailableComponent>(uid))
{
AddComp<GhostTakeoverAvailableComponent>(uid);
var ghostRole = EnsureComp<GhostRoleComponent>(uid);
ghostRole.RoleName = Loc.GetString("ventriloquist-puppet-role-name");
ghostRole.RoleDescription = Loc.GetString("ventriloquist-puppet-role-description");
}
args.Handled = true;
}
/// <summary>
/// When dropped the dummy is muted again.
/// </summary>
private void OnDropped(EntityUid uid, VentriloquistPuppetComponent component, DroppedEvent args)
{
if (HasComp<MutedComponent>(uid))
return;
_popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
/// <summary>
/// When unequipped from a hand slot the dummy is muted again.
/// </summary>
private void OnUnequippedHand(EntityUid uid, VentriloquistPuppetComponent component, GotUnequippedHandEvent args)
{
if (HasComp<MutedComponent>(uid))
return;
_popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
/// <summary>
/// Mutes the dummy.
/// </summary>
private void MuteDummy(EntityUid uid, VentriloquistPuppetComponent component)
{
_popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-removed-hand"), uid, uid);
EnsureComp<MutedComponent>(uid);
RemComp<CombatModeComponent>(uid);
RemComp<GhostTakeoverAvailableComponent>(uid);
}
}
}

View File

@@ -46,12 +46,12 @@ namespace Content.Server.Speech.Muting
private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args) private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args)
{ {
// TODO something better than this.
if (HasComp<MimePowersComponent>(uid)) if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid); _popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
else if (HasComp<VentriloquistPuppetComponent>(uid))
if (HasComp<PuppetDummyComponent>(uid)) _popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-cant-speak"), uid, uid);
_popupSystem.PopupEntity(Loc.GetString("dummy-cant-speak"), uid, uid);
else else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid); _popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);

View File

@@ -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;
}
}

View File

@@ -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<PuppetDummyComponent, UseAttemptEvent>(OnUseAttempt);
SubscribeLocalEvent<PuppetDummyComponent, InteractionAttemptEvent>(OnInteractAttempt);
SubscribeLocalEvent<PuppetDummyComponent, DropAttemptEvent>(OnDropAttempt);
SubscribeLocalEvent<PuppetDummyComponent, PickupAttemptEvent>(OnPickupAttempt);
SubscribeLocalEvent<PuppetDummyComponent, UpdateCanMoveEvent>(OnMoveAttempt);
SubscribeLocalEvent<PuppetDummyComponent, EmoteAttemptEvent>(OnEmoteAttempt);
SubscribeLocalEvent<PuppetDummyComponent, ChangeDirectionAttemptEvent>(OnChangeDirectionAttempt);
SubscribeLocalEvent<PuppetDummyComponent, ComponentStartup>(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();
}
}
}

View File

@@ -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<VentriloquistPuppetComponent, UseAttemptEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, InteractionAttemptEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, DropAttemptEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, PickupAttemptEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, UpdateCanMoveEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, EmoteAttemptEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, ChangeDirectionAttemptEvent>(Cancel);
SubscribeLocalEvent<VentriloquistPuppetComponent, ComponentStartup>(OnStartup);
}
private void OnStartup(EntityUid uid, VentriloquistPuppetComponent component, ComponentStartup args)
{
_blocker.UpdateCanMove(uid);
}
private void Cancel<T>(EntityUid uid, VentriloquistPuppetComponent component, T args) where T : CancellableEntityEventArgs
{
args.Cancel();
}
}

View File

@@ -0,0 +1,8 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Puppet;
[RegisterComponent, NetworkedComponent]
public sealed partial class VentriloquistPuppetComponent : Component
{
}

View File

@@ -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!

View File

@@ -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!

View File

@@ -12,7 +12,7 @@
- type: Input - type: Input
context: "human" context: "human"
- type: DoAfter - type: DoAfter
- type: PuppetDummy - type: VentriloquistPuppet
- type: Item - type: Item
size: 30 size: 30
- type: Muted - type: Muted