Gender Swap

This commit is contained in:
Jabak
2024-07-03 11:17:58 +03:00
parent 35edf6460a
commit 03ee041be9
9 changed files with 281 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using Content.Server.IdentityManagement;
using Content.Shared._Amour.GrammarSystem;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.IdentityManagement.Components;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.GameObjects.Components.Localization;
namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class GenderChange : ReagentEffect
{
/// <summary>
/// What gender is the consumer changed to? If not set then swap between male/female.
/// </summary>
[DataField("gender")]
public Gender? NewGender;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-gender-change", ("chance", Probability));
public override void Effect(ReagentEffectArgs args)
{
if (args.EntityManager.TryGetComponent<GrammarComponent>(args.SolutionEntity, out var grammar))
{
var uid = args.SolutionEntity;
var newGender = NewGender;
var grammarSystem = args.EntityManager.System<GrammarSystem>();
var identitySystem = args.EntityManager.System<IdentitySystem>();
// bleh, this probably should not be here but I have no clue where to put it
if (grammar.Gender != Gender.Epicene && grammar.Gender != Gender.Neuter)
{
if (grammar.Gender == Gender.Male)
newGender = Gender.Female;
else
newGender = Gender.Male;
}
if (newGender.HasValue)
{
grammarSystem.SetGender((uid, grammar), newGender);
if (args.EntityManager.HasComponent<IdentityComponent>(uid))
identitySystem.QueueIdentityUpdate(uid);
}
}
}
}

View File

@@ -0,0 +1,36 @@
using Content.Shared.Humanoid;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class SexChange : ReagentEffect
{
/// <summary>
/// What sex is the consumer changed to? If not set then swap between male/female.
/// </summary>
[DataField("sex")]
public Sex? NewSex;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-sex-change", ("chance", Probability));
public override void Effect(ReagentEffectArgs args)
{
if (args.EntityManager.TryGetComponent<HumanoidAppearanceComponent>(args.SolutionEntity, out var appearance))
{
var uid = args.SolutionEntity;
var newSex = NewSex;
var humanoidAppearanceSystem = args.EntityManager.System<SharedHumanoidAppearanceSystem>();
if (newSex.HasValue)
{
humanoidAppearanceSystem.SetSex(uid, newSex.Value);
return;
}
if (appearance.Sex != Sex.Unsexed)
humanoidAppearanceSystem.SwapSex(uid);
}
}
}