]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix humanoid profile voice being broken (#42550)
authorpathetic meowmeow <uhhadd@gmail.com>
Tue, 20 Jan 2026 19:13:51 +0000 (14:13 -0500)
committerGitHub <noreply@github.com>
Tue, 20 Jan 2026 19:13:51 +0000 (19:13 +0000)
Fix humanoid appearance voice being broken

Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs [new file with mode: 0644]
Content.Shared/Humanoid/HumanoidProfileSystem.cs
Content.Shared/Humanoid/Sex.cs

diff --git a/Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs b/Content.IntegrationTests/Tests/Humanoid/HumanoidProfileTests.cs
new file mode 100644 (file)
index 0000000..1e4a094
--- /dev/null
@@ -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<SpeciesPrototype> 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<IEntityManager>();
+            var humanoidProfile = entityManager.System<HumanoidProfileSystem>();
+            var human = entityManager.Spawn("MobHuman");
+            humanoidProfile.ApplyProfileTo(human, new HumanoidCharacterProfile()
+                .WithSex(Sex.Female)
+                .WithAge(67)
+                .WithGender(Gender.Neuter)
+                .WithSpecies(Vox));
+            var humanoidComponent = entityManager.GetComponent<HumanoidProfileComponent>(human);
+            var voiceComponent = entityManager.GetComponent<VocalComponent>(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();
+    }
+}
index 881fd6378ae2a3f08f43d4d88f4c1e200322497c..bc4f64d72a3fec1679dbce2ae8930ac6b04c3c35 100644 (file)
@@ -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<GrammarComponent>(ent, out var grammar))
         {
             _grammar.SetGender((ent, grammar), profile.Gender);
index ddb8cca03633c63cddc1b36c580deec43129c5c0..f388ba9833e94aed83467ceb46f61c7e51503242 100644 (file)
@@ -17,5 +17,6 @@ namespace Content.Shared.Humanoid
     ///     Raised when entity has changed their sex.
     ///     This doesn't handle gender changes.
     /// </summary>
+    [ByRefEvent]
     public record struct SexChangedEvent(Sex OldSex, Sex NewSex);
 }