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