mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Some coats and scrubs in loadout are branded with specific corporation logo's. This PR restricts specifically those items to the employers that they are from. Note that we have coats from other companies currently not listed as available employers too. Perhaps we should consider adding them? # Updated: This PR now also includes CCVars that can disable a part, or the entirety, of Contractors for downstreams that prefer free-form RP over gameplay. While I was at it, I made it so that AI and Borgs don't get Passports. --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - tweak: Restricted some corporate jackets and scrubs to that specific corporation. - tweak: Downstreams can now disable Contractors entirely or partially if they prefer freeform-rp over gameplay facilitating RP - tweak: Station AI and Borg are no longer people and don't get passports. (cherry picked from commit 445bdc5c1b04c9f41460fb1cc6986e736732508e)
85 lines
3.2 KiB
C#
85 lines
3.2 KiB
C#
using System.Linq;
|
|
using Content.Server.Players.PlayTimeTracking;
|
|
using Content.Shared._EE.Contractors.Prototypes;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Customization.Systems;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Players;
|
|
using Content.Shared.Preferences;
|
|
using Content.Shared.Roles;
|
|
using Robust.Shared;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.Manager;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server._EE.Contractors.Systems;
|
|
|
|
public sealed class EmployerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly ISerializationManager _serialization = default!;
|
|
[Dependency] private readonly CharacterRequirementsSystem _characterRequirements = default!;
|
|
[Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!;
|
|
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
|
[Dependency] private readonly IComponentFactory _componentFactory = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawnComplete);
|
|
}
|
|
|
|
// When the player is spawned in, add the employer components selected during character creation
|
|
private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args) =>
|
|
ApplyEmployer(args.Mob, args.JobId, args.Profile,
|
|
_playTimeTracking.GetTrackerTimes(args.Player), args.Player.ContentData()?.Whitelisted ?? false);
|
|
|
|
/// <summary>
|
|
/// Adds the employer selected by a player to an entity.
|
|
/// </summary>
|
|
public void ApplyEmployer(EntityUid uid, ProtoId<JobPrototype>? jobId, HumanoidCharacterProfile profile,
|
|
Dictionary<string, TimeSpan> playTimes, bool whitelisted)
|
|
{
|
|
if (jobId == null || !_prototype.TryIndex(jobId, out _))
|
|
return;
|
|
|
|
var jobPrototypeToUse = _prototype.Index(jobId.Value);
|
|
|
|
ProtoId<EmployerPrototype> employer = profile.Employer != string.Empty ? profile.Employer : SharedHumanoidAppearanceSystem.DefaultEmployer;
|
|
|
|
if(!_prototype.TryIndex<EmployerPrototype>(employer, out var employerPrototype))
|
|
{
|
|
DebugTools.Assert($"Employer '{employer}' not found!");
|
|
return;
|
|
}
|
|
|
|
if (!_characterRequirements.CheckRequirementsValid(
|
|
employerPrototype.Requirements,
|
|
jobPrototypeToUse,
|
|
profile, playTimes, whitelisted, employerPrototype,
|
|
EntityManager, _prototype, _configuration,
|
|
out _))
|
|
return;
|
|
|
|
AddEmployer(uid, employerPrototype);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds a single Employer Prototype to an Entity.
|
|
/// </summary>
|
|
public void AddEmployer(EntityUid uid, EmployerPrototype employerPrototype)
|
|
{
|
|
if (!_configuration.GetCVar(CCVars.ContractorsEnabled) ||
|
|
!_configuration.GetCVar(CCVars.ContractorsTraitFunctionsEnabled))
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var function in employerPrototype.Functions)
|
|
function.OnPlayerSpawn(uid, _componentFactory, EntityManager, _serialization);
|
|
}
|
|
}
|