# Conflicts: # Content.Client/UserInterface/Controls/RadialContainer.cs # Content.Server/Lathe/LatheSystem.cs # Content.Server/Silicons/Laws/SiliconLawSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Materials/SharedMaterialReclaimerSystem.cs # Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs # Content.Shared/VendingMachines/SharedVendingMachineSystem.cs # Content.Shared/Wieldable/SharedWieldableSystem.cs # Resources/Locale/en-US/_strings/station-events/events/radiation-storm.ftl # Resources/Locale/en-US/_strings/store/uplink-catalog.ftl # Resources/Prototypes/Atmospherics/gases.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Datasets/Names/borg.yml # Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml # Resources/Prototypes/Entities/Mobs/Player/silicon.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Snipers/snipers.yml # Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml # Resources/ServerInfo/Guidebook/Engineering/AME.xml # Resources/ServerInfo/Guidebook/Engineering/AirlockSecurity.xml # Resources/ServerInfo/Guidebook/Engineering/Atmospherics.xml # Resources/ServerInfo/Guidebook/Engineering/Construction.xml # Resources/ServerInfo/Guidebook/Engineering/Engineering.xml # Resources/ServerInfo/Guidebook/Engineering/Fires.xml # Resources/ServerInfo/Guidebook/Engineering/NetworkConfigurator.xml # Resources/ServerInfo/Guidebook/Engineering/Networking.xml # Resources/ServerInfo/Guidebook/Engineering/Power.xml # Resources/ServerInfo/Guidebook/Engineering/RTG.xml # Resources/ServerInfo/Guidebook/Engineering/Shuttlecraft.xml # Resources/ServerInfo/Guidebook/Engineering/Singularity.xml # Resources/ServerInfo/Guidebook/Engineering/TEG.xml # Resources/ServerInfo/Guidebook/Security/CriminalRecords.xml # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/equipped-OUTERCLOTHING.png # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/icon.png # Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/meta.json # Resources/Textures/Objects/Weapons/Guns/Rifles/lecter.rsi/equipped-BACKPACK.png # Resources/migration.yml
87 lines
2.8 KiB
C#
87 lines
2.8 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Content.Shared.Localizations;
|
|
using System.Linq;
|
|
using Content.Shared.Players.PlayTimeTracking;
|
|
using Content.Shared.Preferences;
|
|
using Content.Shared.Roles.Jobs;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared.Roles;
|
|
|
|
[UsedImplicitly]
|
|
[Serializable, NetSerializable]
|
|
public sealed partial class RoleTimeRequirement : JobRequirement
|
|
{
|
|
/// <summary>
|
|
/// What particular role they need the time requirement with.
|
|
/// </summary>
|
|
[DataField(required: true)]
|
|
public ProtoId<PlayTimeTrackerPrototype> Role;
|
|
|
|
/// <inheritdoc cref="DepartmentTimeRequirement.Time"/>
|
|
[DataField(required: true)]
|
|
public TimeSpan Time;
|
|
|
|
public override bool Check(IEntityManager entManager,
|
|
IPrototypeManager protoManager,
|
|
HumanoidCharacterProfile? profile,
|
|
IReadOnlyDictionary<string, TimeSpan> playTimes,
|
|
string? protoId, // Sunrise-Edit
|
|
string[] sponsorPrototypes, // Sunrise-Edit
|
|
[NotNullWhen(false)] out FormattedMessage? reason)
|
|
{
|
|
reason = new FormattedMessage();
|
|
|
|
// Sunrise-Sponsors-Start
|
|
if (sponsorPrototypes.Contains(protoId))
|
|
return true;
|
|
// Sunrise-Sponsors-End
|
|
|
|
string proto = Role;
|
|
|
|
playTimes.TryGetValue(proto, out var roleTime);
|
|
var roleDiffSpan = Time - roleTime;
|
|
var roleDiff = roleDiffSpan.TotalMinutes;
|
|
var formattedRoleDiff = ContentLocalizationManager.FormatPlaytime(roleDiffSpan);
|
|
var departmentColor = Color.Yellow;
|
|
|
|
if (!entManager.EntitySysManager.TryGetEntitySystem(out SharedJobSystem? jobSystem))
|
|
return false;
|
|
|
|
var jobProto = jobSystem.GetJobPrototype(proto);
|
|
|
|
if (jobSystem.TryGetDepartment(jobProto, out var departmentProto))
|
|
departmentColor = departmentProto.Color;
|
|
|
|
if (!protoManager.TryIndex<JobPrototype>(jobProto, out var indexedJob))
|
|
return false;
|
|
|
|
if (!Inverted)
|
|
{
|
|
if (roleDiff <= 0)
|
|
return true;
|
|
|
|
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
|
"role-timer-role-insufficient",
|
|
("time", formattedRoleDiff),
|
|
("job", indexedJob.LocalizedName),
|
|
("departmentColor", departmentColor.ToHex())));
|
|
return false;
|
|
}
|
|
|
|
if (roleDiff <= 0)
|
|
{
|
|
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString(
|
|
"role-timer-role-too-high",
|
|
("time", formattedRoleDiff),
|
|
("job", indexedJob.LocalizedName),
|
|
("departmentColor", departmentColor.ToHex())));
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|