From eca2d3e0aea939e17350db0a5defece6e9a30e4b Mon Sep 17 00:00:00 2001 From: SpicyDarkFox <128318785+SpicyDarkFox@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:15:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BF=D0=BE=D0=BD=D1=81?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=D0=B8=20(#303)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * улучшение спонсорки * Update ChatManager.cs забыл убрать лишнее * доработка спонсорки --- Content.Client/Lobby/LobbyUIController.cs | 33 +++++++++++++++++-- .../Preferences/ClientPreferencesManager.cs | 4 +-- .../UI/HumanoidProfileEditor.xaml.cs | 2 +- .../Clothing/Systems/LoadoutSystem.cs | 18 ++++++++-- Content.Server/Traits/TraitSystem.cs | 17 +++++++++- .../Loadouts/Systems/LoadoutSystem.cs | 24 +++++++++++--- .../Systems/CharacterRequirementsSystem.cs | 23 +++++++------ 7 files changed, 96 insertions(+), 25 deletions(-) diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index bd5496881df..2991dbc1d37 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -16,6 +16,11 @@ using Robust.Client.UserInterface.Controllers; using Robust.Shared.Map; using Robust.Shared.Prototypes; +using Robust.Shared.Player; +using Robust.Client.Player; +#if LPP_Sponsors +using Content.Client._LostParadise.Sponsors; +#endif namespace Content.Client.Lobby; @@ -28,6 +33,7 @@ public sealed partial class LobbyUIController : UIController, IOnStateEntered(); + var sponsorTier = 0; + if (sys.TryGetInfo(out var sponsorInfo)) + sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; +#endif if (UpdateClothes) { RemoveDummyClothes(_previewDummy.Value); @@ -126,7 +138,11 @@ public void UpdateCharacterUI() GiveDummyJobClothes(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile); if (ShowLoadouts) _loadouts.ApplyCharacterLoadout(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile, - _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted()); + _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted() +#if LPP_Sponsors + , sponsorTier, uuid +#endif + ); UpdateClothes = false; } @@ -171,9 +187,20 @@ public void RemoveDummyClothes(EntityUid dummy) /// public void GiveDummyJobClothesLoadout(EntityUid dummy, HumanoidCharacterProfile profile) { +#if LPP_Sponsors + var sys = IoCManager.Resolve(); + var sponsorTier = 0; + if (sys.TryGetInfo(out var sponsorInfo)) + sponsorTier = sponsorInfo.Tier; + var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : ""; +#endif var job = GetPreferredJob(profile); GiveDummyJobClothes(dummy, job, profile); - _loadouts.ApplyCharacterLoadout(dummy, job, profile, _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted()); + _loadouts.ApplyCharacterLoadout(dummy, job, profile, _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted() +#if LPP_Sponsors + , sponsorTier, uuid +#endif + ); } /// diff --git a/Content.Client/Preferences/ClientPreferencesManager.cs b/Content.Client/Preferences/ClientPreferencesManager.cs index c2c47477f8b..f6c7946f018 100644 --- a/Content.Client/Preferences/ClientPreferencesManager.cs +++ b/Content.Client/Preferences/ClientPreferencesManager.cs @@ -85,8 +85,8 @@ public void UpdateCharacter(ICharacterProfile profile, int slot) if (sponsorMarkings is not null && sponsorMarkings.Count() > 0) allowedMarkings = allowedMarkings.Concat(sponsorMarkings).ToArray(); } - var session = _playerManager.LocalSession!; - profile.EnsureValid(session, collection, allowedMarkings); + var session = _playerManager.LocalSession!; + profile.EnsureValid(session, collection, allowedMarkings); #else profile.EnsureValid(_playerManager.LocalSession!, collection); #endif diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index b2038fd06fb..94d5a656178 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -1474,7 +1474,7 @@ private void UpdateTraits(bool showUnusable) _configurationManager, out _ #if LPP_Sponsors - , 0, sponsorTier, uuid + , 0, sponsorTier, uuid #endif ); _traits.Add(trait, usable); diff --git a/Content.Server/Clothing/Systems/LoadoutSystem.cs b/Content.Server/Clothing/Systems/LoadoutSystem.cs index 73d5ae387ab..6acdcc29592 100644 --- a/Content.Server/Clothing/Systems/LoadoutSystem.cs +++ b/Content.Server/Clothing/Systems/LoadoutSystem.cs @@ -7,6 +7,9 @@ using Content.Shared.Storage; using Content.Shared.Storage.EntitySystems; using Robust.Shared.Configuration; +#if LPP_Sponsors +using Content.Server._LostParadise.Sponsors; +#endif namespace Content.Server.Clothing.Systems; @@ -17,7 +20,9 @@ public sealed class LoadoutSystem : EntitySystem [Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly SharedStorageSystem _storage = default!; [Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!; - +#if LPP_Sponsors + [Dependency] private readonly CheckSponsorSystem _checkSponsor = default!; +#endif public override void Initialize() { @@ -27,13 +32,22 @@ public override void Initialize() private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent ev) { +#if LPP_Sponsors + var sponsorTier = _checkSponsor.CheckUser(ev.Player.UserId).Item2 ?? 0; + var uuid = ev.Player.UserId.ToString(); +#endif + if (ev.JobId == null || !_configurationManager.GetCVar(CCVars.GameLoadoutsEnabled)) return; // Spawn the loadout, get a list of items that failed to equip var failedLoadouts = _loadout.ApplyCharacterLoadout(ev.Mob, ev.JobId, ev.Profile, - _playTimeTracking.GetTrackerTimes(ev.Player), ev.Player.ContentData()?.Whitelisted ?? false); + _playTimeTracking.GetTrackerTimes(ev.Player), ev.Player.ContentData()?.Whitelisted ?? false +#if LPP_Sponsors + , sponsorTier, uuid +#endif + ); // Try to find back-mounted storage apparatus if (!_inventory.TryGetSlotEntity(ev.Mob, "back", out var item) || diff --git a/Content.Server/Traits/TraitSystem.cs b/Content.Server/Traits/TraitSystem.cs index bd36b4ecefb..50111b11fc1 100644 --- a/Content.Server/Traits/TraitSystem.cs +++ b/Content.Server/Traits/TraitSystem.cs @@ -14,6 +14,9 @@ using Content.Shared.Psionics; using Content.Server.Language; using Content.Shared.Mood; +#if LPP_Sponsors +using Content.Server._LostParadise.Sponsors; +#endif namespace Content.Server.Traits; @@ -28,6 +31,9 @@ public sealed class TraitSystem : EntitySystem [Dependency] private readonly PsionicAbilitiesSystem _psionicAbilities = default!; [Dependency] private readonly IComponentFactory _componentFactory = default!; [Dependency] private readonly LanguageSystem _languageSystem = default!; +#if LPP_Sponsors + [Dependency] private readonly CheckSponsorSystem _checkSponsor = default!; +#endif public override void Initialize() { @@ -39,6 +45,11 @@ public override void Initialize() // When the player is spawned in, add all trait components selected during character creation private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args) { + +#if LPP_Sponsors + var sponsorTier = _checkSponsor.CheckUser(args.Player.UserId).Item2 ?? 0; + var uuid = args.Player.UserId.ToString(); +#endif foreach (var traitId in args.Profile.TraitPreferences) { if (!_prototype.TryIndex(traitId, out var traitPrototype)) @@ -52,7 +63,11 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args) _prototype.Index(args.JobId ?? _prototype.EnumeratePrototypes().First().ID), args.Profile, _playTimeTracking.GetTrackerTimes(args.Player), args.Player.ContentData()?.Whitelisted ?? false, traitPrototype, EntityManager, _prototype, _configuration, - out _)) + out _ +#if LPP_Sponsors + , 0, sponsorTier, uuid +#endif + )) continue; AddTrait(args.Mob, traitPrototype); diff --git a/Content.Shared/Clothing/Loadouts/Systems/LoadoutSystem.cs b/Content.Shared/Clothing/Loadouts/Systems/LoadoutSystem.cs index 5a2f1b2da90..207e8eccd5a 100644 --- a/Content.Shared/Clothing/Loadouts/Systems/LoadoutSystem.cs +++ b/Content.Shared/Clothing/Loadouts/Systems/LoadoutSystem.cs @@ -40,10 +40,18 @@ private void OnMapInit(EntityUid uid, LoadoutComponent component, MapInitEvent a public List ApplyCharacterLoadout(EntityUid uid, ProtoId job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted) + Dictionary playTimes, bool whitelisted +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" +#endif + ) { var jobPrototype = _prototype.Index(job); - return ApplyCharacterLoadout(uid, jobPrototype, profile, playTimes, whitelisted); + return ApplyCharacterLoadout(uid, jobPrototype, profile, playTimes, whitelisted +#if LPP_Sponsors + , sponsorTier, uuid +#endif + ); } /// @@ -56,7 +64,11 @@ public List ApplyCharacterLoadout(EntityUid uid, ProtoIdIf the player is whitelisted /// A list of loadout items that couldn't be equipped but passed checks public List ApplyCharacterLoadout(EntityUid uid, JobPrototype job, HumanoidCharacterProfile profile, - Dictionary playTimes, bool whitelisted) + Dictionary playTimes, bool whitelisted +#if LPP_Sponsors + , int sponsorTier = 0, string uuid = "" +#endif + ) { var failedLoadouts = new List(); @@ -72,7 +84,11 @@ public List ApplyCharacterLoadout(EntityUid uid, JobPrototype job, Hu if (!_characterRequirements.CheckRequirementsValid( loadoutProto.Requirements, job, profile, playTimes, whitelisted, loadoutProto, EntityManager, _prototype, _configuration, - out _)) + out _ +#if LPP_Sponsors + , 0, sponsorTier, uuid +#endif + )) continue; diff --git a/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs b/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs index 19726d16231..b5459536de4 100644 --- a/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs +++ b/Content.Shared/Customization/Systems/CharacterRequirementsSystem.cs @@ -25,15 +25,14 @@ public bool CheckRequirementValid(CharacterRequirement requirement, JobPrototype ) { var validation = false; -#if LPP_Sponsors - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, - out reason, depth, sponsorTier, uuid); -#else + validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, - out reason, depth); + out reason, depth +#if LPP_Sponsors + , sponsorTier, uuid #endif + ); // Return false if the requirement is invalid and not inverted // If it's inverted return false when it's valid @@ -56,15 +55,15 @@ public bool CheckRequirementsValid(List requirements, JobP { var validation = false; FormattedMessage? reason; -#if LPP_Sponsors - validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, - entityManager, prototypeManager, configManager, - out reason, depth, sponsorTier, uuid); -#else + validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager, configManager, - out reason, depth); + out reason, depth +#if LPP_Sponsors + , sponsorTier, uuid #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 (!validation)