From d820d144d42aef5a63215cfaace8085f5a696c40 Mon Sep 17 00:00:00 2001 From: SpicyDarkFox <128318785+SpicyDarkFox@users.noreply.github.com> Date: Thu, 17 Oct 2024 02:22:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=81=D0=BF=D0=BE=D0=BD=D1=81=D0=BE=D1=80=D0=BA?= =?UTF-8?q?=D0=B8=20(#282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * улучшение спонсорки --- Content.Client/LateJoin/LateJoinGui.cs | 5 +- .../Preferences/UI/AntagPreferenceSelector.cs | 9 +- .../UI/HumanoidProfileEditor.xaml.cs | 16 ++- .../UI/LoadoutPreferenceSelector.cs | 8 +- .../Preferences/UI/TraitPreferenceSelector.cs | 10 +- Content.Server/Chat/Managers/ChatManager.cs | 12 ++- .../PlayTimeTrackingSystem.cs | 9 +- .../Systems/CharacterRequirements.Job.cs | 46 ++------ .../Systems/CharacterRequirements.Logic.cs | 50 ++------- .../Systems/CharacterRequirements.Profile.cs | 100 +++++++----------- .../CharacterRequirements.Whitelist.cs | 10 +- .../Systems/CharacterRequirements.cs | 18 +--- .../Systems/CharacterRequirementsSystem.cs | 32 ++---- 13 files changed, 130 insertions(+), 195 deletions(-) diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index 8e2c7462cae..c021985603f 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -21,6 +21,7 @@ using Robust.Shared.Utility; using static Robust.Client.UserInterface.Controls.BoxContainer; using Robust.Shared.Player; +using Robust.Client.Player; #if LPP_Sponsors using Content.Client._LostParadise.Sponsors; #endif @@ -29,6 +30,7 @@ namespace Content.Client.LateJoin { public sealed class LateJoinGui : DefaultWindow { + [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!; [Dependency] private readonly IConfigurationManager _configManager = default!; @@ -95,6 +97,7 @@ private void RebuildUI() var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0) @@ -286,7 +289,7 @@ private void RebuildUI() _configManager, out var reasons #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif )) { diff --git a/Content.Client/Preferences/UI/AntagPreferenceSelector.cs b/Content.Client/Preferences/UI/AntagPreferenceSelector.cs index 8b0e899e26a..bfee555a80c 100644 --- a/Content.Client/Preferences/UI/AntagPreferenceSelector.cs +++ b/Content.Client/Preferences/UI/AntagPreferenceSelector.cs @@ -2,8 +2,13 @@ using Content.Shared.Customization.Systems; using Content.Shared.Preferences; using Content.Shared.Roles; +using System.Linq; +using System.Numerics; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; +using Robust.Shared.Player; +using Robust.Client.Player; + #if LPP_Sponsors using Content.Client._LostParadise.Sponsors; #endif @@ -12,6 +17,7 @@ namespace Content.Client.Preferences.UI; public sealed class AntagPreferenceSelector : RequirementsSelector { + [Dependency] private readonly IPlayerManager _playerManager = default!; // 0 is yes and 1 is no public bool Preference { @@ -48,6 +54,7 @@ public AntagPreferenceSelector(AntagPrototype proto, JobPrototype highJob) : bas var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = "";//_playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif if (proto.Requirements != null @@ -63,7 +70,7 @@ public AntagPreferenceSelector(AntagPrototype proto, JobPrototype highJob) : bas configMan, out var reasons #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif )) LockRequirements(characterReqs.GetRequirementsText(reasons)); diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index 2b399a2e31e..e4fe9c50694 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -31,6 +31,8 @@ using Robust.Shared.Physics; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +using Robust.Shared.Player; +using Robust.Client.Player; using Direction = Robust.Shared.Maths.Direction; #if LPP_Sponsors using Content.Client._LostParadise.Sponsors; @@ -41,6 +43,7 @@ namespace Content.Client.Preferences.UI [GenerateTypedNameReferences] public sealed partial class HumanoidProfileEditor : BoxContainer { + private readonly IPlayerManager _playerManager; private readonly IEntityManager _entityManager; private readonly IPrototypeManager _prototypeManager; private readonly IClientPreferencesManager _preferencesManager; @@ -121,6 +124,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt IConfigurationManager configurationManager) { RobustXamlLoader.Load(this); + _playerManager = IoCManager.Resolve(); _entityManager = IoCManager.Resolve(); _prototypeManager = prototypeManager; _preferencesManager = preferencesManager; @@ -734,6 +738,7 @@ private void UpdateRoleRequirements() var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif var departments = _prototypeManager.EnumeratePrototypes().ToArray(); @@ -804,7 +809,7 @@ private void UpdateRoleRequirements() _configurationManager, out var reasons #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif )) selector.LockRequirements(_characterRequirementsSystem.GetRequirementsText(reasons)); @@ -854,6 +859,7 @@ private void EnsureJobRequirementsValid() var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif foreach (var selector in _jobPriorities) { @@ -870,7 +876,7 @@ private void EnsureJobRequirementsValid() _configurationManager, out _ #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif )) continue; @@ -1508,6 +1514,7 @@ private void UpdateTraits(bool showUnusable) var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif _traits.Clear(); @@ -1525,7 +1532,7 @@ private void UpdateTraits(bool showUnusable) _configurationManager, out _ #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif ); _traits.Add(trait, usable); @@ -1824,6 +1831,7 @@ private void UpdateLoadouts(bool showUnusable) var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif // Get the highest priority job to use for loadout filtering @@ -1844,7 +1852,7 @@ private void UpdateLoadouts(bool showUnusable) _configurationManager, out _ #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif ); _loadouts.Add(loadout, usable); diff --git a/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs b/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs index d1c756a0fa5..b9bd970db03 100644 --- a/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs +++ b/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs @@ -15,6 +15,8 @@ using Robust.Shared.Map; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +using Robust.Shared.Player; +using Robust.Client.Player; #if LPP_Sponsors using Content.Client._LostParadise.Sponsors; #endif @@ -23,6 +25,7 @@ namespace Content.Client.Preferences.UI; public sealed class LoadoutPreferenceSelector : Control { + private readonly IPlayerManager _playerManager; public LoadoutPrototype Loadout { get; } public bool Valid; @@ -66,6 +69,8 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, CharacterRequirementsSystem characterRequirementsSystem, JobRequirementsManager jobRequirementsManager) { + _playerManager = IoCManager.Resolve(); + Loadout = loadout; SpriteView previewLoadout; @@ -152,6 +157,7 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob, var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif // Get requirement reasons @@ -161,7 +167,7 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob, entityManager, prototypeManager, configManager, out var reasons #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif ); diff --git a/Content.Client/Preferences/UI/TraitPreferenceSelector.cs b/Content.Client/Preferences/UI/TraitPreferenceSelector.cs index a9ab51b4da3..6e7396ca099 100644 --- a/Content.Client/Preferences/UI/TraitPreferenceSelector.cs +++ b/Content.Client/Preferences/UI/TraitPreferenceSelector.cs @@ -11,6 +11,9 @@ using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +using Robust.Shared.Player; +using Robust.Client.Player; +using System.Linq; #if LPP_Sponsors using Content.Client._LostParadise.Sponsors; #endif @@ -19,6 +22,8 @@ namespace Content.Client.Preferences.UI; public sealed class TraitPreferenceSelector : Control { + private readonly IPlayerManager _playerManager; + public TraitPrototype Trait { get; } public bool Valid; @@ -48,6 +53,8 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, CharacterRequirementsSystem characterRequirementsSystem, JobRequirementsManager jobRequirementsManager) { + _playerManager = IoCManager.Resolve(); + Trait = trait; // Create a checkbox to get the loadout @@ -89,6 +96,7 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human var sponsorTier = 0; if (sys.TryGetInfo(out var sponsorInfo)) sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; #endif // Get requirement reasons @@ -98,7 +106,7 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human entityManager, prototypeManager, configManager, out var reasons #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif ); diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 18215a28148..b8695e1bd4d 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -243,14 +243,20 @@ private void SendOOC(ICommonSession player, string message) return; } - var wrappedMessage = Loc.GetString("chat-manager-send-ooc-wrap-message", ("playerName",player.Name), ("message", FormattedMessage.EscapeText(message))); + Color? colorOverride = null; + var wrappedMessage = Loc.GetString("chat-manager-send-ooc-wrap-message", ("playerName", player.Name), ("message", FormattedMessage.EscapeText(message))); + if (_adminManager.HasAdminFlag(player, AdminFlags.Admin)) + { + var prefs = _preferencesManager.GetPreferences(player.UserId); + colorOverride = prefs.AdminOOCColor; + } if (_netConfigManager.GetClientCVar(player.Channel, CCVars.ShowOocPatronColor) && player.Channel.UserData.PatronTier is { } patron && PatronOocColors.TryGetValue(patron, out var patronColor)) { - wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", patronColor),("playerName", player.Name), ("message", FormattedMessage.EscapeText(message))); + wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", patronColor), ("playerName", player.Name), ("message", FormattedMessage.EscapeText(message))); } #if LPP_Sponsors // _LostParadise-Sponsors - if (_sponsorsManager.TryGetInfo(player.UserId, out var sponsorData) && sponsorData.OOCColor != null) + if (_sponsorsManager.TryGetInfo(player.UserId, out var sponsorData) && sponsorData.Tier > 0) { wrappedMessage = Loc.GetString("chat-manager-send-ooc-patron-wrap-message", ("patronColor", sponsorData.OOCColor), ("playerName", player.Name), ("message", FormattedMessage.EscapeText(message))); } diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs index bc976bed432..ea95e2704b2 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs @@ -187,6 +187,7 @@ public bool IsAllowed(ICommonSession player, string role) #if LPP_Sponsors var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0; + var uuid = player.UserId.ToString(); #endif return _characterRequirements.CheckRequirementsValid( @@ -201,7 +202,7 @@ public bool IsAllowed(ICommonSession player, string role) _config, out _ #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif ); } @@ -222,6 +223,7 @@ public HashSet GetDisallowedJobs(ICommonSession player) #if LPP_Sponsors var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0; + var uuid = player.UserId.ToString(); #endif foreach (var job in _prototypes.EnumeratePrototypes()) @@ -240,7 +242,7 @@ public HashSet GetDisallowedJobs(ICommonSession player) _config, out _ #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif )) continue; @@ -272,6 +274,7 @@ public void RemoveDisallowedJobs(NetUserId userId, ref List jobs) #if LPP_Sponsors var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0; + var uuid = player.UserId.ToString(); #endif for (var i = 0; i < jobs.Count; i++) @@ -295,7 +298,7 @@ public void RemoveDisallowedJobs(NetUserId userId, ref List jobs) _config, out _ #if LPP_Sponsors - , 0, sponsorTier + , 0, sponsorTier, uuid #endif )) { diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs index 024b3001092..e956b111cca 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs @@ -23,17 +23,14 @@ public sealed partial class CharacterJobRequirement : CharacterRequirement [DataField(required: true)] public List> Jobs; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { var jobs = new List(); @@ -76,17 +73,14 @@ public sealed partial class CharacterDepartmentRequirement : CharacterRequiremen [DataField(required: true)] public List> Departments; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { var departments = new List(); @@ -125,18 +119,12 @@ public sealed partial class CharacterDepartmentTimeRequirement : CharacterRequir [DataField(required: true)] public ProtoId Department; -#if LPP_Sponsors - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth, 0); -#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { @@ -216,18 +204,12 @@ public sealed partial class CharacterOverallTimeRequirement : CharacterRequireme [DataField] public TimeSpan Max = TimeSpan.MaxValue; -#if LPP_Sponsors - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth, 0); -#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { @@ -297,18 +279,12 @@ public sealed partial class CharacterPlaytimeRequirement : CharacterRequirement [DataField(required: true)] public ProtoId Tracker; -#if LPP_Sponsors - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth, 0); -#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs index 646201c1703..2c3b6c7b11c 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs @@ -20,18 +20,12 @@ public sealed partial class CharacterLogicAndRequirement : CharacterRequirement [DataField] public List Requirements { get; private set; } = new(); -#if LPP_Sponsors - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth, 0); -#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { @@ -39,7 +33,7 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, .CheckRequirementsValid(Requirements, job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out var reasons, depth + 1 #if LPP_Sponsors - , sponsorTier = 0 + , sponsorTier = 0, uuid #endif ); @@ -70,19 +64,12 @@ public sealed partial class CharacterLogicOrRequirement : CharacterRequirement [DataField] public List Requirements { get; private set; } = new(); -#if LPP_Sponsors - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth, 0); -#endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { @@ -94,16 +81,10 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, { var validation = false; FormattedMessage? raisin; + #if LPP_Sponsors - if (requirement is CharacterDepartmentTimeRequirement || - requirement is CharacterOverallTimeRequirement || - requirement is CharacterPlaytimeRequirement - ) - validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, out raisin, depth + 1, sponsorTier); - else - validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, out raisin, depth + 1); + validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, + entityManager, prototypeManager, configManager, out raisin, depth + 1, sponsorTier, uuid); #else validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out raisin, depth + 1); @@ -146,18 +127,12 @@ public sealed partial class CharacterLogicXorRequirement : CharacterRequirement [DataField] public List Requirements { get; private set; } = new(); -#if LPP_Sponsors - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth, 0); -#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { @@ -170,15 +145,8 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, var validation = false; FormattedMessage? raisin; #if LPP_Sponsors - if (requirement is CharacterDepartmentTimeRequirement || - requirement is CharacterOverallTimeRequirement || - requirement is CharacterPlaytimeRequirement - ) - validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, out raisin, depth + 1, sponsorTier); - else - validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, out raisin, depth + 1); + validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, + entityManager, prototypeManager, configManager, out raisin, depth + 1, sponsorTier, uuid); #else validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out raisin, depth + 1); diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index 9c6a5d80bcf..a5defdfb14d 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -30,16 +30,14 @@ public sealed partial class CharacterAgeRequirement : CharacterRequirement [DataField(required: true)] public int Max; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { reason = FormattedMessage.FromMarkup(Loc.GetString("character-age-requirement", ("inverted", Inverted), ("min", Min), ("max", Max))); @@ -57,16 +55,14 @@ public sealed partial class CharacterGenderRequirement : CharacterRequirement [DataField(required: true)] public Gender Gender; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { reason = FormattedMessage.FromMarkup(Loc.GetString("character-gender-requirement", ("inverted", Inverted), @@ -85,16 +81,14 @@ public sealed partial class CharacterSexRequirement : CharacterRequirement [DataField(required: true)] public Sex Sex; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { reason = FormattedMessage.FromMarkup(Loc.GetString("character-sex-requirement", ("inverted", Inverted), @@ -113,16 +107,14 @@ public sealed partial class CharacterSpeciesRequirement : CharacterRequirement [DataField(required: true)] public List> Species; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { const string color = "green"; reason = FormattedMessage.FromMarkup(Loc.GetString("character-species-requirement", @@ -153,16 +145,14 @@ public sealed partial class CharacterHeightRequirement : CharacterRequirement [DataField] public float Max = int.MaxValue; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { const string color = "yellow"; var species = prototypeManager.Index(profile.Species); @@ -194,16 +184,14 @@ public sealed partial class CharacterWidthRequirement : CharacterRequirement [DataField] public float Max = int.MaxValue; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { const string color = "yellow"; var species = prototypeManager.Index(profile.Species); @@ -235,16 +223,14 @@ public sealed partial class CharacterWeightRequirement : CharacterRequirement [DataField] public float Max = int.MaxValue; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { const string color = "green"; var species = prototypeManager.Index(profile.Species); @@ -280,16 +266,14 @@ public sealed partial class CharacterTraitRequirement : CharacterRequirement [DataField(required: true)] public List> Traits; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { const string color = "lightblue"; reason = FormattedMessage.FromMarkup(Loc.GetString("character-trait-requirement", @@ -311,16 +295,14 @@ public sealed partial class CharacterLoadoutRequirement : CharacterRequirement [DataField(required: true)] public List> Loadouts; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { const string color = "lightblue"; reason = FormattedMessage.FromMarkup(Loc.GetString("character-loadout-requirement", @@ -342,16 +324,14 @@ public sealed partial class CharacterItemGroupRequirement : CharacterRequirement [DataField(required: true)] public ProtoId Group; -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { var group = prototypeManager.Index(Group); diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs index a0504fffa80..1f9b747443b 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs @@ -17,16 +17,14 @@ namespace Content.Shared.Customization.Systems; [Serializable, NetSerializable] public sealed partial class CharacterWhitelistRequirement : CharacterRequirement { -#if LPP_Sponsors public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0, int sponsorTier = 0) => IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" #endif - public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted, IPrototype prototype, - IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + ) { reason = FormattedMessage.FromMarkup(Loc.GetString("character-whitelist-requirement", ("inverted", Inverted))); return !configManager.GetCVar(CCVars.WhitelistEnabled) || whitelisted; diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.cs b/Content.Shared/Customization/Systems/CharacterRequirements.cs index 7569707ec91..831d7cfab94 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.cs @@ -37,21 +37,9 @@ public abstract bool IsValid( IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 - ); - #if LPP_Sponsors - public abstract bool IsValid( - JobPrototype job, - HumanoidCharacterProfile profile, - Dictionary playTimes, - bool whitelisted, - IPrototype prototype, - IEntityManager entityManager, - IPrototypeManager prototypeManager, - IConfigurationManager configManager, - out FormattedMessage? reason, - int depth = 0, - int sponsorTier = 0 - ); + , int sponsorTier = 0, + string uuid = "" #endif + ); } diff --git a/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs b/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs index 3eb05cc8ac9..19726d16231 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs @@ -20,27 +20,19 @@ public bool CheckRequirementValid(CharacterRequirement requirement, JobPrototype IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out FormattedMessage? reason, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { var validation = false; #if LPP_Sponsors - if (requirement is CharacterDepartmentTimeRequirement || - requirement is CharacterOverallTimeRequirement || - requirement is CharacterPlaytimeRequirement - ) - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, + validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, - out reason, depth, sponsorTier); - else - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, + out reason, depth, sponsorTier, uuid); +#else + validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, out reason, depth); -#else - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, - out reason, depth); #endif // Return false if the requirement is invalid and not inverted @@ -53,7 +45,7 @@ public bool CheckRequirementsValid(List requirements, JobP IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, out List reasons, int depth = 0 #if LPP_Sponsors - , int sponsorTier = 0 + , int sponsorTier = 0, string uuid = "" #endif ) { @@ -65,17 +57,9 @@ public bool CheckRequirementsValid(List requirements, JobP var validation = false; FormattedMessage? reason; #if LPP_Sponsors - if (requirement is CharacterDepartmentTimeRequirement || - requirement is CharacterOverallTimeRequirement || - requirement is CharacterPlaytimeRequirement - ) - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, - out reason, depth, sponsorTier); - else - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, + validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, - out reason, depth); + out reason, depth, sponsorTier, uuid); #else validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager,