Files
crystall-punk-14/Content.Shared/Preferences/Loadouts/Effects/JobRequirementLoadoutEffect.cs
Ed 3409e0f752 Merge remote-tracking branch 'upstream/stable' into ed-15-09-2025-upstream-sync
# Conflicts:
#	.github/CODEOWNERS
#	Content.Client/Overlays/StencilOverlay.cs
#	Content.Server/Chemistry/EntitySystems/InjectorSystem.cs
#	Content.Server/GameTicking/Commands/SetGamePresetCommand.cs
#	Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs
#	Content.Shared/Chemistry/EntitySystems/SharedInjectorSystem.cs
#	Content.Shared/Clothing/Components/ClothingComponent.cs
#	Content.Shared/Humanoid/HumanoidCharacterAppearance.cs
#	Content.Shared/Humanoid/SkinColor.cs
#	Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/bowl.yml
2025-09-15 13:50:49 +03:00

42 lines
1.5 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Content.Shared.CCVar;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Roles;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Preferences.Loadouts.Effects;
/// <summary>
/// Checks for a job requirement to be met such as playtime.
/// </summary>
public sealed partial class JobRequirementLoadoutEffect : LoadoutEffect
{
[DataField(required: true)]
public JobRequirement Requirement = default!;
public override bool Validate(HumanoidCharacterProfile profile, RoleLoadout loadout, ICommonSession? session, IDependencyCollection collection, [NotNullWhen(false)] out FormattedMessage? reason)
{
var configurationManager = collection.Resolve<IConfigurationManager>();
var timersDisabled = !configurationManager.GetCVar(CCVars.GameRoleLoadoutTimers);
if (session == null || timersDisabled)
{
reason = FormattedMessage.Empty;
return true;
}
var manager = collection.Resolve<ISharedPlaytimeManager>();
var playtimes = manager.GetPlayTimes(session);
return Requirement.Check(
session.UserId, //CP14 add NetUserId for sponsorship checks
collection.Resolve<IEntityManager>(),
collection.Resolve<IPrototypeManager>(),
profile,
playtimes,
out reason);
}
}