Fixes (#593)
* - fix: Fix jobreq probably. * - fix: Felinid ling transform in containers.
This commit is contained in:
@@ -24,6 +24,7 @@ public sealed class JobRequirementsManager : ISharedPlaytimeManager
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
[Dependency] private readonly IClientAdminManager _adminManager = default!;
|
||||
|
||||
private readonly Dictionary<string, TimeSpan> _roles = new();
|
||||
private readonly List<string> _roleBans = new();
|
||||
@@ -114,8 +115,12 @@ public sealed class JobRequirementsManager : ISharedPlaytimeManager
|
||||
return true;
|
||||
|
||||
var reasons = new List<string>();
|
||||
var isAdmin = _adminManager.IsAdmin(true); // WD
|
||||
foreach (var requirement in requirements)
|
||||
{
|
||||
if (requirement.IgnoreIfAdmin && isAdmin) // WD
|
||||
continue;
|
||||
|
||||
if (requirement.Check(_entManager, _prototypes, profile, _roles, out var jobReason))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ using Content.Server.Popups;
|
||||
using Content.Server.Store.Components;
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Server.Temperature.Systems;
|
||||
using Content.Shared._White.Item.PseudoItem;
|
||||
using Content.Shared._White.Overlays;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Borer;
|
||||
@@ -1011,7 +1012,7 @@ public sealed partial class ChangelingSystem
|
||||
|
||||
if (!TryComp(polymorphEntity.Value, out FelinidComponent? felinid))
|
||||
return polymorphEntity;
|
||||
|
||||
|
||||
_action.SetCharges(felinid.HairballAction, 0);
|
||||
_action.SetEnabled(felinid.HairballAction, false);
|
||||
|
||||
@@ -1020,6 +1021,9 @@ public sealed partial class ChangelingSystem
|
||||
|
||||
private void BeforeTransform(EntityUid target)
|
||||
{
|
||||
if (TryComp(target, out PseudoItemComponent? pseudoItem) && pseudoItem.Active)
|
||||
_transform.AttachToGridOrMap(target);
|
||||
|
||||
if (TryComp(target, out BorerHostComponent? host) && host.BorerContainer.Count > 0)
|
||||
_borer.GetOut(host.BorerContainer.ContainedEntities[0]);
|
||||
|
||||
|
||||
@@ -164,16 +164,8 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
|
||||
_tracking.QueueSendTimers(ev.PlayerSession);
|
||||
}
|
||||
|
||||
private bool IsBypassingChecks(ICommonSession player)
|
||||
{
|
||||
return _adminManager.IsAdmin(player, true);
|
||||
}
|
||||
|
||||
public bool IsAllowed(ICommonSession player, string role)
|
||||
{
|
||||
if (IsBypassingChecks(player))
|
||||
return true;
|
||||
|
||||
if (!_prototypes.TryIndex<JobPrototype>(role, out var job) ||
|
||||
!_cfg.GetCVar(CCVars.GameRoleTimers))
|
||||
return true;
|
||||
@@ -184,16 +176,15 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
|
||||
playTimes = new Dictionary<string, TimeSpan>();
|
||||
}
|
||||
|
||||
return JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(player.UserId).SelectedCharacter);
|
||||
var isAdmin = _adminManager.IsAdmin(player, true); // WD
|
||||
|
||||
return JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(player.UserId).SelectedCharacter, isAdmin); // WD EDIT
|
||||
}
|
||||
|
||||
public HashSet<string> GetDisallowedJobs(ICommonSession player)
|
||||
{
|
||||
var roles = new HashSet<string>();
|
||||
|
||||
if (IsBypassingChecks(player))
|
||||
return roles;
|
||||
|
||||
if (!_cfg.GetCVar(CCVars.GameRoleTimers))
|
||||
return roles;
|
||||
|
||||
@@ -203,9 +194,11 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
|
||||
playTimes = new Dictionary<string, TimeSpan>();
|
||||
}
|
||||
|
||||
var isAdmin = _adminManager.IsAdmin(player, true); // WD
|
||||
|
||||
foreach (var job in _prototypes.EnumeratePrototypes<JobPrototype>())
|
||||
{
|
||||
if (JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(player.UserId).SelectedCharacter))
|
||||
if (JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(player.UserId).SelectedCharacter, isAdmin)) // WD EDIT
|
||||
roles.Add(job.ID);
|
||||
}
|
||||
|
||||
@@ -219,9 +212,6 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
|
||||
|
||||
var player = _playerManager.GetSessionById(userId);
|
||||
|
||||
if (IsBypassingChecks(player))
|
||||
return;
|
||||
|
||||
if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
|
||||
{
|
||||
// Sorry mate but your playtimes haven't loaded.
|
||||
@@ -229,10 +219,12 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
|
||||
playTimes ??= new Dictionary<string, TimeSpan>();
|
||||
}
|
||||
|
||||
var isAdmin = _adminManager.IsAdmin(player, true); // WD
|
||||
|
||||
for (var i = 0; i < jobs.Count; i++)
|
||||
{
|
||||
if (_prototypes.TryIndex(jobs[i], out var job)
|
||||
&& JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter))
|
||||
&& JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes, (HumanoidCharacterProfile?) _preferencesManager.GetPreferences(userId).SelectedCharacter, isAdmin)) // WD EDIT
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Content.Shared.Roles;
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class DepartmentTimeRequirement : JobRequirement
|
||||
{
|
||||
public override bool IgnoreIfAdmin => true; // WD
|
||||
|
||||
/// <summary>
|
||||
/// Which department needs the required amount of time.
|
||||
/// </summary>
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Content.Shared.Roles;
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class OverallPlaytimeRequirement : JobRequirement
|
||||
{
|
||||
public override bool IgnoreIfAdmin => true; // WD
|
||||
|
||||
/// <inheritdoc cref="DepartmentTimeRequirement.Time"/>
|
||||
[DataField(required: true)]
|
||||
public TimeSpan Time;
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Content.Shared.Roles;
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class RoleTimeRequirement : JobRequirement
|
||||
{
|
||||
public override bool IgnoreIfAdmin => true; // WD
|
||||
|
||||
/// <summary>
|
||||
/// What particular role they need the time requirement with.
|
||||
/// </summary>
|
||||
|
||||
@@ -14,7 +14,8 @@ public static class JobRequirements
|
||||
[NotNullWhen(false)] out FormattedMessage? reason,
|
||||
IEntityManager entManager,
|
||||
IPrototypeManager protoManager,
|
||||
HumanoidCharacterProfile? profile)
|
||||
HumanoidCharacterProfile? profile,
|
||||
bool isAdmin)
|
||||
{
|
||||
var sys = entManager.System<SharedRoleSystem>();
|
||||
var requirements = sys.GetJobRequirement(job);
|
||||
@@ -24,6 +25,9 @@ public static class JobRequirements
|
||||
|
||||
foreach (var requirement in requirements)
|
||||
{
|
||||
if (isAdmin && requirement.IgnoreIfAdmin)
|
||||
continue;
|
||||
|
||||
if (!requirement.Check(entManager, protoManager, profile, playTimes, out reason))
|
||||
return false;
|
||||
}
|
||||
@@ -42,6 +46,8 @@ public abstract partial class JobRequirement
|
||||
[DataField]
|
||||
public bool Inverted;
|
||||
|
||||
public virtual bool IgnoreIfAdmin => false; // WD
|
||||
|
||||
public abstract bool Check(
|
||||
IEntityManager entManager,
|
||||
IPrototypeManager protoManager,
|
||||
|
||||
Reference in New Issue
Block a user