From 3647f70e71e6b113ed2c17fe0ec1f71b17b8643c Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Sat, 7 Dec 2024 02:57:08 -0400 Subject: [PATCH 01/10] This is literally just string-checking, lmao, but it should work fine for most purposes. --- .../Systems/CharacterRequirements.Profile.cs | 203 ++++++++++++------ .../customization/character-requirements.ftl | 8 + 2 files changed, 151 insertions(+), 60 deletions(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index 5e10c504932..c71e9183d6a 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -1,3 +1,5 @@ +#region + using System.Linq; using Content.Shared.Clothing.Loadouts.Prototypes; using Content.Shared.Humanoid; @@ -12,7 +14,9 @@ using Robust.Shared.Physics; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Utility; + +#endregion + namespace Content.Shared.Customization.Systems; @@ -20,8 +24,7 @@ namespace Content.Shared.Customization.Systems; /// /// Requires the profile to be within an age range /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterAgeRequirement : CharacterRequirement { [DataField(required: true)] @@ -30,7 +33,8 @@ public sealed partial class CharacterAgeRequirement : CharacterRequirement [DataField(required: true)] public int Max; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -39,10 +43,14 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { - reason = Loc.GetString("character-age-requirement", - ("inverted", Inverted), ("min", Min), ("max", Max)); + reason = Loc.GetString( + "character-age-requirement", + ("inverted", Inverted), + ("min", Min), + ("max", Max)); return profile.Age >= Min && profile.Age <= Max; } } @@ -50,14 +58,14 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to be a certain gender /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterGenderRequirement : CharacterRequirement { [DataField(required: true)] public Gender Gender; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -66,9 +74,11 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { - reason = Loc.GetString("character-gender-requirement", + reason = Loc.GetString( + "character-gender-requirement", ("inverted", Inverted), ("gender", Loc.GetString($"humanoid-profile-editor-pronouns-{Gender.ToString().ToLower()}-text"))); return profile.Gender == Gender; @@ -78,14 +88,14 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to be a certain sex /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterSexRequirement : CharacterRequirement { [DataField(required: true)] public Sex Sex; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -94,9 +104,11 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { - reason = Loc.GetString("character-sex-requirement", + reason = Loc.GetString( + "character-sex-requirement", ("inverted", Inverted), ("sex", Loc.GetString($"humanoid-profile-editor-sex-{Sex.ToString().ToLower()}-text"))); return profile.Sex == Sex; @@ -106,14 +118,14 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to be a certain species /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterSpeciesRequirement : CharacterRequirement { [DataField(required: true)] public List> Species; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -122,10 +134,12 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { const string color = "green"; - reason = Loc.GetString("character-species-requirement", + reason = Loc.GetString( + "character-species-requirement", ("inverted", Inverted), ("species", $"[color={color}]{string.Join($"[/color], [color={color}]", Species.Select(s => Loc.GetString(prototypeManager.Index(s).Name)))}[/color]")); @@ -135,10 +149,9 @@ public override bool IsValid(JobPrototype job, } /// -/// Requires the profile to be within a certain height range +/// Requires the profile to be within a certain height range /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterHeightRequirement : CharacterRequirement { /// @@ -153,7 +166,8 @@ public sealed partial class CharacterHeightRequirement : CharacterRequirement [DataField] public float Max = int.MaxValue; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -162,13 +176,18 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { const string color = "yellow"; var species = prototypeManager.Index(profile.Species); - reason = Loc.GetString("character-height-requirement", - ("inverted", Inverted), ("color", color), ("min", Min), ("max", Max)); + reason = Loc.GetString( + "character-height-requirement", + ("inverted", Inverted), + ("color", color), + ("min", Min), + ("max", Max)); var height = profile.Height * species.AverageHeight; return height >= Min && height <= Max; @@ -178,8 +197,7 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to be within a certain width range /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterWidthRequirement : CharacterRequirement { /// @@ -194,7 +212,8 @@ public sealed partial class CharacterWidthRequirement : CharacterRequirement [DataField] public float Max = int.MaxValue; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -203,13 +222,18 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { const string color = "yellow"; var species = prototypeManager.Index(profile.Species); - reason = Loc.GetString("character-width-requirement", - ("inverted", Inverted), ("color", color), ("min", Min), ("max", Max)); + reason = Loc.GetString( + "character-width-requirement", + ("inverted", Inverted), + ("color", color), + ("min", Min), + ("max", Max)); var width = profile.Width * species.AverageWidth; return width >= Min && width <= Max; @@ -219,8 +243,7 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to be within a certain weight range /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterWeightRequirement : CharacterRequirement { /// @@ -235,7 +258,8 @@ public sealed partial class CharacterWeightRequirement : CharacterRequirement [DataField] public float Max = int.MaxValue; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -244,7 +268,8 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { const string color = "green"; var species = prototypeManager.Index(profile.Species); @@ -259,28 +284,32 @@ public override bool IsValid(JobPrototype job, var weight = MathF.Round( MathF.PI * MathF.Pow( fixture.Fixtures["fix1"].Shape.Radius - * ((profile.Width + profile.Height) / 2), 2) - * fixture.Fixtures["fix1"].Density); + * ((profile.Width + profile.Height) / 2), + 2) + * fixture.Fixtures["fix1"].Density); - reason = Loc.GetString("character-weight-requirement", - ("inverted", Inverted), ("color", color), ("min", Min), ("max", Max)); + reason = Loc.GetString( + "character-weight-requirement", + ("inverted", Inverted), + ("color", color), + ("min", Min), + ("max", Max)); return weight >= Min && weight <= Max; } } - /// /// Requires the profile to have one of the specified traits /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterTraitRequirement : CharacterRequirement { [DataField(required: true)] public List> Traits; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -289,10 +318,12 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { const string color = "lightblue"; - reason = Loc.GetString("character-trait-requirement", + reason = Loc.GetString( + "character-trait-requirement", ("inverted", Inverted), ("traits", $"[color={color}]{string.Join($"[/color], [color={color}]", Traits.Select(t => Loc.GetString($"trait-name-{t}")))}[/color]")); @@ -304,14 +335,14 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to have one of the specified loadouts /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterLoadoutRequirement : CharacterRequirement { [DataField(required: true)] public List> Loadouts; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -320,10 +351,12 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { const string color = "lightblue"; - reason = Loc.GetString("character-loadout-requirement", + reason = Loc.GetString( + "character-loadout-requirement", ("inverted", Inverted), ("loadouts", $"[color={color}]{string.Join($"[/color], [color={color}]", Loadouts.Select(l => Loc.GetString($"loadout-name-{l}")))}[/color]")); @@ -335,14 +368,14 @@ public override bool IsValid(JobPrototype job, /// /// Requires the profile to not have any more than X of the specified traits, loadouts, etc, in a group /// -[UsedImplicitly] -[Serializable, NetSerializable] +[UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CharacterItemGroupRequirement : CharacterRequirement { [DataField(required: true)] public ProtoId Group; - public override bool IsValid(JobPrototype job, + public override bool IsValid( + JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, @@ -351,19 +384,23 @@ public override bool IsValid(JobPrototype job, IPrototypeManager prototypeManager, IConfigurationManager configManager, out string? reason, - int depth = 0) + int depth = 0 + ) { var group = prototypeManager.Index(Group); // Get the count of items in the group that are in the profile - var items = group.Items.Select(item => item.TryGetValue(profile, prototypeManager, out _) ? item.ID : null).Where(id => id != null).ToList(); + var items = group.Items.Select(item => item.TryGetValue(profile, prototypeManager, out _) ? item.ID : null) + .Where(id => id != null) + .ToList(); var count = items.Count; // If prototype is selected, remove one from the count if (items.ToList().Contains(prototype.ID)) count--; - reason = Loc.GetString("character-item-group-requirement", + reason = Loc.GetString( + "character-item-group-requirement", ("inverted", Inverted), ("group", Loc.GetString($"character-item-group-{Group}")), ("max", group.MaxItems)); @@ -371,3 +408,49 @@ public override bool IsValid(JobPrototype job, return count < group.MaxItems; } } + +/// +/// Requires the profile to have one of the specified loadouts +/// +[UsedImplicitly, Serializable, NetSerializable,] +public sealed partial class CVarRequirement : CharacterRequirement +{ + [DataField("cvar", required: true)] + public string CVar; + + [DataField("requireValue", required: true)] + public string RequiredValue; + + public override bool IsValid( + JobPrototype job, + HumanoidCharacterProfile profile, + Dictionary playTimes, + bool whitelisted, + IPrototype prototype, + IEntityManager entityManager, + IPrototypeManager prototypeManager, + IConfigurationManager configManager, + out string? reason, + int depth = 0 + ) + { + if (!configManager.IsCVarRegistered(CVar)) + { + reason = null; + return true; + } + + const string color = "lightblue"; + var cvar = configManager.GetCVar(CVar); + var isValid = cvar.ToString()! == RequiredValue; + + reason = Loc.GetString( + "character-cvar-requirement", + ("inverted", Inverted), + ("color", color), + ("cvar", CVar), + ("value", RequiredValue)); + + return isValid; + } +} diff --git a/Resources/Locale/en-US/customization/character-requirements.ftl b/Resources/Locale/en-US/customization/character-requirements.ftl index d50c2b39669..8c3be74231c 100644 --- a/Resources/Locale/en-US/customization/character-requirements.ftl +++ b/Resources/Locale/en-US/customization/character-requirements.ftl @@ -140,3 +140,11 @@ character-whitelist-requirement = You must{$inverted -> [true]{" "}not *[other]{""} } be whitelisted + +## Cvar + +character-cvar-requirement = + The server must{$inverted -> + [true]{" "}not + *[other]{""} +} have [color={$color}]{$cvar}[/color] set to [color={$color}]{$value}[/color]. From 1f56f49c26aa3233d3b94600b1fae70005c71fda Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Sat, 7 Dec 2024 02:58:27 -0400 Subject: [PATCH 02/10] Disgusting --- .../Customization/Systems/CharacterRequirements.Profile.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index c71e9183d6a..e8c2227963f 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -1,5 +1,3 @@ -#region - using System.Linq; using Content.Shared.Clothing.Loadouts.Prototypes; using Content.Shared.Humanoid; @@ -15,9 +13,6 @@ using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -#endregion - - namespace Content.Shared.Customization.Systems; From 253f580a8db3109849a7dfd6181c153668d0e94a Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Sat, 7 Dec 2024 03:03:46 -0400 Subject: [PATCH 03/10] I used this in debugging, no longer! Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> --- .../Customization/Systems/CharacterRequirements.Profile.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index e8c2227963f..b4a1b3d7126 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -437,7 +437,6 @@ public override bool IsValid( const string color = "lightblue"; var cvar = configManager.GetCVar(CVar); - var isValid = cvar.ToString()! == RequiredValue; reason = Loc.GetString( "character-cvar-requirement", @@ -446,6 +445,6 @@ public override bool IsValid( ("cvar", CVar), ("value", RequiredValue)); - return isValid; + return cvar.ToString()! == RequiredValue; } } From 92726785edeee9109d7152c56bf870cad76f5830 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Sat, 7 Dec 2024 03:17:40 -0400 Subject: [PATCH 04/10] Update CharacterRequirements.Profile.cs Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> --- .../Systems/CharacterRequirements.Profile.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index b4a1b3d7126..c715a21ac20 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -19,7 +19,7 @@ namespace Content.Shared.Customization.Systems; /// /// Requires the profile to be within an age range /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterAgeRequirement : CharacterRequirement { [DataField(required: true)] @@ -53,7 +53,7 @@ public override bool IsValid( /// /// Requires the profile to be a certain gender /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterGenderRequirement : CharacterRequirement { [DataField(required: true)] @@ -83,7 +83,7 @@ public override bool IsValid( /// /// Requires the profile to be a certain sex /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterSexRequirement : CharacterRequirement { [DataField(required: true)] @@ -113,7 +113,7 @@ public override bool IsValid( /// /// Requires the profile to be a certain species /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterSpeciesRequirement : CharacterRequirement { [DataField(required: true)] @@ -146,7 +146,7 @@ public override bool IsValid( /// /// Requires the profile to be within a certain height range /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterHeightRequirement : CharacterRequirement { /// @@ -192,7 +192,7 @@ public override bool IsValid( /// /// Requires the profile to be within a certain width range /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterWidthRequirement : CharacterRequirement { /// @@ -238,7 +238,7 @@ public override bool IsValid( /// /// Requires the profile to be within a certain weight range /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterWeightRequirement : CharacterRequirement { /// @@ -297,7 +297,7 @@ public override bool IsValid( /// /// Requires the profile to have one of the specified traits /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterTraitRequirement : CharacterRequirement { [DataField(required: true)] @@ -330,7 +330,7 @@ public override bool IsValid( /// /// Requires the profile to have one of the specified loadouts /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterLoadoutRequirement : CharacterRequirement { [DataField(required: true)] @@ -363,7 +363,7 @@ public override bool IsValid( /// /// Requires the profile to not have any more than X of the specified traits, loadouts, etc, in a group /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CharacterItemGroupRequirement : CharacterRequirement { [DataField(required: true)] @@ -407,7 +407,7 @@ public override bool IsValid( /// /// Requires the profile to have one of the specified loadouts /// -[UsedImplicitly, Serializable, NetSerializable,] +[UsedImplicitly, Serializable, NetSerializable] public sealed partial class CVarRequirement : CharacterRequirement { [DataField("cvar", required: true)] From 892db4a806acec13e345cb40aaccaead5ff33e93 Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Sun, 8 Dec 2024 00:42:42 -0400 Subject: [PATCH 05/10] Moved to Misc for anything that isn't truly a character requirement, but still needs to inherit as such. --- .../Systems/CharacterRequirements.Misc.cs | 45 ++++++++++++++++++ .../Systems/CharacterRequirements.Profile.cs | 46 ------------------- 2 files changed, 45 insertions(+), 46 deletions(-) create mode 100644 Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs new file mode 100644 index 00000000000..b58b35ef8e3 --- /dev/null +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs @@ -0,0 +1,45 @@ +/// +/// Requires the profile to have one of the specified loadouts +/// +[UsedImplicitly, Serializable, NetSerializable,] +public sealed partial class CVarRequirement : CharacterRequirement +{ + [DataField("cvar", required: true)] + public string CVar; + + [DataField("requiredValue", required: true)] + public string RequiredValue; + + public override bool IsValid( + JobPrototype job, + HumanoidCharacterProfile profile, + Dictionary playTimes, + bool whitelisted, + IPrototype prototype, + IEntityManager entityManager, + IPrototypeManager prototypeManager, + IConfigurationManager configManager, + out string? reason, + int depth = 0 + ) + { + if (!configManager.IsCVarRegistered(CVar)) + { + reason = null; + return true; + } + + const string color = "lightblue"; + var cvar = configManager.GetCVar(CVar); + var isValid = cvar.ToString()! == RequiredValue; + + reason = Loc.GetString( + "character-cvar-requirement", + ("inverted", Inverted), + ("color", color), + ("cvar", CVar), + ("value", RequiredValue)); + + return isValid; + } +} \ No newline at end of file diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index e8c2227963f..cde97f24f5b 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -403,49 +403,3 @@ public override bool IsValid( return count < group.MaxItems; } } - -/// -/// Requires the profile to have one of the specified loadouts -/// -[UsedImplicitly, Serializable, NetSerializable,] -public sealed partial class CVarRequirement : CharacterRequirement -{ - [DataField("cvar", required: true)] - public string CVar; - - [DataField("requireValue", required: true)] - public string RequiredValue; - - public override bool IsValid( - JobPrototype job, - HumanoidCharacterProfile profile, - Dictionary playTimes, - bool whitelisted, - IPrototype prototype, - IEntityManager entityManager, - IPrototypeManager prototypeManager, - IConfigurationManager configManager, - out string? reason, - int depth = 0 - ) - { - if (!configManager.IsCVarRegistered(CVar)) - { - reason = null; - return true; - } - - const string color = "lightblue"; - var cvar = configManager.GetCVar(CVar); - var isValid = cvar.ToString()! == RequiredValue; - - reason = Loc.GetString( - "character-cvar-requirement", - ("inverted", Inverted), - ("color", color), - ("cvar", CVar), - ("value", RequiredValue)); - - return isValid; - } -} From 84a808a6f1df15ada2f3f85742494e6f3260d4e8 Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Sun, 8 Dec 2024 00:50:46 -0400 Subject: [PATCH 06/10] Oops --- .../Systems/CharacterRequirements.Misc.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs index b58b35ef8e3..3e5d758c485 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs @@ -1,3 +1,13 @@ +using Content.Shared.Customization.Systems; +using Content.Shared.Preferences; +using Content.Shared.Roles; +using JetBrains.Annotations; +using Robust.Shared.Configuration; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization; + +namespace Content.Shared.Customization.Systems; + /// /// Requires the profile to have one of the specified loadouts /// @@ -5,10 +15,10 @@ public sealed partial class CVarRequirement : CharacterRequirement { [DataField("cvar", required: true)] - public string CVar; + public required string CVar; [DataField("requiredValue", required: true)] - public string RequiredValue; + public required string RequiredValue; public override bool IsValid( JobPrototype job, @@ -42,4 +52,4 @@ public override bool IsValid( return isValid; } -} \ No newline at end of file +} From fd5cf13c00d1e4ce12366d49fe3eb062f3a514da Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Sun, 8 Dec 2024 00:57:52 -0400 Subject: [PATCH 07/10] silly --- .../Customization/Systems/CharacterRequirements.Misc.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs index 3e5d758c485..50ebc458a2f 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs @@ -15,10 +15,10 @@ namespace Content.Shared.Customization.Systems; public sealed partial class CVarRequirement : CharacterRequirement { [DataField("cvar", required: true)] - public required string CVar; + public string CVar; [DataField("requiredValue", required: true)] - public required string RequiredValue; + public string RequiredValue; public override bool IsValid( JobPrototype job, From 5420315a70b69e50680db72a79d770d41e56f5ff Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:32:42 -0400 Subject: [PATCH 08/10] Update CharacterRequirements.Misc.cs Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> --- .../Customization/Systems/CharacterRequirements.Misc.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs index 50ebc458a2f..62709097e6f 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs @@ -9,7 +9,7 @@ namespace Content.Shared.Customization.Systems; /// -/// Requires the profile to have one of the specified loadouts +/// Requires the server to have a specific CVar value. /// [UsedImplicitly, Serializable, NetSerializable,] public sealed partial class CVarRequirement : CharacterRequirement From dd653616431962b9d1d0903833ac8a739d897924 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:43:26 -0400 Subject: [PATCH 09/10] Update Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs Co-authored-by: VMSolidus Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> --- .../Customization/Systems/CharacterRequirements.Misc.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs index 62709097e6f..f13cb94f397 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Misc.cs @@ -17,7 +17,7 @@ public sealed partial class CVarRequirement : CharacterRequirement [DataField("cvar", required: true)] public string CVar; - [DataField("requiredValue", required: true)] + [DataField(required: true)] public string RequiredValue; public override bool IsValid( From ad36616106c3014217049c956225833946a24d17 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:14:57 -0400 Subject: [PATCH 10/10] Update Resources/Locale/en-US/customization/character-requirements.ftl Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> --- Resources/Locale/en-US/customization/character-requirements.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Locale/en-US/customization/character-requirements.ftl b/Resources/Locale/en-US/customization/character-requirements.ftl index 8c3be74231c..900e15ea66e 100644 --- a/Resources/Locale/en-US/customization/character-requirements.ftl +++ b/Resources/Locale/en-US/customization/character-requirements.ftl @@ -141,7 +141,7 @@ character-whitelist-requirement = You must{$inverted -> *[other]{""} } be whitelisted -## Cvar +## CVar character-cvar-requirement = The server must{$inverted ->