Files
crystall-punk-14/Content.Shared/Roles/JobRequirements.cs
Ed 39ca6175e6 Simple sponsorship system (#1189)
* simple sponsorship system

* priority Join

* OOC Sponsor Color

* Update CP14SponsorRolePrototype.cs

* loadout sponsorship

* bruh

* refactor to interfaces

* Update CP14ClientSponsorManager.cs

* finish loadout option

* role pass
2025-04-17 19:55:25 +03:00

55 lines
1.7 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Content.Shared.Preferences;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Roles;
public static class JobRequirements
{
public static bool TryRequirementsMet(
NetUserId userId, //CP14 add NetUserId for sponsorship checks
JobPrototype job,
IReadOnlyDictionary<string, TimeSpan> playTimes,
[NotNullWhen(false)] out FormattedMessage? reason,
IEntityManager entManager,
IPrototypeManager protoManager,
HumanoidCharacterProfile? profile)
{
var sys = entManager.System<SharedRoleSystem>();
var requirements = sys.GetJobRequirement(job);
reason = null;
if (requirements == null)
return true;
foreach (var requirement in requirements)
{
if (!requirement.Check(userId, entManager, protoManager, profile, playTimes, out reason)) //CP14 add NetUserId for sponsorship checks
return false;
}
return true;
}
}
/// <summary>
/// Abstract class for playtime and other requirements for role gates.
/// </summary>
[ImplicitDataDefinitionForInheritors]
[Serializable, NetSerializable]
public abstract partial class JobRequirement
{
[DataField]
public bool Inverted;
public abstract bool Check(
NetUserId? userId, //CP14 Sponsorship Checks
IEntityManager entManager,
IPrototypeManager protoManager,
HumanoidCharacterProfile? profile,
IReadOnlyDictionary<string, TimeSpan> playTimes,
[NotNullWhen(false)] out FormattedMessage? reason);
}