diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index 1351aa9e86..09ec8002dc 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -20,6 +20,10 @@ using Robust.Shared.Prototypes; using Robust.Shared.Utility; using static Robust.Client.UserInterface.Controls.BoxContainer; +using Robust.Shared.Player; +#if LPP_Sponsors +using Content.Client._LostParadise.Sponsors; +#endif namespace Content.Client.LateJoin { @@ -86,6 +90,13 @@ private void RebuildUI() _jobButtons.Clear(); _jobCategories.Clear(); +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif + if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0) Logger.Warning("No stations exist, nothing to display in late-join GUI"); @@ -273,7 +284,11 @@ private void RebuildUI() _entityManager, _prototypeManager, _configManager, - out var reasons)) + out var reasons +#if LPP_Sponsors + , 0, sponsorTier +#endif + )) { jobButton.Disabled = true; diff --git a/Content.Client/Preferences/UI/AntagPreferenceSelector.cs b/Content.Client/Preferences/UI/AntagPreferenceSelector.cs index f4975a6090..a74774ee6c 100644 --- a/Content.Client/Preferences/UI/AntagPreferenceSelector.cs +++ b/Content.Client/Preferences/UI/AntagPreferenceSelector.cs @@ -4,6 +4,9 @@ using Content.Shared.Roles; using Robust.Shared.Configuration; using Robust.Shared.Prototypes; +#if LPP_Sponsors +using Content.Client._LostParadise.Sponsors; +#endif namespace Content.Client.Preferences.UI; @@ -40,6 +43,13 @@ public AntagPreferenceSelector(AntagPrototype proto, JobPrototype highJob) : bas var protoMan = IoCManager.Resolve(); var configMan = IoCManager.Resolve(); +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif + if (proto.Requirements != null && !characterReqs.CheckRequirementsValid( proto.Requirements, @@ -51,7 +61,11 @@ public AntagPreferenceSelector(AntagPrototype proto, JobPrototype highJob) : bas entMan, protoMan, configMan, - out var reasons)) + out var reasons +#if LPP_Sponsors + , 0, sponsorTier +#endif + )) LockRequirements(characterReqs.GetRequirementsText(reasons)); } } diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml index 865e7a9339..0f3fa01bce 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml @@ -4,6 +4,7 @@ xmlns:humanoid="clr-namespace:Content.Client.Humanoid" xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" + xmlns:donate="clr-namespace:Content.Client._LostParadise.Donate" HorizontalExpand="True"> @@ -219,18 +220,20 @@ - + - - + + + + - - - + + + diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index 53c18b980a..762c43e099 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -38,6 +38,9 @@ using Robust.Shared.Utility; using static Content.Client.Stylesheets.StyleBase; using Direction = Robust.Shared.Maths.Direction; +#if LPP_Sponsors +using Content.Client._LostParadise.Sponsors; +#endif namespace Content.Client.Preferences.UI { @@ -90,7 +93,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer private Button _loadoutsRemoveUnusableButton => LoadoutsRemoveUnusableButton; private NeoTabContainer _loadoutsTabs => CLoadoutsTabs; - private BoxContainer _donateList => DonateList; // Lost Paradise Donate Preferences + private BoxContainer _donateList => LPPDonateTab; // Lost Paradise Donate Preferences #if LPP_Sponsors private List<_LostParadise.Donate.DonatePreferenceSelector> _donatePreferences; // Lost Paradise Donate Preferences #endif @@ -609,25 +612,26 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt #if LPP_Sponsors // Lost Paradise Donate Preferences #region Donate - LPPDonates.Orphan(); + LPPDonateTab.Orphan(); + _tabContainer.AddTab(LPPDonateTab, Loc.GetString("lost-donate-editor")); var donate = prototypeManager.EnumeratePrototypes().OrderBy(t => Loc.GetString(t.Name)).ToList(); _donatePreferences = new List<_LostParadise.Donate.DonatePreferenceSelector>(); - _tabContainer.AddTab(LPPDonates, Loc.GetString("lost-donate-editor")); var granted = false; + _donateList.DisposeAllChildren(); if (donate.Count > 0) { foreach (var donatet in donate) { var selector = new _LostParadise.Donate.DonatePreferenceSelector(donatet); - _donateList.AddChild(selector); - _donatePreferences.Add(selector); - selector.PreferenceChanged += preference => { Profile = Profile?.WithDonatePreference(donatet.ID, preference); }; if (selector.Gave) granted = true; + + _donateList.AddChild(selector); + _donatePreferences.Add(selector); } } if (!granted) @@ -642,7 +646,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt #endregion #else - LPPDonate.Dispose(); + LPPDonateTab.Dispose(); #endif #endregion Left @@ -658,6 +662,19 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt IsDirty = false; } +#if LPP_Sponsors // Lost Paradise Donate Preferences + private void RefreshDonatePreferences() + { + _donatePreferences = new List<_LostParadise.Donate.DonatePreferenceSelector>(); + foreach (var preferenceSelector in _donatePreferences) + { + var donateId = preferenceSelector.Donate.ID; + var preference = Profile?.DonatePreferences.Contains(donateId) ?? false; + + preferenceSelector.Preference = preference; + } + } +#endif private void LoadoutsChanged(bool enabled) { @@ -737,6 +754,13 @@ private void UpdateRoleRequirements() _jobCategories.Clear(); var firstCategory = true; +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif + var departments = _prototypeManager.EnumeratePrototypes().ToArray(); Array.Sort(departments, DepartmentUIComparer.Instance); @@ -803,7 +827,11 @@ private void UpdateRoleRequirements() _entityManager, _prototypeManager, _configurationManager, - out var reasons)) + out var reasons +#if LPP_Sponsors + , 0, sponsorTier +#endif + )) selector.LockRequirements(_characterRequirementsSystem.GetRequirementsText(reasons)); category.AddChild(selector); @@ -846,6 +874,12 @@ private void UpdateRoleRequirements() /// private void EnsureJobRequirementsValid() { +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif foreach (var selector in _jobPriorities) { if (selector.Priority == JobPriority.Never @@ -859,7 +893,11 @@ private void EnsureJobRequirementsValid() _entityManager, _prototypeManager, _configurationManager, - out _)) + out _ +#if LPP_Sponsors + , 0, sponsorTier +#endif + )) continue; selector.Priority = JobPriority.Never; @@ -1506,6 +1544,13 @@ private void UpdateTraits(bool showUnusable) // Get the highest priority job to use for trait filtering var highJob = _controller.GetPreferredJob(Profile ?? HumanoidCharacterProfile.DefaultWithSpecies()); +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif + _traits.Clear(); foreach (var trait in _prototypeManager.EnumeratePrototypes()) { @@ -1520,6 +1565,9 @@ private void UpdateTraits(bool showUnusable) _prototypeManager, _configurationManager, out _ +#if LPP_Sponsors + , 0, sponsorTier +#endif ); _traits.Add(trait, usable); @@ -1812,6 +1860,12 @@ private void UpdateLoadouts(bool showUnusable) _loadoutPointsBar.MaxValue = points; _loadoutPointsBar.Value = points; +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif // Get the highest priority job to use for loadout filtering var highJob = _controller.GetPreferredJob(Profile ?? HumanoidCharacterProfile.DefaultWithSpecies()); @@ -1830,6 +1884,9 @@ private void UpdateLoadouts(bool showUnusable) _prototypeManager, _configurationManager, out _ +#if LPP_Sponsors + , 0, sponsorTier +#endif ); _loadouts.Add(loadout, usable); diff --git a/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs b/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs index 7769c64e5a..5c50705237 100644 --- a/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs +++ b/Content.Client/Preferences/UI/LoadoutPreferenceSelector.cs @@ -15,10 +15,12 @@ using Robust.Shared.Map; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +#if LPP_Sponsors +using Content.Client._LostParadise.Sponsors; +#endif namespace Content.Client.Preferences.UI; - public sealed class LoadoutPreferenceSelector : Control { public LoadoutPrototype Loadout { get; } @@ -145,13 +147,23 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob, if (!string.IsNullOrEmpty(desc)) tooltip.Append($"{Loc.GetString(desc)}"); +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var checkSponsorSystem = sys.GetEntitySystem(); + checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = checkSponsorSystem.GetSponsorStatus().Item2; +#endif // Get requirement reasons characterRequirementsSystem.CheckRequirementsValid( loadout.Requirements, highJob, profile, new Dictionary(), jobRequirementsManager.IsWhitelisted(), loadout, entityManager, prototypeManager, configManager, - out var reasons); + out var reasons +#if LPP_Sponsors + , 0, sponsorTier +#endif + ); // Add requirement reasons to the tooltip foreach (var reason in reasons) diff --git a/Content.Client/Preferences/UI/TraitPreferenceSelector.cs b/Content.Client/Preferences/UI/TraitPreferenceSelector.cs index e242f2955e..2a9ae3f56a 100644 --- a/Content.Client/Preferences/UI/TraitPreferenceSelector.cs +++ b/Content.Client/Preferences/UI/TraitPreferenceSelector.cs @@ -11,10 +11,12 @@ using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +#if LPP_Sponsors +using Content.Client._LostParadise.Sponsors; +#endif namespace Content.Client.Preferences.UI; - public sealed class TraitPreferenceSelector : Control { public TraitPrototype Trait { get; } @@ -82,13 +84,24 @@ public TraitPreferenceSelector(TraitPrototype trait, JobPrototype highJob, Human if (!string.IsNullOrEmpty(desc) && desc != $"trait-description-{trait.ID}") tooltip.Append(desc); +#if LPP_Sponsors + //Logger.Error("SPONSOR: go check sponsor - Trait"); + var sys = IoCManager.Resolve(); + var _checkSponsorSystem = sys.GetEntitySystem(); + _checkSponsorSystem.GoCheckSponsor(); + var sponsorTier = _checkSponsorSystem.GetSponsorStatus().Item2; +#endif // Get requirement reasons characterRequirementsSystem.CheckRequirementsValid( trait.Requirements, highJob, profile, new Dictionary(), jobRequirementsManager.IsWhitelisted(), trait, entityManager, prototypeManager, configManager, - out var reasons); + out var reasons +#if LPP_Sponsors + , 0, sponsorTier +#endif + ); // Add requirement reasons to the tooltip foreach (var reason in reasons) diff --git a/Content.Server/Corvax/TTS/TTSSystem.Sanitize.cs b/Content.Server/Corvax/TTS/TTSSystem.Sanitize.cs index 81f2d3920b..8ff595530a 100644 --- a/Content.Server/Corvax/TTS/TTSSystem.Sanitize.cs +++ b/Content.Server/Corvax/TTS/TTSSystem.Sanitize.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using System.Text.RegularExpressions; using Content.Server.Chat.Systems; @@ -10,7 +10,7 @@ public sealed partial class TTSSystem private void OnTransformSpeech(TransformSpeechEvent args) { if (!_isEnabled) return; - args.Message = args.Message.Replace("+", ""); + args.Message = args.Message.Replace("+", " "); } private string Sanitize(string text) diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs index de53235198..bc976bed43 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs @@ -20,6 +20,9 @@ using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +#if LPP_Sponsors +using Content.Server._LostParadise.Sponsors; +#endif namespace Content.Server.Players.PlayTimeTracking; @@ -37,7 +40,9 @@ public sealed class PlayTimeTrackingSystem : EntitySystem [Dependency] private readonly CharacterRequirementsSystem _characterRequirements = default!; [Dependency] private readonly IServerPreferencesManager _prefs = default!; [Dependency] private readonly IConfigurationManager _config = default!; - +#if LPP_Sponsors + [Dependency] private readonly CheckSponsorSystem _checkSponsor = default!; +#endif public override void Initialize() { @@ -180,6 +185,10 @@ public bool IsAllowed(ICommonSession player, string role) var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // DeltaV - Whitelist requirement +#if LPP_Sponsors + var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0; +#endif + return _characterRequirements.CheckRequirementsValid( job.Requirements, job, @@ -190,7 +199,11 @@ public bool IsAllowed(ICommonSession player, string role) EntityManager, _prototypes, _config, - out _); + out _ +#if LPP_Sponsors + , 0, sponsorTier +#endif + ); } public HashSet GetDisallowedJobs(ICommonSession player) @@ -207,6 +220,10 @@ public HashSet GetDisallowedJobs(ICommonSession player) var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // DeltaV - Whitelist requirement +#if LPP_Sponsors + var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0; +#endif + foreach (var job in _prototypes.EnumeratePrototypes()) { if (job.Requirements != null) @@ -221,7 +238,11 @@ public HashSet GetDisallowedJobs(ICommonSession player) EntityManager, _prototypes, _config, - out _)) + out _ +#if LPP_Sponsors + , 0, sponsorTier +#endif + )) continue; goto NoRole; @@ -249,6 +270,10 @@ public void RemoveDisallowedJobs(NetUserId userId, ref List jobs) var isWhitelisted = player.ContentData()?.Whitelisted ?? false; // DeltaV - Whitelist requirement +#if LPP_Sponsors + var sponsorTier = _checkSponsor.CheckUser(player.UserId).Item2 ?? 0; +#endif + for (var i = 0; i < jobs.Count; i++) { var job = jobs[i]; @@ -268,7 +293,11 @@ public void RemoveDisallowedJobs(NetUserId userId, ref List jobs) EntityManager, _prototypes, _config, - out _)) + out _ +#if LPP_Sponsors + , 0, sponsorTier +#endif + )) { jobs.RemoveSwap(i); i--; diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs index f9a060b738..d62b6ea7d2 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Job.cs @@ -23,6 +23,13 @@ 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); +#endif + public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -69,6 +76,13 @@ 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); +#endif + public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -111,10 +125,20 @@ 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) + 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 +#endif + ) { // Disable the requirement if the role timers are disabled if (!configManager.GetCVar(CCVars.GameRoleTimers)) @@ -123,6 +147,15 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, return !Inverted; } +#if LPP_Sponsors + //Logger.Error($"SPONSOR: CharacterDepartmentTimeRequirement. Tier: {sponsorTier}, whitelisted: {whitelisted}"); + if (sponsorTier >= 5) + { + reason = null; + return true; + } +#endif + var department = prototypeManager.Index(Department); // Combine all of this department's job playtimes @@ -177,10 +210,20 @@ 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) + 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 +#endif + ) { // Disable the requirement if the role timers are disabled if (!configManager.GetCVar(CCVars.GameRoleTimers)) @@ -189,6 +232,15 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, return !Inverted; } +#if LPP_Sponsors + //Logger.Error($"SPONSOR: CharacterOverallTimeRequirement. Tier: {sponsorTier}, whitelisted: {whitelisted}"); + if (sponsorTier >=5) + { + reason = null; + return true; + } +#endif + // Get the overall time var overallTime = playTimes.GetValueOrDefault(PlayTimeTrackingShared.TrackerOverall); @@ -233,10 +285,20 @@ 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) + 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 +#endif + ) { // Disable the requirement if the role timers are disabled if (!configManager.GetCVar(CCVars.GameRoleTimers)) @@ -245,6 +307,15 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, return !Inverted; } +#if LPP_Sponsors + //Logger.Error($"SPONSOR: CharacterPlaytimeRequirement. Tier: {sponsorTier}, whitelisted: {whitelisted}"); + if (sponsorTier >= 5) + { + reason = null; + return true; + } +#endif + // Get SharedJobSystem if (!entityManager.EntitySysManager.TryGetEntitySystem(out SharedJobSystem? jobSystem)) { diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs index 397e74bc8b..646201c170 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Logic.cs @@ -20,14 +20,28 @@ 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) + 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 +#endif + ) { var succeeded = entityManager.EntitySysManager.GetEntitySystem() .CheckRequirementsValid(Requirements, job, profile, playTimes, whitelisted, prototype, entityManager, - prototypeManager, configManager, out var reasons, depth + 1); + prototypeManager, configManager, out var reasons, depth + 1 +#if LPP_Sponsors + , sponsorTier = 0 +#endif + ); if (reasons.Count == 0) { @@ -56,10 +70,21 @@ 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) + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0 +#endif + ) { var succeeded = false; var reasons = new List(); @@ -67,8 +92,24 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, foreach (var requirement in Requirements) { - if (characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, out var raisin, depth + 1)) + 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); +#else + validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, + entityManager, prototypeManager, configManager, out raisin, depth + 1); +#endif + + if (validation) { succeeded = true; break; @@ -105,10 +146,20 @@ 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) + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0 +#endif + ) { var reasons = new List(); var succeeded = false; @@ -116,8 +167,23 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, foreach (var requirement in Requirements) { - if (characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, out var raisin, depth + 1)) + 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); +#else + validation = characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype, + entityManager, prototypeManager, configManager, out raisin, depth + 1); +#endif + if (validation) { if (succeeded) { diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs index 8fdb7c0e7d..f6ef5c7abc 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Profile.cs @@ -30,6 +30,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -51,6 +57,12 @@ public sealed partial class CharacterBackpackTypeRequirement : CharacterRequirem [DataField(required: true)] public BackpackPreference Preference; +#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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -73,6 +85,12 @@ public sealed partial class CharacterClothingPreferenceRequirement : CharacterRe [DataField(required: true)] public ClothingPreference Preference; +#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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -95,6 +113,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -117,6 +141,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -139,6 +169,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -173,6 +209,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -208,6 +250,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -243,6 +291,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -282,6 +336,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -307,6 +367,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, @@ -332,6 +398,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs b/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs index d23d472e06..a0504fffa8 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.Whitelist.cs @@ -17,6 +17,12 @@ 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); +#endif public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, diff --git a/Content.Shared/Customization/Systems/CharacterRequirements.cs b/Content.Shared/Customization/Systems/CharacterRequirements.cs index 2bf24700a6..7569707ec9 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirements.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirements.cs @@ -38,4 +38,20 @@ public abstract bool IsValid( 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 + ); +#endif } diff --git a/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs b/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs index 9becb640d1..3eb05cc8ac 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs @@ -18,33 +18,72 @@ public sealed class CharacterRequirementsSystem : EntitySystem public bool CheckRequirementValid(CharacterRequirement requirement, JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out FormattedMessage? reason, int depth = 0) + out FormattedMessage? reason, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0 +#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, + entityManager, prototypeManager, configManager, + out reason, depth, sponsorTier); + 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 // If it's inverted return false when it's valid - return - !requirement.IsValid(job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, - out reason, depth) - ? requirement.Inverted - : !requirement.Inverted; + return !validation ? requirement.Inverted : !requirement.Inverted; } public bool CheckRequirementsValid(List requirements, JobPrototype job, HumanoidCharacterProfile profile, Dictionary playTimes, bool whitelisted, IPrototype prototype, IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager, - out List reasons, int depth = 0) + out List reasons, int depth = 0 +#if LPP_Sponsors + , int sponsorTier = 0 +#endif + ) { reasons = new List(); var valid = true; foreach (var requirement in requirements) { + 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, + entityManager, prototypeManager, configManager, + out reason, depth); +#else + validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, + entityManager, prototypeManager, configManager, + out reason, depth); +#endif // Set valid to false if the requirement is invalid and not inverted // If it's inverted set valid to false when it's valid - if (!requirement.IsValid(job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, - out var reason, depth)) + if (!validation) { if (valid) valid = requirement.Inverted;