From efb6c68ac802aff55cd5c591bb9deadf98e7abb3 Mon Sep 17 00:00:00 2001 From: pathetic meowmeow Date: Tue, 20 Jan 2026 14:13:51 -0500 Subject: [PATCH] Fix humanoid profile voice being broken (#42550) Fix humanoid appearance voice being broken --- .../Tests/Humanoid/HumanoidProfileTests.cs | 49 +++++++++++++++++++ .../Humanoid/HumanoidProfileSystem.cs | 3 ++ Content.Shared/Humanoid/Sex.cs | 1 + 3 files changed, 53 insertions(+) create mode 100644 Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs diff --git a/Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs b/Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs new file mode 100644 index 0000000000..1e4a094b79 --- /dev/null +++ b/Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs @@ -0,0 +1,49 @@ +using Content.Shared.Humanoid; +using Content.Shared.Humanoid.Prototypes; +using Content.Shared.Preferences; +using Content.Shared.Speech.Components; +using Robust.Shared.Enums; +using Robust.Shared.GameObjects; +using Robust.Shared.Prototypes; + +namespace Content.IntegrationTests.Tests.Humanoid; + +[TestFixture] +[TestOf(typeof(HumanoidProfileSystem))] +public sealed class HumanoidProfileTests +{ + private static readonly ProtoId Vox = "Vox"; + + [Test] + public async Task EnsureValidLoading() + { + await using var pair = await PoolManager.GetServerClient(); + var server = pair.Server; + + await server.WaitIdleAsync(); + + await server.WaitAssertion(() => + { + var entityManager = server.ResolveDependency(); + var humanoidProfile = entityManager.System(); + var human = entityManager.Spawn("MobHuman"); + humanoidProfile.ApplyProfileTo(human, new HumanoidCharacterProfile() + .WithSex(Sex.Female) + .WithAge(67) + .WithGender(Gender.Neuter) + .WithSpecies(Vox)); + var humanoidComponent = entityManager.GetComponent(human); + var voiceComponent = entityManager.GetComponent(human); + + Assert.That(humanoidComponent.Age, Is.EqualTo(67)); + Assert.That(humanoidComponent.Sex, Is.EqualTo(Sex.Female)); + Assert.That(humanoidComponent.Gender, Is.EqualTo(Gender.Neuter)); + Assert.That(humanoidComponent.Species, Is.EqualTo(Vox)); + + Assert.That(voiceComponent.Sounds, Is.Not.Null, message: "the MobHuman spawned by this test needs to have sex-specific sound set"); + Assert.That(voiceComponent.Sounds![Sex.Female], Is.EqualTo(voiceComponent.EmoteSounds)); + }); + + await pair.CleanReturnAsync(); + } +} diff --git a/Content.Shared/Humanoid/HumanoidProfileSystem.cs b/Content.Shared/Humanoid/HumanoidProfileSystem.cs index 881fd6378a..bc4f64d72a 100644 --- a/Content.Shared/Humanoid/HumanoidProfileSystem.cs +++ b/Content.Shared/Humanoid/HumanoidProfileSystem.cs @@ -30,6 +30,9 @@ public sealed class HumanoidProfileSystem : EntitySystem ent.Comp.Sex = profile.Sex; Dirty(ent); + var sexChanged = new SexChangedEvent(ent.Comp.Sex, profile.Sex); + RaiseLocalEvent(ent, ref sexChanged); + if (TryComp(ent, out var grammar)) { _grammar.SetGender((ent, grammar), profile.Gender); diff --git a/Content.Shared/Humanoid/Sex.cs b/Content.Shared/Humanoid/Sex.cs index ddb8cca036..f388ba9833 100644 --- a/Content.Shared/Humanoid/Sex.cs +++ b/Content.Shared/Humanoid/Sex.cs @@ -17,5 +17,6 @@ namespace Content.Shared.Humanoid /// Raised when entity has changed their sex. /// This doesn't handle gender changes. /// + [ByRefEvent] public record struct SexChangedEvent(Sex OldSex, Sex NewSex); } -- 2.52.0