Fix humanoid profile voice being broken (#42550)
Fix humanoid appearance voice being broken
This commit is contained in:
parent
e19f4643f2
commit
dd43910f79
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue