@@ -42,9 +42,6 @@ public sealed partial class BorgSystem
|
||||
{
|
||||
var chassis = args.Container.Owner;
|
||||
|
||||
if (Terminating(chassis))
|
||||
return;
|
||||
|
||||
if (!TryComp<BorgChassisComponent>(chassis, out var chassisComp) ||
|
||||
args.Container != chassisComp.ModuleContainer)
|
||||
return;
|
||||
@@ -232,7 +229,11 @@ public sealed partial class BorgSystem
|
||||
return false;
|
||||
|
||||
if (component.ModuleContainer.ContainedEntities.Count >= component.MaxModules)
|
||||
{
|
||||
if (user != null)
|
||||
Popup.PopupEntity(Loc.GetString("borg-module-too-many"), uid, user.Value);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (component.ModuleWhitelist?.IsValid(module, EntityManager) == false)
|
||||
{
|
||||
|
||||
@@ -69,8 +69,14 @@ public sealed partial class BorgSystem
|
||||
if (TryComp<NameIdentifierComponent>(uid, out var identifier))
|
||||
name = $"{name} {identifier.FullIdentifier}";
|
||||
|
||||
_metaData.SetEntityName(uid, name);
|
||||
var metaData = MetaData(uid);
|
||||
|
||||
// don't change the name if the value doesn't actually change
|
||||
if (metaData.EntityName.Equals(name, StringComparison.InvariantCulture))
|
||||
return;
|
||||
|
||||
_adminLog.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(attachedEntity):player} set borg \"{ToPrettyString(uid)}\"'s name to: {name}");
|
||||
_metaData.SetEntityName(uid, name, metaData);
|
||||
}
|
||||
|
||||
private void OnRemoveModuleBuiMessage(EntityUid uid, BorgChassisComponent component, BorgRemoveModuleBuiMessage args)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
@@ -12,6 +15,7 @@ using Content.Shared.Silicons.Laws.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Toolshed;
|
||||
|
||||
namespace Content.Server.Silicons.Laws;
|
||||
|
||||
@@ -34,12 +38,12 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
SubscribeLocalEvent<SiliconLawBoundComponent, MindAddedMessage>(OnMindAdded);
|
||||
SubscribeLocalEvent<SiliconLawBoundComponent, ToggleLawsScreenEvent>(OnToggleLawsScreen);
|
||||
SubscribeLocalEvent<SiliconLawBoundComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
|
||||
SubscribeLocalEvent<SiliconLawBoundComponent, PlayerSpawnCompleteEvent>(OnPlayerSpawnComplete);
|
||||
|
||||
SubscribeLocalEvent<SiliconLawProviderComponent, GetSiliconLawsEvent>(OnDirectedGetLaws);
|
||||
SubscribeLocalEvent<EmagSiliconLawComponent, GetSiliconLawsEvent>(OnDirectedEmagGetLaws);
|
||||
SubscribeLocalEvent<EmagSiliconLawComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private void OnComponentStartup(EntityUid uid, SiliconLawBoundComponent component, ComponentStartup args)
|
||||
{
|
||||
component.ProvidedAction = new (_prototype.Index<InstantActionPrototype>(component.ViewLawsAction));
|
||||
@@ -78,6 +82,11 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
_userInterface.TrySetUiState(args.Entity, SiliconLawsUiKey.Key, state, (IPlayerSession) args.Session);
|
||||
}
|
||||
|
||||
private void OnPlayerSpawnComplete(EntityUid uid, SiliconLawBoundComponent component, PlayerSpawnCompleteEvent args)
|
||||
{
|
||||
component.LastLawProvider = args.Station;
|
||||
}
|
||||
|
||||
private void OnDirectedGetLaws(EntityUid uid, SiliconLawProviderComponent component, ref GetSiliconLawsEvent args)
|
||||
{
|
||||
if (args.Handled || HasComp<EmaggedComponent>(uid) || component.Laws.Count == 0)
|
||||
@@ -117,28 +126,55 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
NotifyLawsChanged(uid);
|
||||
}
|
||||
|
||||
public List<SiliconLaw> GetLaws(EntityUid uid)
|
||||
public List<SiliconLaw> GetLaws(EntityUid uid, SiliconLawBoundComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return new List<SiliconLaw>();
|
||||
|
||||
var xform = Transform(uid);
|
||||
|
||||
var ev = new GetSiliconLawsEvent(uid);
|
||||
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
if (ev.Handled)
|
||||
{
|
||||
component.LastLawProvider = uid;
|
||||
return ev.Laws;
|
||||
}
|
||||
|
||||
if (_station.GetOwningStation(uid, xform) is { } station)
|
||||
{
|
||||
RaiseLocalEvent(station, ref ev);
|
||||
if (ev.Handled)
|
||||
{
|
||||
component.LastLawProvider = station;
|
||||
return ev.Laws;
|
||||
}
|
||||
}
|
||||
|
||||
if (xform.GridUid is { } grid)
|
||||
{
|
||||
RaiseLocalEvent(grid, ref ev);
|
||||
if (ev.Handled)
|
||||
{
|
||||
component.LastLawProvider = grid;
|
||||
return ev.Laws;
|
||||
}
|
||||
}
|
||||
|
||||
if (component.LastLawProvider == null ||
|
||||
Deleted(component.LastLawProvider) ||
|
||||
Terminating(component.LastLawProvider.Value))
|
||||
{
|
||||
component.LastLawProvider = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
RaiseLocalEvent(component.LastLawProvider.Value, ref ev);
|
||||
if (ev.Handled)
|
||||
{
|
||||
return ev.Laws;
|
||||
}
|
||||
}
|
||||
|
||||
RaiseLocalEvent(ref ev);
|
||||
@@ -155,3 +191,30 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
_chatManager.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.ConnectedClient, colorOverride: Color.FromHex("#2ed2fd"));
|
||||
}
|
||||
}
|
||||
|
||||
[ToolshedCommand, AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class LawsCommand : ToolshedCommand
|
||||
{
|
||||
private SiliconLawSystem? _law;
|
||||
|
||||
[CommandImplementation("list")]
|
||||
public IEnumerable<EntityUid> List()
|
||||
{
|
||||
var query = EntityManager.EntityQueryEnumerator<SiliconLawBoundComponent>();
|
||||
while (query.MoveNext(out var uid, out _))
|
||||
{
|
||||
yield return uid;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandImplementation("get")]
|
||||
public IEnumerable<string> Get([PipedArgument] EntityUid lawbound)
|
||||
{
|
||||
_law ??= GetSys<SiliconLawSystem>();
|
||||
|
||||
foreach (var law in _law.GetLaws(lawbound))
|
||||
{
|
||||
yield return $"law {law.LawIdentifierOverride ?? law.Order.ToString()}: {Loc.GetString(law.LawString)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
SubscribeLocalEvent<WiresComponent, PowerChangedEvent>(OnWiresPowered);
|
||||
SubscribeLocalEvent<WiresComponent, WireDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
|
||||
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(OnActivatableUIPanelChanged);
|
||||
}
|
||||
|
||||
private void SetOrCreateWireLayout(EntityUid uid, WiresComponent? wires = null)
|
||||
@@ -505,6 +506,17 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnActivatableUIPanelChanged(EntityUid uid, ActivatableUIRequiresPanelComponent component, ref PanelChangedEvent args)
|
||||
{
|
||||
if (args.Open == component.RequireOpen)
|
||||
return;
|
||||
|
||||
if (!TryComp<ActivatableUIComponent>(uid, out var ui) || ui.Key == null)
|
||||
return;
|
||||
|
||||
_uiSystem.TryCloseAll(uid, ui.Key);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, WiresComponent component, MapInitEvent args)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(component.LayoutId))
|
||||
@@ -641,6 +653,9 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
component.Open = open;
|
||||
UpdateAppearance(uid, component);
|
||||
Dirty(component);
|
||||
|
||||
var ev = new PanelChangedEvent(component.Open);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
}
|
||||
|
||||
public void SetWiresPanelSecurityData(EntityUid uid, WiresPanelComponent component, string wiresPanelSecurityLevelID)
|
||||
|
||||
Reference in New Issue
Block a user