Dewarns access (#16666)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -11,14 +11,16 @@ public sealed class AccessOverlay : Overlay
|
||||
{
|
||||
private readonly IEntityManager _entityManager;
|
||||
private readonly EntityLookupSystem _lookup;
|
||||
private readonly SharedTransformSystem _xform;
|
||||
private readonly Font _font;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
||||
|
||||
public AccessOverlay(IEntityManager entManager, IResourceCache cache, EntityLookupSystem lookup)
|
||||
public AccessOverlay(IEntityManager entManager, IResourceCache cache, EntityLookupSystem lookup, SharedTransformSystem xform)
|
||||
{
|
||||
_entityManager = entManager;
|
||||
_lookup = lookup;
|
||||
_xform = xform;
|
||||
|
||||
_font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
|
||||
}
|
||||
@@ -71,7 +73,7 @@ public sealed class AccessOverlay : Overlay
|
||||
textStr = "";
|
||||
}
|
||||
|
||||
var screenPos = args.ViewportControl.WorldToScreen(xform.WorldPosition);
|
||||
var screenPos = args.ViewportControl.WorldToScreen(_xform.GetWorldPosition(xform));
|
||||
|
||||
args.ScreenHandle.DrawString(_font, screenPos, textStr, Color.Gold);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,6 @@ using Content.Shared.Access.Systems;
|
||||
|
||||
namespace Content.Client.Access;
|
||||
|
||||
public sealed class AccessSystem : SharedAccessSystem {}
|
||||
public sealed class AccessSystem : SharedAccessSystem
|
||||
{
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ public sealed class ShowAccessReadersCommand : IConsoleCommand
|
||||
{
|
||||
var collection = IoCManager.Instance;
|
||||
|
||||
if (collection == null) return;
|
||||
if (collection == null)
|
||||
return;
|
||||
|
||||
var overlay = collection.Resolve<IOverlayManager>();
|
||||
|
||||
@@ -25,9 +26,10 @@ public sealed class ShowAccessReadersCommand : IConsoleCommand
|
||||
|
||||
var entManager = collection.Resolve<IEntityManager>();
|
||||
var cache = collection.Resolve<IResourceCache>();
|
||||
var system = entManager.EntitySysManager.GetEntitySystem<EntityLookupSystem>();
|
||||
var lookup = entManager.System<EntityLookupSystem>();
|
||||
var xform = entManager.System<SharedTransformSystem>();
|
||||
|
||||
overlay.AddOverlay(new AccessOverlay(entManager, cache, system));
|
||||
overlay.AddOverlay(new AccessOverlay(entManager, cache, lookup, xform));
|
||||
shell.WriteLine($"Set access reader debug overlay to true");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,10 @@ namespace Content.Client.Access.UI
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing) return;
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ namespace Content.Client.Access.UI
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing) return;
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_window?.Dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Content.Client.Access.UI
|
||||
public sealed partial class IdCardConsoleWindow : DefaultWindow
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
private readonly ISawmill _logMill = default!;
|
||||
|
||||
private readonly IdCardConsoleBoundUserInterface _owner;
|
||||
|
||||
@@ -30,6 +32,7 @@ namespace Content.Client.Access.UI
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
_logMill = _logManager.GetSawmill(SharedIdCardConsoleSystem.Sawmill);
|
||||
|
||||
_owner = owner;
|
||||
|
||||
@@ -67,7 +70,7 @@ namespace Content.Client.Access.UI
|
||||
{
|
||||
if (!prototypeManager.TryIndex<AccessLevelPrototype>(access, out var accessLevel))
|
||||
{
|
||||
Logger.ErrorS(SharedIdCardConsoleSystem.Sawmill, $"Unable to find accesslevel for {access}");
|
||||
_logMill.Error($"Unable to find accesslevel for {access}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.Access;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Serilog;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Access
|
||||
{
|
||||
@@ -9,6 +13,35 @@ namespace Content.IntegrationTests.Tests.Access
|
||||
[TestOf(typeof(AccessReaderComponent))]
|
||||
public sealed class AccessReaderTest
|
||||
{
|
||||
[Test]
|
||||
public async Task TestProtoTags()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient(new PoolSettings() { NoClient = true });
|
||||
var server = pair.Pair.Server;
|
||||
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
var accessName = server.ResolveDependency<IComponentFactory>().GetComponentName(typeof(AccessReaderComponent));
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
foreach (var ent in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (!ent.Components.TryGetComponent(accessName, out var access))
|
||||
continue;
|
||||
|
||||
var reader = (AccessReaderComponent) access;
|
||||
var allTags = reader.AccessLists.SelectMany(c => c).Union(reader.DenyTags);
|
||||
|
||||
foreach (var level in allTags)
|
||||
{
|
||||
Assert.That(protoManager.HasIndex<AccessLevelPrototype>(level), $"Invalid access level: {level} found on {ent}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestTags()
|
||||
{
|
||||
|
||||
@@ -2,5 +2,6 @@ namespace Content.Server.Access.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class AgentIDCardComponent : Component
|
||||
{}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,4 @@ namespace Content.Server.Access.Systems;
|
||||
|
||||
public sealed class AccessSystem : SharedAccessSystem
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Content.Server.Access.Systems
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -112,7 +113,7 @@ namespace Content.Server.Access.Systems
|
||||
if (player != null)
|
||||
{
|
||||
_adminLogger.Add(LogType.Identity, LogImpact.Low,
|
||||
$"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(id.Owner):entity} to {jobTitle} ");
|
||||
$"{ToPrettyString(player.Value):player} has changed the job title of {ToPrettyString(uid):entity} to {jobTitle} ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -149,7 +150,7 @@ namespace Content.Server.Access.Systems
|
||||
if (player != null)
|
||||
{
|
||||
_adminLogger.Add(LogType.Identity, LogImpact.Low,
|
||||
$"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(id.Owner):entity} to {fullName} ");
|
||||
$"{ToPrettyString(player.Value):player} has changed the name of {ToPrettyString(uid):entity} to {fullName} ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -174,7 +175,7 @@ namespace Content.Server.Access.Systems
|
||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
||||
("fullName", id.FullName),
|
||||
("jobSuffix", jobSuffix));
|
||||
EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName = val;
|
||||
_metaSystem.SetEntityName(uid, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@ public sealed class IdExaminableSystem : EntitySystem
|
||||
|
||||
private void OnGetExamineVerbs(EntityUid uid, IdExaminableComponent component, GetVerbsEvent<ExamineVerb> args)
|
||||
{
|
||||
|
||||
var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid);
|
||||
var info = GetInfo(component.Owner) ?? Loc.GetString("id-examinable-component-verb-no-id");
|
||||
var info = GetInfo(uid) ?? Loc.GetString("id-examinable-component-verb-no-id");
|
||||
|
||||
var verb = new ExamineVerb()
|
||||
{
|
||||
@@ -47,12 +46,13 @@ public sealed class IdExaminableSystem : EntitySystem
|
||||
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
|
||||
{
|
||||
// PDA
|
||||
if (EntityManager.TryGetComponent(idUid, out PdaComponent? pda) && pda.ContainedId is not null)
|
||||
if (EntityManager.TryGetComponent(idUid, out PdaComponent? pda) &&
|
||||
TryComp<IdCardComponent>(pda.ContainedId, out var id))
|
||||
{
|
||||
return GetNameAndJob(pda.ContainedId);
|
||||
return GetNameAndJob(id);
|
||||
}
|
||||
// ID Card
|
||||
if (EntityManager.TryGetComponent(idUid, out IdCardComponent? id))
|
||||
if (EntityManager.TryGetComponent(idUid, out id))
|
||||
{
|
||||
return GetNameAndJob(id);
|
||||
}
|
||||
|
||||
@@ -26,15 +26,16 @@ namespace Content.Server.Access.Systems
|
||||
{
|
||||
// Go over all ID cards and make sure they're correctly configured for extended access.
|
||||
|
||||
foreach (var card in EntityQuery<PresetIdCardComponent>())
|
||||
var query = EntityQueryEnumerator<PresetIdCardComponent>();
|
||||
while (query.MoveNext(out var uid, out var card))
|
||||
{
|
||||
var station = _stationSystem.GetOwningStation(card.Owner);
|
||||
var station = _stationSystem.GetOwningStation(uid);
|
||||
|
||||
// If we're not on an extended access station, the ID is already configured correctly from MapInit.
|
||||
if (station == null || !Comp<StationJobsComponent>(station.Value).ExtendedAccess)
|
||||
return;
|
||||
|
||||
SetupIdAccess(card.Owner, card, true);
|
||||
SetupIdAccess(uid, card, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ namespace Content.Server.Access.Systems
|
||||
// or may not yet know whether it is on extended access (players not spawned yet).
|
||||
// PlayerJobsAssigned makes sure extended access is configured correctly in that case.
|
||||
|
||||
var station = _stationSystem.GetOwningStation(id.Owner);
|
||||
var station = _stationSystem.GetOwningStation(uid);
|
||||
var extended = false;
|
||||
if (station != null)
|
||||
extended = Comp<StationJobsComponent>(station.Value).ExtendedAccess;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Administration.UI;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Inventory;
|
||||
@@ -16,7 +17,7 @@ using Robust.Shared.Prototypes;
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
sealed class SetOutfitCommand : IConsoleCommand
|
||||
public sealed class SetOutfitCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
@@ -106,9 +107,9 @@ namespace Content.Server.Administration.Commands
|
||||
var equipmentEntity = entityManager.SpawnEntity(gearStr, entityManager.GetComponent<TransformComponent>(target).Coordinates);
|
||||
if (slot.Name == "id" &&
|
||||
entityManager.TryGetComponent<PdaComponent?>(equipmentEntity, out var pdaComponent) &&
|
||||
pdaComponent.ContainedId != null)
|
||||
entityManager.TryGetComponent<IdCardComponent>(pdaComponent.ContainedId, out var id))
|
||||
{
|
||||
pdaComponent.ContainedId.FullName = entityManager.GetComponent<MetaDataComponent>(target).EntityName;
|
||||
id.FullName = entityManager.GetComponent<MetaDataComponent>(target).EntityName;
|
||||
}
|
||||
|
||||
invSystem.TryEquip(target, equipmentEntity, slot.Name, silent: true, force: true, inventory: inventoryComponent);
|
||||
|
||||
@@ -10,6 +10,7 @@ using Content.Server.Damage.Components;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.Hands.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
@@ -49,6 +50,9 @@ public sealed partial class AdminVerbSystem
|
||||
[Dependency] private readonly AdminTestArenaSystem _adminTestArenaSystem = default!;
|
||||
[Dependency] private readonly StationJobsSystem _stationJobsSystem = default!;
|
||||
[Dependency] private readonly JointSystem _jointSystem = default!;
|
||||
[Dependency] private readonly BatterySystem _batterySystem = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
|
||||
private void AddTricksVerbs(GetVerbsEvent<Verb> args)
|
||||
{
|
||||
@@ -80,7 +84,6 @@ public sealed partial class AdminVerbSystem
|
||||
? "admin-trick-unbolt-description"
|
||||
: "admin-trick-bolt-description"),
|
||||
Priority = (int) (bolts.BoltsDown ? TricksVerbPriorities.Unbolt : TricksVerbPriorities.Bolt),
|
||||
|
||||
};
|
||||
args.Verbs.Add(bolt);
|
||||
}
|
||||
@@ -100,9 +103,7 @@ public sealed partial class AdminVerbSystem
|
||||
Message = Loc.GetString(airlock.EmergencyAccess
|
||||
? "admin-trick-emergency-access-off-description"
|
||||
: "admin-trick-emergency-access-on-description"),
|
||||
Priority = (int) (airlock.EmergencyAccess
|
||||
? TricksVerbPriorities.EmergencyAccessOff
|
||||
: TricksVerbPriorities.EmergencyAccessOn),
|
||||
Priority = (int) (airlock.EmergencyAccess ? TricksVerbPriorities.EmergencyAccessOff : TricksVerbPriorities.EmergencyAccessOn),
|
||||
};
|
||||
args.Verbs.Add(emergencyAccess);
|
||||
}
|
||||
@@ -169,8 +170,8 @@ public sealed partial class AdminVerbSystem
|
||||
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/AdminActions/fill_battery.png")),
|
||||
Act = () =>
|
||||
{
|
||||
battery.CurrentCharge = battery.MaxCharge;
|
||||
Dirty(battery);
|
||||
_batterySystem.SetCharge(args.Target, battery.MaxCharge, battery);
|
||||
Dirty(args.Target, battery);
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
Message = Loc.GetString("admin-trick-refill-battery-description"),
|
||||
@@ -185,8 +186,8 @@ public sealed partial class AdminVerbSystem
|
||||
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/AdminActions/drain_battery.png")),
|
||||
Act = () =>
|
||||
{
|
||||
battery.CurrentCharge = 0;
|
||||
Dirty(battery);
|
||||
_batterySystem.SetCharge(args.Target, 0, battery);
|
||||
Dirty(args.Target, battery);
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
Message = Loc.GetString("admin-trick-drain-battery-description"),
|
||||
@@ -386,7 +387,7 @@ public sealed partial class AdminVerbSystem
|
||||
Act = () =>
|
||||
{
|
||||
var (mapUid, gridUid) = _adminTestArenaSystem.AssertArenaLoaded(player);
|
||||
Transform(args.Target).Coordinates = new EntityCoordinates(gridUid ?? mapUid, Vector2.One);
|
||||
_xformSystem.SetCoordinates(args.Target, new EntityCoordinates(gridUid ?? mapUid, Vector2.One));
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
Message = Loc.GetString("admin-trick-send-to-test-arena-description"),
|
||||
@@ -509,7 +510,7 @@ public sealed partial class AdminVerbSystem
|
||||
{
|
||||
_quickDialog.OpenDialog(player, "Rename", "Name", (string newName) =>
|
||||
{
|
||||
MetaData(args.Target).EntityName = newName;
|
||||
_metaSystem.SetEntityName(args.Target, newName);
|
||||
});
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
@@ -527,7 +528,7 @@ public sealed partial class AdminVerbSystem
|
||||
{
|
||||
_quickDialog.OpenDialog(player, "Redescribe", "Description", (LongString newDescription) =>
|
||||
{
|
||||
MetaData(args.Target).EntityDescription = newDescription.String;
|
||||
_metaSystem.SetEntityDescription(args.Target, newDescription.String);
|
||||
});
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
@@ -547,8 +548,8 @@ public sealed partial class AdminVerbSystem
|
||||
(string newName, LongString newDescription) =>
|
||||
{
|
||||
var meta = MetaData(args.Target);
|
||||
meta.EntityName = newName;
|
||||
meta.EntityDescription = newDescription.String;
|
||||
_metaSystem.SetEntityName(args.Target, newName, meta);
|
||||
_metaSystem.SetEntityDescription(args.Target, newDescription.String, meta);
|
||||
});
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
@@ -592,7 +593,7 @@ public sealed partial class AdminVerbSystem
|
||||
if (shuttle is null)
|
||||
return;
|
||||
|
||||
Transform(args.User).Coordinates = new EntityCoordinates(shuttle.Value, Vector2.Zero);
|
||||
_xformSystem.SetCoordinates(args.User, new EntityCoordinates(shuttle.Value, Vector2.Zero));
|
||||
},
|
||||
Impact = LogImpact.Low,
|
||||
Message = Loc.GetString("admin-trick-locate-cargo-shuttle-description"),
|
||||
@@ -615,8 +616,8 @@ public sealed partial class AdminVerbSystem
|
||||
if (!HasComp<StationInfiniteBatteryTargetComponent>(ent))
|
||||
continue;
|
||||
var battery = EnsureComp<BatteryComponent>(ent);
|
||||
battery.CurrentCharge = battery.MaxCharge;
|
||||
Dirty(battery);
|
||||
_batterySystem.SetCharge(ent, battery.MaxCharge, battery);
|
||||
Dirty(ent, battery);
|
||||
}
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
@@ -637,8 +638,8 @@ public sealed partial class AdminVerbSystem
|
||||
if (!HasComp<StationInfiniteBatteryTargetComponent>(ent))
|
||||
continue;
|
||||
var battery = EnsureComp<BatteryComponent>(ent);
|
||||
battery.CurrentCharge = 0;
|
||||
Dirty(battery);
|
||||
_batterySystem.SetCharge(ent, 0, battery);
|
||||
Dirty(ent, battery);
|
||||
}
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
@@ -743,7 +744,7 @@ public sealed partial class AdminVerbSystem
|
||||
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/AdminActions/snap_joints.png")),
|
||||
Act = () =>
|
||||
{
|
||||
_jointSystem.ClearJoints(joints);
|
||||
_jointSystem.ClearJoints(args.Target, joints);
|
||||
},
|
||||
Impact = LogImpact.Medium,
|
||||
Message = Loc.GetString("admin-trick-snap-joints-description"),
|
||||
@@ -858,12 +859,10 @@ public sealed partial class AdminVerbSystem
|
||||
{
|
||||
return slotEntity.Value;
|
||||
}
|
||||
else if (TryComp<PdaComponent>(slotEntity, out var pda))
|
||||
else if (TryComp<PdaComponent>(slotEntity, out var pda)
|
||||
&& HasComp<IdCardComponent>(pda.ContainedId))
|
||||
{
|
||||
if (pda.ContainedId != null)
|
||||
{
|
||||
return pda.ContainedId.Owner;
|
||||
}
|
||||
return pda.ContainedId;
|
||||
}
|
||||
}
|
||||
else if (TryComp<HandsComponent>(target, out var hands))
|
||||
@@ -891,40 +890,40 @@ public sealed partial class AdminVerbSystem
|
||||
|
||||
private void RevokeAllAccess(EntityUid entity)
|
||||
{
|
||||
_accessSystem.TrySetTags(entity, new string[]{});
|
||||
_accessSystem.TrySetTags(entity, Array.Empty<string>());
|
||||
}
|
||||
|
||||
public enum TricksVerbPriorities
|
||||
{
|
||||
Bolt = 0,
|
||||
Unbolt = 0,
|
||||
EmergencyAccessOn = -1, // These are separate intentionally for `invokeverb` shenanigans.
|
||||
EmergencyAccessOff = -1,
|
||||
MakeIndestructible = -2,
|
||||
MakeVulnerable = -2,
|
||||
BlockUnanchoring = -3,
|
||||
RefillBattery = -4,
|
||||
DrainBattery = -5,
|
||||
RefillOxygen = -6,
|
||||
RefillNitrogen = -7,
|
||||
RefillPlasma = -8,
|
||||
SendToTestArena = -9,
|
||||
GrantAllAccess = -10,
|
||||
RevokeAllAccess = -11,
|
||||
Rejuvenate = -12,
|
||||
AdjustStack = -13,
|
||||
FillStack = -14,
|
||||
Rename = -15,
|
||||
Redescribe = -16,
|
||||
RenameAndRedescribe = -17,
|
||||
BarJobSlots = -18,
|
||||
LocateCargoShuttle = -19,
|
||||
InfiniteBattery = -20,
|
||||
HaltMovement = -21,
|
||||
Unpause = -22,
|
||||
Pause = -23,
|
||||
SnapJoints = -24,
|
||||
MakeMinigun = -25,
|
||||
SetBulletAmount = -26,
|
||||
Unbolt = -1,
|
||||
EmergencyAccessOn = -2,
|
||||
EmergencyAccessOff = -3,
|
||||
MakeIndestructible = -4,
|
||||
MakeVulnerable = -5,
|
||||
BlockUnanchoring = -6,
|
||||
RefillBattery = -7,
|
||||
DrainBattery = -8,
|
||||
RefillOxygen = -9,
|
||||
RefillNitrogen = -10,
|
||||
RefillPlasma = -11,
|
||||
SendToTestArena = -12,
|
||||
GrantAllAccess = -13,
|
||||
RevokeAllAccess = -14,
|
||||
Rejuvenate = -15,
|
||||
AdjustStack = -16,
|
||||
FillStack = -17,
|
||||
Rename = -18,
|
||||
Redescribe = -19,
|
||||
RenameAndRedescribe = -20,
|
||||
BarJobSlots = -21,
|
||||
LocateCargoShuttle = -22,
|
||||
InfiniteBattery = -23,
|
||||
HaltMovement = -24,
|
||||
Unpause = -25,
|
||||
Pause = -26,
|
||||
SnapJoints = -27,
|
||||
MakeMinigun = -28,
|
||||
SetBulletAmount = -29,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Server.PDA.Ringer;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server.Store.Components;
|
||||
using Content.Server.Store.Systems;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
@@ -117,14 +118,15 @@ namespace Content.Server.PDA
|
||||
// TODO: Update the level and name of the station with each call to UpdatePdaUi is only needed for latejoin players.
|
||||
// TODO: If someone can implement changing the level and name of the station when changing the PDA grid, this can be removed.
|
||||
|
||||
var id = CompOrNull<IdCardComponent>(pda.ContainedId);
|
||||
var state = new PdaUpdateState(
|
||||
pda.FlashlightOn,
|
||||
pda.PenSlot.HasItem,
|
||||
new PdaIdInfoText
|
||||
{
|
||||
ActualOwnerName = pda.OwnerName,
|
||||
IdOwner = pda.ContainedId?.FullName,
|
||||
JobTitle = pda.ContainedId?.JobTitle,
|
||||
IdOwner = id?.FullName,
|
||||
JobTitle = id?.JobTitle,
|
||||
StationAlertLevel = pda.StationAlertLevel,
|
||||
StationAlertColor = pda.StationAlertColor
|
||||
},
|
||||
|
||||
@@ -130,17 +130,17 @@ namespace Content.Server.Sandbox
|
||||
}
|
||||
else if (TryComp<PdaComponent>(slotEntity, out var pda))
|
||||
{
|
||||
if (pda.ContainedId == null)
|
||||
if (pda.ContainedId is null)
|
||||
{
|
||||
var newID = CreateFreshId();
|
||||
if (TryComp<ItemSlotsComponent>(pda.Owner, out var itemSlots))
|
||||
if (TryComp<ItemSlotsComponent>(slotEntity, out var itemSlots))
|
||||
{
|
||||
_slots.TryInsert(slotEntity.Value, pda.IdSlot, newID, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpgradeId(pda.ContainedId.Owner);
|
||||
UpgradeId(pda.ContainedId!.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Server.Mind.Commands;
|
||||
using Content.Server.PDA;
|
||||
using Content.Server.Roles;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Hands.Components;
|
||||
@@ -44,6 +45,7 @@ public sealed class StationSpawningSystem : EntitySystem
|
||||
[Dependency] private readonly PdaSystem _pdaSystem = default!;
|
||||
[Dependency] private readonly SharedAccessSystem _accessSystem = default!;
|
||||
[Dependency] private readonly IdentitySystem _identity = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
|
||||
private bool _randomizeCharacters;
|
||||
|
||||
@@ -146,7 +148,7 @@ public sealed class StationSpawningSystem : EntitySystem
|
||||
if (profile != null)
|
||||
{
|
||||
_humanoidSystem.LoadProfile(entity.Value, profile);
|
||||
MetaData(entity.Value).EntityName = profile.Name;
|
||||
_metaSystem.SetEntityName(entity.Value, profile.Name);
|
||||
if (profile.FlavorText != "" && _configurationManager.GetCVar(CCVars.FlavorText))
|
||||
{
|
||||
AddComp<DetailExaminableComponent>(entity.Value).Content = profile.FlavorText;
|
||||
@@ -158,7 +160,7 @@ public sealed class StationSpawningSystem : EntitySystem
|
||||
return entity.Value;
|
||||
}
|
||||
|
||||
private void DoJobSpecials(Job? job, EntityUid entity)
|
||||
private static void DoJobSpecials(Job? job, EntityUid entity)
|
||||
{
|
||||
foreach (var jobSpecial in job?.Prototype.Special ?? Array.Empty<JobSpecial>())
|
||||
{
|
||||
@@ -211,11 +213,10 @@ public sealed class StationSpawningSystem : EntitySystem
|
||||
if (!_inventorySystem.TryGetSlotEntity(entity, "id", out var idUid))
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(idUid, out PdaComponent? pdaComponent) || pdaComponent.ContainedId == null)
|
||||
if (!EntityManager.TryGetComponent(idUid, out PdaComponent? pdaComponent) || !TryComp<IdCardComponent>(pdaComponent.ContainedId, out var card))
|
||||
return;
|
||||
|
||||
var card = pdaComponent.ContainedId;
|
||||
var cardId = card.Owner;
|
||||
var cardId = pdaComponent.ContainedId.Value;
|
||||
_cardSystem.TryChangeFullName(cardId, characterName, card);
|
||||
_cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, card);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public sealed class StationRecordsSystem : EntitySystem
|
||||
string? jobId, StationRecordsComponent? records = null)
|
||||
{
|
||||
if (!Resolve(station, ref records)
|
||||
|| String.IsNullOrEmpty(jobId)
|
||||
|| string.IsNullOrEmpty(jobId)
|
||||
|| !_prototypeManager.HasIndex<JobPrototype>(jobId))
|
||||
{
|
||||
return;
|
||||
@@ -204,7 +204,7 @@ public sealed class StationRecordsSystem : EntitySystem
|
||||
{
|
||||
if (!Resolve(station, ref records))
|
||||
{
|
||||
return new (StationRecordKey, T)[]{};
|
||||
return Array.Empty<(StationRecordKey, T)>();
|
||||
}
|
||||
|
||||
return records.Records.GetRecordsOfType<T>();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Server.Verbs.Commands
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var verbSystem = EntitySystem.Get<SharedVerbSystem>();
|
||||
var verbSystem = entityManager.System<SharedVerbSystem>();
|
||||
|
||||
// get the 'player' entity (defaulting to command user, otherwise uses a uid)
|
||||
EntityUid? playerEntity = null;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.StationRecords;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -59,4 +58,3 @@ public sealed class AccessReaderComponentState : ComponentState
|
||||
AccessKeys = accessKeys;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Access.Components
|
||||
{
|
||||
@@ -17,8 +16,7 @@ namespace Content.Shared.Access.Components
|
||||
|
||||
[DataField("jobTitle")]
|
||||
[AutoNetworkedField]
|
||||
[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem),
|
||||
Other = AccessPermissions.ReadWrite)]
|
||||
[Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)]
|
||||
public string? JobTitle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Content.Shared.Access.Systems
|
||||
public sealed class AgentIDCardJobChangedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Job { get; }
|
||||
|
||||
public AgentIDCardJobChangedMessage(string job)
|
||||
{
|
||||
Job = job;
|
||||
|
||||
@@ -11,18 +11,17 @@ using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.StationRecords;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Access.Systems
|
||||
{
|
||||
namespace Content.Shared.Access.Systems;
|
||||
|
||||
public sealed class AccessReaderSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<AccessReaderComponent, ComponentInit>(OnInit);
|
||||
|
||||
SubscribeLocalEvent<AccessReaderComponent, GotEmaggedEvent>(OnEmagged);
|
||||
SubscribeLocalEvent<AccessReaderComponent, LinkAttemptEvent>(OnLinkAttempt);
|
||||
|
||||
@@ -54,18 +53,6 @@ namespace Content.Shared.Access.Systems
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, AccessReaderComponent reader, ComponentInit args)
|
||||
{
|
||||
var allTags = reader.AccessLists.SelectMany(c => c).Union(reader.DenyTags);
|
||||
foreach (var level in allTags)
|
||||
{
|
||||
if (!_prototypeManager.HasIndex<AccessLevelPrototype>(level))
|
||||
{
|
||||
Logger.ErrorS("access", $"Invalid access level: {level}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, AccessReaderComponent reader, ref GotEmaggedEvent args)
|
||||
{
|
||||
args.Handled = true;
|
||||
@@ -257,7 +244,7 @@ namespace Content.Shared.Access.Systems
|
||||
}
|
||||
|
||||
if (TryComp(uid, out PdaComponent? pda) &&
|
||||
pda.ContainedId?.Owner is {Valid: true} id)
|
||||
pda.ContainedId is { Valid: true } id)
|
||||
{
|
||||
tags = EntityManager.GetComponent<AccessComponent>(id).Tags;
|
||||
return true;
|
||||
@@ -280,7 +267,7 @@ namespace Content.Shared.Access.Systems
|
||||
}
|
||||
|
||||
if (TryComp<PdaComponent>(uid, out var pda) &&
|
||||
pda.ContainedId?.Owner is {Valid: true} id)
|
||||
pda.ContainedId is { Valid: true } id)
|
||||
{
|
||||
if (TryComp<StationRecordKeyStorageComponent>(id, out var pdastorage) && pdastorage.Key != null)
|
||||
{
|
||||
@@ -293,4 +280,3 @@ namespace Content.Shared.Access.Systems
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
public bool TryFindIdCard(EntityUid uid, [NotNullWhen(true)] out IdCardComponent? idCard)
|
||||
{
|
||||
// check held item?
|
||||
if (EntityManager.TryGetComponent(uid, out HandsComponent? hands) &&
|
||||
if (TryComp(uid, out HandsComponent? hands) &&
|
||||
hands.ActiveHandEntity is EntityUid heldItem &&
|
||||
TryGetIdCard(heldItem, out idCard))
|
||||
{
|
||||
@@ -30,9 +30,7 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
|
||||
// check inventory slot?
|
||||
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid) && TryGetIdCard(idUid.Value, out idCard))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -43,12 +41,12 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
/// </summary>
|
||||
public bool TryGetIdCard(EntityUid uid, [NotNullWhen(true)] out IdCardComponent? idCard)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(uid, out idCard))
|
||||
if (TryComp(uid, out idCard))
|
||||
return true;
|
||||
|
||||
if (EntityManager.TryGetComponent(uid, out PdaComponent? pda) && pda.ContainedId != null)
|
||||
if (TryComp(uid, out PdaComponent? pda)
|
||||
&& TryComp(pda.ContainedId, out idCard))
|
||||
{
|
||||
idCard = pda.ContainedId;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Shared.PDA
|
||||
[DataField("id", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? IdCard;
|
||||
|
||||
[ViewVariables] public IdCardComponent? ContainedId;
|
||||
[ViewVariables] public EntityUid? ContainedId;
|
||||
[ViewVariables] public bool FlashlightOn;
|
||||
|
||||
[ViewVariables] public string? OwnerName;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Content.Shared.PDA
|
||||
protected virtual void OnItemInserted(EntityUid uid, PdaComponent pda, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (args.Container.ID == PdaComponent.PdaIdSlotId)
|
||||
pda.ContainedId = CompOrNull<IdCardComponent>(args.Entity);
|
||||
pda.ContainedId = args.Entity;
|
||||
|
||||
UpdatePdaAppearance(uid, pda);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user