* 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
55 lines
1.7 KiB
C#
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);
|
|
}
|