Random TTS Borg (#701)

* Random TTS Borg

* Правки

* Правки №2

* fix bezdarnost

* fix bezdarnost 2

---------

Co-authored-by: drdth <drdtheuser@gmail.com>
This commit is contained in:
Jabak
2024-09-27 21:52:15 +03:00
committed by GitHub
parent eff426c09f
commit f175ef4c3b
4 changed files with 38 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Access.Components; using System.Linq;
using Content.Shared._White.TTS;
using Content.Shared.Containers.ItemSlots; using Content.Shared.Containers.ItemSlots;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
@@ -7,6 +8,8 @@ using Content.Shared.PowerCell.Components;
using Content.Shared.Silicons.Borgs.Components; using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Wires; using Content.Shared.Wires;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.Silicons.Borgs; namespace Content.Shared.Silicons.Borgs;
@@ -18,6 +21,10 @@ public abstract partial class SharedBorgSystem : EntitySystem
[Dependency] protected readonly SharedContainerSystem Container = default!; [Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] protected readonly ItemSlotsSystem ItemSlots = default!; [Dependency] protected readonly ItemSlotsSystem ItemSlots = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!; // Giedi EDIT
[Dependency] protected readonly IRobustRandom RobustRandom = default!; // Giedi EDIT
private HashSet<TTSVoicePrototype> _voices = new ();
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize() public override void Initialize()
@@ -31,9 +38,33 @@ public abstract partial class SharedBorgSystem : EntitySystem
SubscribeLocalEvent<BorgChassisComponent, EntRemovedFromContainerMessage>(OnRemoved); SubscribeLocalEvent<BorgChassisComponent, EntRemovedFromContainerMessage>(OnRemoved);
SubscribeLocalEvent<BorgChassisComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers); SubscribeLocalEvent<BorgChassisComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers);
// WD edit
SubscribeLocalEvent<SharedTTSComponent, ComponentStartup>(EnsureRandomTTS);
InitializeRelay(); InitializeRelay();
GenerateVoiceList(); // WD edit
} }
// Giedi added
private void EnsureRandomTTS(EntityUid uid, SharedTTSComponent component, ComponentStartup args)
{
if (!HasComp<BorgChassisComponent>(uid))
return;
var voiceId = RobustRandom.Pick(_voices);
component.VoicePrototypeId = voiceId.ID;
Dirty(uid, component);
}
private void GenerateVoiceList()
{
_voices = PrototypeManager.EnumeratePrototypes<TTSVoicePrototype>()
.Where(x => x.BorgVoice)
.ToHashSet();
}
// Giedi added
private void OnItemSlotInsertAttempt(EntityUid uid, BorgChassisComponent component, ref ItemSlotInsertAttemptEvent args) private void OnItemSlotInsertAttempt(EntityUid uid, BorgChassisComponent component, ref ItemSlotInsertAttemptEvent args)
{ {
if (args.Cancelled) if (args.Cancelled)

View File

@@ -1,11 +1,12 @@
using Robust.Shared.Prototypes; using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared._White.TTS; namespace Content.Shared._White.TTS;
/// <summary> /// <summary>
/// Apply TTS for entity chat say messages /// Apply TTS for entity chat say messages
/// </summary> /// </summary>
[RegisterComponent, AutoGenerateComponentState] [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
public sealed partial class SharedTTSComponent : Component public sealed partial class SharedTTSComponent : Component
{ {
@@ -14,4 +15,4 @@ public sealed partial class SharedTTSComponent : Component
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public ProtoId<TTSVoicePrototype> VoicePrototypeId { get; set; } = "Eugene"; public ProtoId<TTSVoicePrototype> VoicePrototypeId { get; set; } = "Eugene";
} }

View File

@@ -128,12 +128,7 @@
- Flashed - Flashed
- type: TypingIndicator - type: TypingIndicator
proto: robot proto: robot
- type: Speech - type: TTS
speechVerb: Robotic
speechSounds: Borg
- type: Vocal
sounds:
Unsexed: UnisexSilicon
- type: UnblockableSpeech - type: UnblockableSpeech
- type: FootstepModifier - type: FootstepModifier
footstepSoundCollection: footstepSoundCollection:
@@ -282,10 +277,6 @@
- Syndicate - Syndicate
- type: ShowSyndicateIcons - type: ShowSyndicateIcons
- type: MovementAlwaysTouching - type: MovementAlwaysTouching
- type: Speech - type: TTS
speechSounds: SyndieBorg
- type: Vocal
sounds:
Unsexed: UnisexSiliconSyndicate
- type: PointLight - type: PointLight
color: "#dd200b" color: "#dd200b"

View File

@@ -27,8 +27,6 @@
name: cyborg name: cyborg
- type: Construction - type: Construction
node: cyborg node: cyborg
- type: Speech
speechVerb: Robotic
- type: InteractionPopup - type: InteractionPopup
interactSuccessString: petting-success-generic-cyborg interactSuccessString: petting-success-generic-cyborg
interactFailureString: petting-failure-generic-cyborg interactFailureString: petting-failure-generic-cyborg