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.Movement.Components;
using Content.Shared.Movement.Systems;
@@ -7,6 +8,8 @@ using Content.Shared.PowerCell.Components;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Wires;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Shared.Silicons.Borgs;
@@ -18,6 +21,10 @@ public abstract partial class SharedBorgSystem : EntitySystem
[Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] protected readonly ItemSlotsSystem ItemSlots = 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/>
public override void Initialize()
@@ -31,9 +38,33 @@ public abstract partial class SharedBorgSystem : EntitySystem
SubscribeLocalEvent<BorgChassisComponent, EntRemovedFromContainerMessage>(OnRemoved);
SubscribeLocalEvent<BorgChassisComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers);
// WD edit
SubscribeLocalEvent<SharedTTSComponent, ComponentStartup>(EnsureRandomTTS);
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)
{
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;
/// <summary>
/// Apply TTS for entity chat say messages
/// </summary>
[RegisterComponent, AutoGenerateComponentState]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
// ReSharper disable once InconsistentNaming
public sealed partial class SharedTTSComponent : Component
{
@@ -14,4 +15,4 @@ public sealed partial class SharedTTSComponent : Component
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public ProtoId<TTSVoicePrototype> VoicePrototypeId { get; set; } = "Eugene";
}
}

View File

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

View File

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