-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Поправка для спонсорки #303
Changes from all commits
0a86856
9f9589f
2dfde22
b720d1d
fca36ba
1f98318
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Lo | |
[UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!; | ||
[UISystemDependency] private readonly ClientInventorySystem _inventory = default!; | ||
[UISystemDependency] private readonly LoadoutSystem _loadouts = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
private LobbyCharacterPanel? _previewPanel; | ||
private HumanoidProfileEditor? _profileEditor; | ||
|
@@ -118,15 +124,25 @@ public void UpdateCharacterUI() | |
_previewPanel?.SetSummaryText(maybeProfile.Summary); | ||
_humanoid.LoadProfile(_previewDummy.Value, maybeProfile); | ||
|
||
|
||
#if LPP_Sponsors | ||
var sys = IoCManager.Resolve<SponsorsManager>(); | ||
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); | ||
if (ShowClothes) | ||
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) | |
/// </summary> | ||
public void GiveDummyJobClothesLoadout(EntityUid dummy, HumanoidCharacterProfile profile) | ||
{ | ||
#if LPP_Sponsors | ||
var sys = IoCManager.Resolve<SponsorsManager>(); | ||
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 | ||
); | ||
Comment on lines
+190
to
+203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Устранить дублирование кода! Код получения спонсорской информации дублируется в методах После создания предложенного метода - var sys = IoCManager.Resolve<SponsorsManager>();
- var sponsorTier = 0;
- if (sys.TryGetInfo(out var sponsorInfo))
- sponsorTier = sponsorInfo.Tier;
- var uuid = _playerManager.LocalUser != null ? _playerManager.LocalUser.ToString() ?? "" : "";
+ var (sponsorTier, uuid) = GetSponsorInfo();
|
||
} | ||
|
||
/// <summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Проверьте необходимость явного указания default! Зависимость - [Dependency] private readonly CheckSponsorSystem _checkSponsor = default!;
+ [Dependency] private readonly CheckSponsorSystem _checkSponsor; Also applies to: 34-36 |
||
|
||
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<TraitPrototype>(traitId, out var traitPrototype)) | ||
|
@@ -52,7 +63,11 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args) | |
_prototype.Index<JobPrototype>(args.JobId ?? _prototype.EnumeratePrototypes<JobPrototype>().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 | ||
)) | ||
SpicyDarkFox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
continue; | ||
|
||
AddTrait(args.Mob, traitPrototype); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
); | ||
SpicyDarkFox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// 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<CharacterRequirement> 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 | ||
); | ||
|
||
Comment on lines
+58
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Предлагаю убрать лишние пустые строки Пустые строки до и после вызова - FormattedMessage? reason;
-
validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype,
entityManager, prototypeManager, configManager,
out reason, depth
#if LPP_Sponsors
, sponsorTier, uuid
#endif
);
-
// Set valid to false if the requirement is invalid and not inverted
+ FormattedMessage? reason;
+ validation = requirement.IsValid(job, profile, playTimes, whitelisted, prototype,
+ entityManager, prototypeManager, configManager,
+ out reason, depth
+#if LPP_Sponsors
+ , sponsorTier, uuid
+#endif
+ );
+ // Set valid to false if the requirement is invalid and not inverted
|
||
// 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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Необходима защита от null при работе с UUID!
В строке 132 возможно возникновение NullReferenceException при вызове
ToString()
. Также рекомендуется выделить логику получения спонсорской информации в отдельный метод для улучшения читаемости кода.Предлагаемые изменения:
Рекомендуется выделить логику получения спонсорской информации в отдельный метод: