Compare commits
1 Commits
LocalHelpe
...
ed-18-10-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
237716b353 |
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -19,7 +19,7 @@
|
||||
/Resources/engineCommandPerms.yml @moonheart08 @Chief-Engineer
|
||||
/Resources/clientCommandPerms.yml @moonheart08 @Chief-Engineer
|
||||
|
||||
/Resources/Prototypes/Maps/** @Emisse
|
||||
/Resources/Prototypes/Maps/ @Emisse
|
||||
|
||||
/Resources/Prototypes/Body/ @DrSmugleaf # suffering
|
||||
/Resources/Prototypes/Entities/Mobs/Player/ @DrSmugleaf
|
||||
|
||||
@@ -23,7 +23,6 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
{
|
||||
private readonly IEntityManager _entManager;
|
||||
private readonly SpriteSystem _spriteSystem;
|
||||
private readonly SharedNavMapSystem _navMapSystem;
|
||||
|
||||
private EntityUid? _owner;
|
||||
private NetEntity? _trackedEntity;
|
||||
@@ -43,32 +42,19 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
|
||||
private const float SilencingDuration = 2.5f;
|
||||
|
||||
// Colors
|
||||
private Color _wallColor = new Color(64, 64, 64);
|
||||
private Color _tileColor = new Color(28, 28, 28);
|
||||
private Color _monitorBlipColor = Color.Cyan;
|
||||
private Color _untrackedEntColor = Color.DimGray;
|
||||
private Color _regionBaseColor = new Color(154, 154, 154);
|
||||
private Color _inactiveColor = StyleNano.DisabledFore;
|
||||
private Color _statusTextColor = StyleNano.GoodGreenFore;
|
||||
private Color _goodColor = Color.LimeGreen;
|
||||
private Color _warningColor = new Color(255, 182, 72);
|
||||
private Color _dangerColor = new Color(255, 67, 67);
|
||||
|
||||
public AtmosAlertsComputerWindow(AtmosAlertsComputerBoundUserInterface userInterface, EntityUid? owner)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_entManager = IoCManager.Resolve<IEntityManager>();
|
||||
_spriteSystem = _entManager.System<SpriteSystem>();
|
||||
_navMapSystem = _entManager.System<SharedNavMapSystem>();
|
||||
|
||||
// Pass the owner to nav map
|
||||
_owner = owner;
|
||||
NavMap.Owner = _owner;
|
||||
|
||||
// Set nav map colors
|
||||
NavMap.WallColor = _wallColor;
|
||||
NavMap.TileColor = _tileColor;
|
||||
NavMap.WallColor = new Color(64, 64, 64);
|
||||
NavMap.TileColor = Color.DimGray * NavMap.WallColor;
|
||||
|
||||
// Set nav map grid uid
|
||||
var stationName = Loc.GetString("atmos-alerts-window-unknown-location");
|
||||
@@ -193,9 +179,6 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
// Add tracked entities to the nav map
|
||||
foreach (var device in console.AtmosDevices)
|
||||
{
|
||||
if (!device.NetEntity.Valid)
|
||||
continue;
|
||||
|
||||
if (!NavMap.Visible)
|
||||
continue;
|
||||
|
||||
@@ -226,7 +209,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
if (consoleCoords != null && consoleUid != null)
|
||||
{
|
||||
var texture = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png")));
|
||||
var blip = new NavMapBlip(consoleCoords.Value, texture, _monitorBlipColor, true, false);
|
||||
var blip = new NavMapBlip(consoleCoords.Value, texture, Color.Cyan, true, false);
|
||||
NavMap.TrackedEntities[consoleUid.Value] = blip;
|
||||
}
|
||||
|
||||
@@ -275,7 +258,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
};
|
||||
|
||||
label.SetMarkup(Loc.GetString("atmos-alerts-window-no-active-alerts", ("color", _statusTextColor.ToHexNoAlpha())));
|
||||
label.SetMarkup(Loc.GetString("atmos-alerts-window-no-active-alerts", ("color", StyleNano.GoodGreenFore.ToHexNoAlpha())));
|
||||
|
||||
AlertsTable.AddChild(label);
|
||||
}
|
||||
@@ -287,34 +270,6 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
else
|
||||
MasterTabContainer.SetTabTitle(0, Loc.GetString("atmos-alerts-window-tab-alerts", ("value", activeAlarmCount)));
|
||||
|
||||
// Update sensor regions
|
||||
NavMap.RegionOverlays.Clear();
|
||||
var prioritizedRegionOverlays = new Dictionary<NavMapRegionOverlay, int>();
|
||||
|
||||
if (_owner != null &&
|
||||
_entManager.TryGetComponent<TransformComponent>(_owner, out var xform) &&
|
||||
_entManager.TryGetComponent<NavMapComponent>(xform.GridUid, out var navMap))
|
||||
{
|
||||
var regionOverlays = _navMapSystem.GetNavMapRegionOverlays(_owner.Value, navMap, AtmosAlertsComputerUiKey.Key);
|
||||
|
||||
foreach (var (regionOwner, regionOverlay) in regionOverlays)
|
||||
{
|
||||
var alarmState = GetAlarmState(regionOwner);
|
||||
|
||||
if (!TryGetSensorRegionColor(regionOwner, alarmState, out var regionColor))
|
||||
continue;
|
||||
|
||||
regionOverlay.Color = regionColor;
|
||||
|
||||
var priority = (_trackedEntity == regionOwner) ? 999 : (int)alarmState;
|
||||
prioritizedRegionOverlays.Add(regionOverlay, priority);
|
||||
}
|
||||
|
||||
// Sort overlays according to their priority
|
||||
var sortedOverlays = prioritizedRegionOverlays.OrderBy(x => x.Value).Select(x => x.Key).ToList();
|
||||
NavMap.RegionOverlays = sortedOverlays;
|
||||
}
|
||||
|
||||
// Auto-scroll re-enable
|
||||
if (_autoScrollAwaitsUpdate)
|
||||
{
|
||||
@@ -335,7 +290,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
var coords = _entManager.GetCoordinates(metaData.NetCoordinates);
|
||||
|
||||
if (_trackedEntity != null && _trackedEntity != metaData.NetEntity)
|
||||
color *= _untrackedEntColor;
|
||||
color *= Color.DimGray;
|
||||
|
||||
var selectable = true;
|
||||
var blip = new NavMapBlip(coords, _spriteSystem.Frame0(texture), color, _trackedEntity == metaData.NetEntity, selectable);
|
||||
@@ -343,24 +298,6 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
NavMap.TrackedEntities[metaData.NetEntity] = blip;
|
||||
}
|
||||
|
||||
private bool TryGetSensorRegionColor(NetEntity regionOwner, AtmosAlarmType alarmState, out Color color)
|
||||
{
|
||||
color = Color.White;
|
||||
|
||||
var blip = GetBlipTexture(alarmState);
|
||||
|
||||
if (blip == null)
|
||||
return false;
|
||||
|
||||
// Color the region based on alarm state and entity tracking
|
||||
color = blip.Value.Item2 * _regionBaseColor;
|
||||
|
||||
if (_trackedEntity != null && _trackedEntity != regionOwner)
|
||||
color *= _untrackedEntColor;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateUIEntry(AtmosAlertsComputerEntry entry, int index, Control table, AtmosAlertsComputerComponent console, AtmosAlertsFocusDeviceData? focusData = null)
|
||||
{
|
||||
// Make new UI entry if required
|
||||
@@ -597,13 +534,13 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
||||
switch (alarmState)
|
||||
{
|
||||
case AtmosAlarmType.Invalid:
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png")), _inactiveColor); break;
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png")), StyleNano.DisabledFore); break;
|
||||
case AtmosAlarmType.Normal:
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png")), _goodColor); break;
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_circle.png")), Color.LimeGreen); break;
|
||||
case AtmosAlarmType.Warning:
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_triangle.png")), _warningColor); break;
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_triangle.png")), new Color(255, 182, 72)); break;
|
||||
case AtmosAlarmType.Danger:
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_square.png")), _dangerColor); break;
|
||||
output = (new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/NavMap/beveled_square.png")), new Color(255, 67, 67)); break;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -43,8 +43,6 @@ public sealed partial class ContentAudioSystem
|
||||
|
||||
private void CP14UpdateAmbientLoops()
|
||||
{
|
||||
return; //DISABLED UNTIL CLIENT ERROR SPAM FIXED
|
||||
|
||||
if (_timing.CurTime <= _nextUpdateTime)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Overlays;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Client.Commands;
|
||||
@@ -36,7 +34,7 @@ public sealed class ShowHealthBarsCommand : LocalizedCommands
|
||||
{
|
||||
var showHealthBarsComponent = new ShowHealthBarsComponent
|
||||
{
|
||||
DamageContainers = args.Select(arg => new ProtoId<DamageContainerPrototype>(arg)).ToList(),
|
||||
DamageContainers = args.ToList(),
|
||||
HealthStatusIcon = null,
|
||||
NetSyncEnabled = false
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Client.Chat.Managers;
|
||||
using Content.Client.DebugMon;
|
||||
using Content.Client.Eui;
|
||||
using Content.Client.Fullscreen;
|
||||
using Content.Client.GameTicking.Managers;
|
||||
using Content.Client.GhostKick;
|
||||
using Content.Client.Guidebook;
|
||||
using Content.Client.Input;
|
||||
@@ -72,7 +71,6 @@ namespace Content.Client.Entry
|
||||
[Dependency] private readonly IReplayLoadManager _replayLoad = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
[Dependency] private readonly DebugMonitorManager _debugMonitorManager = default!;
|
||||
[Dependency] private readonly TitleWindowManager _titleWindowManager = default!;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
@@ -142,12 +140,6 @@ namespace Content.Client.Entry
|
||||
_configManager.SetCVar("interface.resolutionAutoScaleMinimum", 0.5f);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_titleWindowManager.Shutdown();
|
||||
}
|
||||
|
||||
public override void PostInit()
|
||||
{
|
||||
base.PostInit();
|
||||
@@ -168,7 +160,6 @@ namespace Content.Client.Entry
|
||||
_userInterfaceManager.SetDefaultTheme(_configManager.GetCVar(CCVars.UIDefaultInterfaceTheme));
|
||||
_userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme));
|
||||
_documentParsingManager.Initialize();
|
||||
_titleWindowManager.Initialize();
|
||||
|
||||
_baseClient.RunLevelChanged += (_, args) =>
|
||||
{
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Client;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client.GameTicking.Managers;
|
||||
|
||||
public sealed class TitleWindowManager
|
||||
{
|
||||
[Dependency] private readonly IBaseClient _client = default!;
|
||||
[Dependency] private readonly IClyde _clyde = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IGameController _gameController = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_cfg.OnValueChanged(CVars.GameHostName, OnHostnameChange, true);
|
||||
_cfg.OnValueChanged(CCVars.GameHostnameInTitlebar, OnHostnameTitleChange, true);
|
||||
|
||||
_client.RunLevelChanged += OnRunLevelChangedChange;
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
_cfg.UnsubValueChanged(CVars.GameHostName, OnHostnameChange);
|
||||
_cfg.UnsubValueChanged(CCVars.GameHostnameInTitlebar, OnHostnameTitleChange);
|
||||
}
|
||||
|
||||
private void OnHostnameChange(string hostname)
|
||||
{
|
||||
var defaultWindowTitle = _gameController.GameTitle();
|
||||
|
||||
// Since the game assumes the server name is MyServer and that GameHostnameInTitlebar CCVar is true by default
|
||||
// Lets just... not show anything. This also is used to revert back to just the game title on disconnect.
|
||||
if (_client.RunLevel == ClientRunLevel.Initialize)
|
||||
{
|
||||
_clyde.SetWindowTitle(defaultWindowTitle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_cfg.GetCVar(CCVars.GameHostnameInTitlebar))
|
||||
// If you really dislike the dash I guess change it here
|
||||
_clyde.SetWindowTitle(hostname + " - " + defaultWindowTitle);
|
||||
else
|
||||
_clyde.SetWindowTitle(defaultWindowTitle);
|
||||
}
|
||||
|
||||
// Clients by default assume game.hostname_in_titlebar is true
|
||||
// but we need to clear it as soon as we join and actually receive the servers preference on this.
|
||||
// This will ensure we rerun OnHostnameChange and set the correct title bar name.
|
||||
private void OnHostnameTitleChange(bool colonthree)
|
||||
{
|
||||
OnHostnameChange(_cfg.GetCVar(CVars.GameHostName));
|
||||
}
|
||||
|
||||
// This is just used we can rerun the hostname change function when we disconnect to revert back to just the games title.
|
||||
private void OnRunLevelChangedChange(object? sender, RunLevelChangedEventArgs runLevelChangedEventArgs)
|
||||
{
|
||||
OnHostnameChange(_cfg.GetCVar(CVars.GameHostName));
|
||||
}
|
||||
}
|
||||
@@ -130,9 +130,9 @@ namespace Content.Client.Hands.Systems
|
||||
OnPlayerHandsAdded?.Invoke(hands);
|
||||
}
|
||||
|
||||
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null, bool log = true)
|
||||
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null)
|
||||
{
|
||||
base.DoDrop(uid, hand, doDropInteraction, hands, log);
|
||||
base.DoDrop(uid, hand, doDropInteraction, hands);
|
||||
|
||||
if (TryComp(hand.HeldEntity, out SpriteComponent? sprite))
|
||||
sprite.RenderOrder = EntityManager.CurrentTick.Value;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Shared.Localizations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -17,10 +16,19 @@ public sealed partial class PlaytimeStatsEntry : ContainerButton
|
||||
|
||||
RoleLabel.Text = role;
|
||||
Playtime = playtime; // store the TimeSpan value directly
|
||||
PlaytimeLabel.Text = ContentLocalizationManager.FormatPlaytime(playtime); // convert to string for display
|
||||
PlaytimeLabel.Text = ConvertTimeSpanToHoursMinutes(playtime); // convert to string for display
|
||||
BackgroundColorPanel.PanelOverride = styleBox;
|
||||
}
|
||||
|
||||
private static string ConvertTimeSpanToHoursMinutes(TimeSpan timeSpan)
|
||||
{
|
||||
var hours = (int)timeSpan.TotalHours;
|
||||
var minutes = timeSpan.Minutes;
|
||||
|
||||
var formattedTimeLoc = Loc.GetString("ui-playtime-time-format", ("hours", hours), ("minutes", minutes));
|
||||
return formattedTimeLoc;
|
||||
}
|
||||
|
||||
public void UpdateShading(StyleBoxFlat styleBox)
|
||||
{
|
||||
BackgroundColorPanel.PanelOverride = styleBox;
|
||||
|
||||
@@ -104,7 +104,8 @@ public sealed partial class PlaytimeStatsWindow : FancyWindow
|
||||
{
|
||||
var overallPlaytime = _jobRequirementsManager.FetchOverallPlaytime();
|
||||
|
||||
OverallPlaytimeLabel.Text = Loc.GetString("ui-playtime-overall", ("time", overallPlaytime));
|
||||
var formattedPlaytime = ConvertTimeSpanToHoursMinutes(overallPlaytime);
|
||||
OverallPlaytimeLabel.Text = Loc.GetString("ui-playtime-overall", ("time", formattedPlaytime));
|
||||
|
||||
var rolePlaytimes = _jobRequirementsManager.FetchPlaytimeByRoles();
|
||||
|
||||
@@ -133,4 +134,13 @@ public sealed partial class PlaytimeStatsWindow : FancyWindow
|
||||
_sawmill.Error($"The provided playtime string '{playtimeString}' is not in the correct format.");
|
||||
}
|
||||
}
|
||||
|
||||
private static string ConvertTimeSpanToHoursMinutes(TimeSpan timeSpan)
|
||||
{
|
||||
var hours = (int) timeSpan.TotalHours;
|
||||
var minutes = timeSpan.Minutes;
|
||||
|
||||
var formattedTimeLoc = Loc.GetString("ui-playtime-time-format", ("hours", hours), ("minutes", minutes));
|
||||
return formattedTimeLoc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using Content.Client.Clickable;
|
||||
using Content.Client.DebugMon;
|
||||
using Content.Client.Eui;
|
||||
using Content.Client.Fullscreen;
|
||||
using Content.Client.GameTicking.Managers;
|
||||
using Content.Client.GhostKick;
|
||||
using Content.Client.Guidebook;
|
||||
using Content.Client.Launcher;
|
||||
@@ -58,7 +57,6 @@ namespace Content.Client.IoC
|
||||
collection.Register<DebugMonitorManager>();
|
||||
collection.Register<PlayerRateLimitManager>();
|
||||
collection.Register<SharedPlayerRateLimitManager, PlayerRateLimitManager>();
|
||||
collection.Register<TitleWindowManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ public sealed class ShowThirstIconsSystem : EquipmentHudSystem<ShowThirstIconsCo
|
||||
return;
|
||||
|
||||
if (_thirst.TryGetStatusIconPrototype(component, out var iconPrototype))
|
||||
ev.StatusIcons.Add(iconPrototype);
|
||||
ev.StatusIcons.Add(iconPrototype!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,16 +76,16 @@ public sealed partial class StencilOverlay : Overlay
|
||||
|
||||
|
||||
//CP14 Overlays
|
||||
if (_entManager.TryGetComponent<CP14CloudShadowsComponent>(mapUid, out var shadows))
|
||||
if (_entManager.TryGetComponent<CP14WorldEdgeComponent>(mapUid, out var worldEdge))
|
||||
{
|
||||
DrawCloudShadows(args, shadows, invMatrix);
|
||||
DrawWorldEdge(args, worldEdge, invMatrix);
|
||||
}
|
||||
//CP14 Overlays end
|
||||
|
||||
//CP14 Overlays
|
||||
if (_entManager.TryGetComponent<CP14WorldEdgeComponent>(mapUid, out var worldEdge))
|
||||
if (_entManager.TryGetComponent<CP14CloudShadowsComponent>(mapUid, out var shadows))
|
||||
{
|
||||
DrawWorldEdge(args, worldEdge, invMatrix);
|
||||
DrawCloudShadows(args, shadows, invMatrix);
|
||||
}
|
||||
//CP14 Overlays end
|
||||
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Pinpointer;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Client.Pinpointer;
|
||||
|
||||
public sealed partial class NavMapSystem
|
||||
{
|
||||
private (AtmosDirection, Vector2i, AtmosDirection)[] _regionPropagationTable =
|
||||
{
|
||||
(AtmosDirection.East, new Vector2i(1, 0), AtmosDirection.West),
|
||||
(AtmosDirection.West, new Vector2i(-1, 0), AtmosDirection.East),
|
||||
(AtmosDirection.North, new Vector2i(0, 1), AtmosDirection.South),
|
||||
(AtmosDirection.South, new Vector2i(0, -1), AtmosDirection.North),
|
||||
};
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
// To prevent compute spikes, only one region is flood filled per frame
|
||||
var query = AllEntityQuery<NavMapComponent>();
|
||||
|
||||
while (query.MoveNext(out var ent, out var entNavMapRegions))
|
||||
FloodFillNextEnqueuedRegion(ent, entNavMapRegions);
|
||||
}
|
||||
|
||||
private void FloodFillNextEnqueuedRegion(EntityUid uid, NavMapComponent component)
|
||||
{
|
||||
if (!component.QueuedRegionsToFlood.Any())
|
||||
return;
|
||||
|
||||
var regionOwner = component.QueuedRegionsToFlood.Dequeue();
|
||||
|
||||
// If the region is no longer valid, flood the next one in the queue
|
||||
if (!component.RegionProperties.TryGetValue(regionOwner, out var regionProperties) ||
|
||||
!regionProperties.Seeds.Any())
|
||||
{
|
||||
FloodFillNextEnqueuedRegion(uid, component);
|
||||
return;
|
||||
}
|
||||
|
||||
// Flood fill the region, using the region seeds as starting points
|
||||
var (floodedTiles, floodedChunks) = FloodFillRegion(uid, component, regionProperties);
|
||||
|
||||
// Combine the flooded tiles into larger rectangles
|
||||
var gridCoords = GetMergedRegionTiles(floodedTiles);
|
||||
|
||||
// Create and assign the new region overlay
|
||||
var regionOverlay = new NavMapRegionOverlay(regionProperties.UiKey, gridCoords)
|
||||
{
|
||||
Color = regionProperties.Color
|
||||
};
|
||||
|
||||
component.RegionOverlays[regionOwner] = regionOverlay;
|
||||
|
||||
// To reduce unnecessary future flood fills, we will track which chunks have been flooded by a region owner
|
||||
|
||||
// First remove an old assignments
|
||||
if (component.RegionOwnerToChunkTable.TryGetValue(regionOwner, out var oldChunks))
|
||||
{
|
||||
foreach (var chunk in oldChunks)
|
||||
{
|
||||
if (component.ChunkToRegionOwnerTable.TryGetValue(chunk, out var oldOwners))
|
||||
{
|
||||
oldOwners.Remove(regionOwner);
|
||||
component.ChunkToRegionOwnerTable[chunk] = oldOwners;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now update with the new assignments
|
||||
component.RegionOwnerToChunkTable[regionOwner] = floodedChunks;
|
||||
|
||||
foreach (var chunk in floodedChunks)
|
||||
{
|
||||
if (!component.ChunkToRegionOwnerTable.TryGetValue(chunk, out var owners))
|
||||
owners = new();
|
||||
|
||||
owners.Add(regionOwner);
|
||||
component.ChunkToRegionOwnerTable[chunk] = owners;
|
||||
}
|
||||
}
|
||||
|
||||
private (HashSet<Vector2i>, HashSet<Vector2i>) FloodFillRegion(EntityUid uid, NavMapComponent component, NavMapRegionProperties regionProperties)
|
||||
{
|
||||
if (!regionProperties.Seeds.Any())
|
||||
return (new(), new());
|
||||
|
||||
var visitedChunks = new HashSet<Vector2i>();
|
||||
var visitedTiles = new HashSet<Vector2i>();
|
||||
var tilesToVisit = new Stack<Vector2i>();
|
||||
|
||||
foreach (var regionSeed in regionProperties.Seeds)
|
||||
{
|
||||
tilesToVisit.Push(regionSeed);
|
||||
|
||||
while (tilesToVisit.Count > 0)
|
||||
{
|
||||
// If the max region area is hit, exit
|
||||
if (visitedTiles.Count > regionProperties.MaxArea)
|
||||
return (new(), new());
|
||||
|
||||
// Pop the top tile from the stack
|
||||
var current = tilesToVisit.Pop();
|
||||
|
||||
// If the current tile position has already been visited,
|
||||
// or is too far away from the seed, continue
|
||||
if ((regionSeed - current).Length > regionProperties.MaxRadius)
|
||||
continue;
|
||||
|
||||
if (visitedTiles.Contains(current))
|
||||
continue;
|
||||
|
||||
// Determine the tile's chunk index
|
||||
var chunkOrigin = SharedMapSystem.GetChunkIndices(current, ChunkSize);
|
||||
var relative = SharedMapSystem.GetChunkRelative(current, ChunkSize);
|
||||
var idx = GetTileIndex(relative);
|
||||
|
||||
// Extract the tile data
|
||||
if (!component.Chunks.TryGetValue(chunkOrigin, out var chunk))
|
||||
continue;
|
||||
|
||||
var flag = chunk.TileData[idx];
|
||||
|
||||
// If the current tile is entirely occupied, continue
|
||||
if ((FloorMask & flag) == 0)
|
||||
continue;
|
||||
|
||||
if ((WallMask & flag) == WallMask)
|
||||
continue;
|
||||
|
||||
if ((AirlockMask & flag) == AirlockMask)
|
||||
continue;
|
||||
|
||||
// Otherwise the tile can be added to this region
|
||||
visitedTiles.Add(current);
|
||||
visitedChunks.Add(chunkOrigin);
|
||||
|
||||
// Determine if we can propagate the region into its cardinally adjacent neighbors
|
||||
// To propagate to a neighbor, movement into the neighbors closest edge must not be
|
||||
// blocked, and vice versa
|
||||
|
||||
foreach (var (direction, tileOffset, reverseDirection) in _regionPropagationTable)
|
||||
{
|
||||
if (!RegionCanPropagateInDirection(chunk, current, direction))
|
||||
continue;
|
||||
|
||||
var neighbor = current + tileOffset;
|
||||
var neighborOrigin = SharedMapSystem.GetChunkIndices(neighbor, ChunkSize);
|
||||
|
||||
if (!component.Chunks.TryGetValue(neighborOrigin, out var neighborChunk))
|
||||
continue;
|
||||
|
||||
visitedChunks.Add(neighborOrigin);
|
||||
|
||||
if (!RegionCanPropagateInDirection(neighborChunk, neighbor, reverseDirection))
|
||||
continue;
|
||||
|
||||
tilesToVisit.Push(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (visitedTiles, visitedChunks);
|
||||
}
|
||||
|
||||
private bool RegionCanPropagateInDirection(NavMapChunk chunk, Vector2i tile, AtmosDirection direction)
|
||||
{
|
||||
var relative = SharedMapSystem.GetChunkRelative(tile, ChunkSize);
|
||||
var idx = GetTileIndex(relative);
|
||||
var flag = chunk.TileData[idx];
|
||||
|
||||
if ((FloorMask & flag) == 0)
|
||||
return false;
|
||||
|
||||
var directionMask = 1 << (int)direction;
|
||||
var wallMask = (int)direction << (int)NavMapChunkType.Wall;
|
||||
var airlockMask = (int)direction << (int)NavMapChunkType.Airlock;
|
||||
|
||||
if ((wallMask & flag) > 0)
|
||||
return false;
|
||||
|
||||
if ((airlockMask & flag) > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<(Vector2i, Vector2i)> GetMergedRegionTiles(HashSet<Vector2i> tiles)
|
||||
{
|
||||
if (!tiles.Any())
|
||||
return new();
|
||||
|
||||
var x = tiles.Select(t => t.X);
|
||||
var minX = x.Min();
|
||||
var maxX = x.Max();
|
||||
|
||||
var y = tiles.Select(t => t.Y);
|
||||
var minY = y.Min();
|
||||
var maxY = y.Max();
|
||||
|
||||
var matrix = new int[maxX - minX + 1, maxY - minY + 1];
|
||||
|
||||
foreach (var tile in tiles)
|
||||
{
|
||||
var a = tile.X - minX;
|
||||
var b = tile.Y - minY;
|
||||
|
||||
matrix[a, b] = 1;
|
||||
}
|
||||
|
||||
return GetMergedRegionTiles(matrix, new Vector2i(minX, minY));
|
||||
}
|
||||
|
||||
private List<(Vector2i, Vector2i)> GetMergedRegionTiles(int[,] matrix, Vector2i offset)
|
||||
{
|
||||
var output = new List<(Vector2i, Vector2i)>();
|
||||
|
||||
var rows = matrix.GetLength(0);
|
||||
var cols = matrix.GetLength(1);
|
||||
|
||||
var dp = new int[rows, cols];
|
||||
var coords = (new Vector2i(), new Vector2i());
|
||||
var maxArea = 0;
|
||||
|
||||
var count = 0;
|
||||
|
||||
while (!IsArrayEmpty(matrix))
|
||||
{
|
||||
count++;
|
||||
|
||||
if (count > rows * cols)
|
||||
break;
|
||||
|
||||
// Clear old values
|
||||
dp = new int[rows, cols];
|
||||
coords = (new Vector2i(), new Vector2i());
|
||||
maxArea = 0;
|
||||
|
||||
// Initialize the first row of dp
|
||||
for (int j = 0; j < cols; j++)
|
||||
{
|
||||
dp[0, j] = matrix[0, j];
|
||||
}
|
||||
|
||||
// Calculate dp values for remaining rows
|
||||
for (int i = 1; i < rows; i++)
|
||||
{
|
||||
for (int j = 0; j < cols; j++)
|
||||
dp[i, j] = matrix[i, j] == 1 ? dp[i - 1, j] + 1 : 0;
|
||||
}
|
||||
|
||||
// Find the largest rectangular area seeded for each position in the matrix
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
for (int j = 0; j < cols; j++)
|
||||
{
|
||||
int minWidth = dp[i, j];
|
||||
|
||||
for (int k = j; k >= 0; k--)
|
||||
{
|
||||
if (dp[i, k] <= 0)
|
||||
break;
|
||||
|
||||
minWidth = Math.Min(minWidth, dp[i, k]);
|
||||
var currArea = Math.Max(maxArea, minWidth * (j - k + 1));
|
||||
|
||||
if (currArea > maxArea)
|
||||
{
|
||||
maxArea = currArea;
|
||||
coords = (new Vector2i(i - minWidth + 1, k), new Vector2i(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save the recorded rectangle vertices
|
||||
output.Add((coords.Item1 + offset, coords.Item2 + offset));
|
||||
|
||||
// Removed the tiles covered by the rectangle from matrix
|
||||
for (int i = coords.Item1.X; i <= coords.Item2.X; i++)
|
||||
{
|
||||
for (int j = coords.Item1.Y; j <= coords.Item2.Y; j++)
|
||||
matrix[i, j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private bool IsArrayEmpty(int[,] matrix)
|
||||
{
|
||||
for (int i = 0; i < matrix.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < matrix.GetLength(1); j++)
|
||||
{
|
||||
if (matrix[i, j] == 1)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Pinpointer;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
@@ -17,7 +16,6 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
||||
{
|
||||
Dictionary<Vector2i, int[]> modifiedChunks;
|
||||
Dictionary<NetEntity, NavMapBeacon> beacons;
|
||||
Dictionary<NetEntity, NavMapRegionProperties> regions;
|
||||
|
||||
switch (args.Current)
|
||||
{
|
||||
@@ -25,8 +23,6 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
||||
{
|
||||
modifiedChunks = delta.ModifiedChunks;
|
||||
beacons = delta.Beacons;
|
||||
regions = delta.Regions;
|
||||
|
||||
foreach (var index in component.Chunks.Keys)
|
||||
{
|
||||
if (!delta.AllChunks!.Contains(index))
|
||||
@@ -39,8 +35,6 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
||||
{
|
||||
modifiedChunks = state.Chunks;
|
||||
beacons = state.Beacons;
|
||||
regions = state.Regions;
|
||||
|
||||
foreach (var index in component.Chunks.Keys)
|
||||
{
|
||||
if (!state.Chunks.ContainsKey(index))
|
||||
@@ -53,54 +47,13 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
|
||||
return;
|
||||
}
|
||||
|
||||
// Update region data and queue new regions for flooding
|
||||
var prevRegionOwners = component.RegionProperties.Keys.ToList();
|
||||
var validRegionOwners = new List<NetEntity>();
|
||||
|
||||
component.RegionProperties.Clear();
|
||||
|
||||
foreach (var (regionOwner, regionData) in regions)
|
||||
{
|
||||
if (!regionData.Seeds.Any())
|
||||
continue;
|
||||
|
||||
component.RegionProperties[regionOwner] = regionData;
|
||||
validRegionOwners.Add(regionOwner);
|
||||
|
||||
if (component.RegionOverlays.ContainsKey(regionOwner))
|
||||
continue;
|
||||
|
||||
if (component.QueuedRegionsToFlood.Contains(regionOwner))
|
||||
continue;
|
||||
|
||||
component.QueuedRegionsToFlood.Enqueue(regionOwner);
|
||||
}
|
||||
|
||||
// Remove stale region owners
|
||||
var regionOwnersToRemove = prevRegionOwners.Except(validRegionOwners);
|
||||
|
||||
foreach (var regionOwnerRemoved in regionOwnersToRemove)
|
||||
RemoveNavMapRegion(uid, component, regionOwnerRemoved);
|
||||
|
||||
// Modify chunks
|
||||
foreach (var (origin, chunk) in modifiedChunks)
|
||||
{
|
||||
var newChunk = new NavMapChunk(origin);
|
||||
Array.Copy(chunk, newChunk.TileData, chunk.Length);
|
||||
component.Chunks[origin] = newChunk;
|
||||
|
||||
// If the affected chunk intersects one or more regions, re-flood them
|
||||
if (!component.ChunkToRegionOwnerTable.TryGetValue(origin, out var affectedOwners))
|
||||
continue;
|
||||
|
||||
foreach (var affectedOwner in affectedOwners)
|
||||
{
|
||||
if (!component.QueuedRegionsToFlood.Contains(affectedOwner))
|
||||
component.QueuedRegionsToFlood.Enqueue(affectedOwner);
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh beacons
|
||||
component.Beacons.Clear();
|
||||
foreach (var (nuid, beacon) in beacons)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,6 @@ public partial class NavMapControl : MapGridControl
|
||||
public List<(Vector2, Vector2)> TileLines = new();
|
||||
public List<(Vector2, Vector2)> TileRects = new();
|
||||
public List<(Vector2[], Color)> TilePolygons = new();
|
||||
public List<NavMapRegionOverlay> RegionOverlays = new();
|
||||
|
||||
// Default colors
|
||||
public Color WallColor = new(102, 217, 102);
|
||||
@@ -229,7 +228,7 @@ public partial class NavMapControl : MapGridControl
|
||||
{
|
||||
if (!blip.Selectable)
|
||||
continue;
|
||||
|
||||
|
||||
var currentDistance = (_transformSystem.ToMapCoordinates(blip.Coordinates).Position - worldPosition).Length();
|
||||
|
||||
if (closestDistance < currentDistance || currentDistance * MinimapScale > MaxSelectableDistance)
|
||||
@@ -320,22 +319,6 @@ public partial class NavMapControl : MapGridControl
|
||||
}
|
||||
}
|
||||
|
||||
// Draw region overlays
|
||||
if (_grid != null)
|
||||
{
|
||||
foreach (var regionOverlay in RegionOverlays)
|
||||
{
|
||||
foreach (var gridCoords in regionOverlay.GridCoords)
|
||||
{
|
||||
var positionTopLeft = ScalePosition(new Vector2(gridCoords.Item1.X, -gridCoords.Item1.Y) - new Vector2(offset.X, -offset.Y));
|
||||
var positionBottomRight = ScalePosition(new Vector2(gridCoords.Item2.X + _grid.TileSize, -gridCoords.Item2.Y - _grid.TileSize) - new Vector2(offset.X, -offset.Y));
|
||||
|
||||
var box = new UIBox2(positionTopLeft, positionBottomRight);
|
||||
handle.DrawRect(box, regionOverlay.Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw map lines
|
||||
if (TileLines.Any())
|
||||
{
|
||||
|
||||
@@ -51,8 +51,6 @@ public sealed class JobRequirementsManager : ISharedPlaytimeManager
|
||||
{
|
||||
// Reset on disconnect, just in case.
|
||||
_roles.Clear();
|
||||
_jobWhitelists.Clear();
|
||||
_roleBans.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +58,9 @@ public sealed class JobRequirementsManager : ISharedPlaytimeManager
|
||||
{
|
||||
_sawmill.Debug($"Received roleban info containing {message.Bans.Count} entries.");
|
||||
|
||||
if (_roleBans.Equals(message.Bans))
|
||||
return;
|
||||
|
||||
_roleBans.Clear();
|
||||
_roleBans.AddRange(message.Bans);
|
||||
Updated?.Invoke();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using Content.Client.Power.APC.UI;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Client.Power.APC.UI;
|
||||
using Content.Shared.APC;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Client.Power.APC
|
||||
{
|
||||
@@ -23,14 +22,6 @@ namespace Content.Client.Power.APC
|
||||
_menu = this.CreateWindow<ApcMenu>();
|
||||
_menu.SetEntity(Owner);
|
||||
_menu.OnBreaker += BreakerPressed;
|
||||
|
||||
var hasAccess = false;
|
||||
if (PlayerManager.LocalEntity != null)
|
||||
{
|
||||
var accessReader = EntMan.System<AccessReaderSystem>();
|
||||
hasAccess = accessReader.IsAllowed((EntityUid)PlayerManager.LocalEntity, Owner);
|
||||
}
|
||||
_menu?.SetAccessEnabled(hasAccess);
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -36,9 +36,19 @@ namespace Content.Client.Power.APC.UI
|
||||
{
|
||||
var castState = (ApcBoundInterfaceState) state;
|
||||
|
||||
if (!BreakerButton.Disabled)
|
||||
if (BreakerButton != null)
|
||||
{
|
||||
BreakerButton.Pressed = castState.MainBreaker;
|
||||
if(castState.HasAccess == false)
|
||||
{
|
||||
BreakerButton.Disabled = true;
|
||||
BreakerButton.ToolTip = Loc.GetString("apc-component-insufficient-access");
|
||||
}
|
||||
else
|
||||
{
|
||||
BreakerButton.Disabled = false;
|
||||
BreakerButton.ToolTip = null;
|
||||
BreakerButton.Pressed = castState.MainBreaker;
|
||||
}
|
||||
}
|
||||
|
||||
if (PowerLabel != null)
|
||||
@@ -76,20 +86,6 @@ namespace Content.Client.Power.APC.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAccessEnabled(bool hasAccess)
|
||||
{
|
||||
if(hasAccess)
|
||||
{
|
||||
BreakerButton.Disabled = false;
|
||||
BreakerButton.ToolTip = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
BreakerButton.Disabled = true;
|
||||
BreakerButton.ToolTip = Loc.GetString("apc-component-insufficient-access");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateChargeBarColor(float charge)
|
||||
{
|
||||
if (ChargeBar == null)
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Content.Client.Stylesheets
|
||||
public static readonly Color ButtonColorDefaultRed = Color.FromHex("#D43B3B");
|
||||
public static readonly Color ButtonColorHovered = Color.FromHex("#7f6357");
|
||||
public static readonly Color ButtonColorHoveredRed = Color.FromHex("#DF6B6B");
|
||||
public static readonly Color ButtonColorPressed = Color.FromHex("#4a332b");
|
||||
public static readonly Color ButtonColorPressed = Color.FromHex("#6c4a3e");
|
||||
public static readonly Color ButtonColorDisabled = Color.FromHex("#3c3330");
|
||||
|
||||
public static readonly Color ButtonColorCautionDefault = Color.FromHex("#ab3232");
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<BoxContainer xmlns="https://spacestation14.io"
|
||||
Orientation="Vertical"
|
||||
Margin="8 0 8 0">
|
||||
<BoxContainer Name="Buttons"
|
||||
Orientation="Vertical"
|
||||
SeparationOverride="5">
|
||||
<!-- Buttons are added here by code -->
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
@@ -1,15 +1,15 @@
|
||||
<BoxContainer xmlns="https://spacestation14.io"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Stretch">
|
||||
Orientation="Horizontal">
|
||||
<Button Name="RequestButton"
|
||||
Access="Public"
|
||||
Text="{Loc 'ghost-roles-window-request-role-button'}"
|
||||
StyleClasses="OpenRight"
|
||||
HorizontalExpand="True"
|
||||
SizeFlagsStretchRatio="3"/>
|
||||
HorizontalAlignment="Left"
|
||||
SetWidth="300"/>
|
||||
<Button Name="FollowButton"
|
||||
Access="Public"
|
||||
Text="{Loc 'ghost-roles-window-follow-role-button'}"
|
||||
StyleClasses="OpenLeft"
|
||||
HorizontalExpand="True"/>
|
||||
HorizontalAlignment="Right"
|
||||
SetWidth="150"/>
|
||||
</BoxContainer>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<BoxContainer xmlns="https://spacestation14.io"
|
||||
Orientation="Vertical">
|
||||
<Label Name="Title"
|
||||
StyleClasses="LabelKeyText"/>
|
||||
<PanelContainer StyleClasses="HighDivider" />
|
||||
<RichTextLabel Name="Description"
|
||||
Margin="0 4"/>
|
||||
</BoxContainer>
|
||||
@@ -1,18 +0,0 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class GhostRoleInfoBox : BoxContainer
|
||||
{
|
||||
public GhostRoleInfoBox(string name, string description)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
Title.Text = name;
|
||||
Description.SetMessage(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<BoxContainer xmlns="https://spacestation14.io"
|
||||
Orientation="Vertical"
|
||||
HorizontalExpand="True"
|
||||
Margin="0 0 8 8">
|
||||
<Label Name="Title"
|
||||
StyleClasses="LabelKeyText"/>
|
||||
<PanelContainer StyleClasses="HighDivider" />
|
||||
<RichTextLabel Name="Description"
|
||||
Margin="0 4"/>
|
||||
<BoxContainer Name="Buttons"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Vertical"
|
||||
SeparationOverride="5">
|
||||
<!-- Buttons are added here by code -->
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
@@ -10,17 +10,20 @@ using Robust.Shared.Utility;
|
||||
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class GhostRoleButtonsBox : BoxContainer
|
||||
public sealed partial class GhostRolesEntry : BoxContainer
|
||||
{
|
||||
private SpriteSystem _spriteSystem;
|
||||
public event Action<GhostRoleInfo>? OnRoleSelected;
|
||||
public event Action<GhostRoleInfo>? OnRoleFollow;
|
||||
|
||||
public GhostRoleButtonsBox(bool hasAccess, FormattedMessage? reason, IEnumerable<GhostRoleInfo> roles, SpriteSystem spriteSystem)
|
||||
public GhostRolesEntry(string name, string description, bool hasAccess, FormattedMessage? reason, IEnumerable<GhostRoleInfo> roles, SpriteSystem spriteSystem)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_spriteSystem = spriteSystem;
|
||||
|
||||
Title.Text = name;
|
||||
Description.SetMessage(description);
|
||||
|
||||
foreach (var role in roles)
|
||||
{
|
||||
var button = new GhostRoleEntryButtons(role);
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Eui;
|
||||
using Content.Shared.Ghost.Roles;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
{
|
||||
@@ -76,13 +77,6 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
|
||||
if (state is not GhostRolesEuiState ghostState)
|
||||
return;
|
||||
|
||||
// We must save BodyVisible state, so all Collapsible boxes will not close
|
||||
// on adding new ghost role.
|
||||
// Save the current state of each Collapsible box being visible or not
|
||||
_window.SaveCollapsibleBoxesStates();
|
||||
|
||||
// Clearing the container before adding new roles
|
||||
_window.ClearEntries();
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
@@ -90,32 +84,28 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
var spriteSystem = sysManager.GetEntitySystem<SpriteSystem>();
|
||||
var requirementsManager = IoCManager.Resolve<JobRequirementsManager>();
|
||||
|
||||
// TODO: role.Requirements value doesn't work at all as an equality key, this must be fixed
|
||||
// Grouping roles
|
||||
var groupedRoles = ghostState.GhostRoles.GroupBy(
|
||||
role => (role.Name, role.Description, role.Requirements));
|
||||
|
||||
// Add a new entry for each role group
|
||||
foreach (var group in groupedRoles)
|
||||
{
|
||||
var name = group.Key.Name;
|
||||
var description = group.Key.Description;
|
||||
var hasAccess = requirementsManager.CheckRoleRequirements(
|
||||
group.Key.Requirements,
|
||||
null,
|
||||
out var reason);
|
||||
bool hasAccess = true;
|
||||
FormattedMessage? reason;
|
||||
|
||||
if (!requirementsManager.CheckRoleRequirements(group.Key.Requirements, null, out reason))
|
||||
{
|
||||
hasAccess = false;
|
||||
}
|
||||
|
||||
// Adding a new role
|
||||
_window.AddEntry(name, description, hasAccess, reason, group, spriteSystem);
|
||||
}
|
||||
|
||||
// Restore the Collapsible box state if it is saved
|
||||
_window.RestoreCollapsibleBoxesStates();
|
||||
|
||||
// Close the rules window if it is no longer needed
|
||||
var closeRulesWindow = ghostState.GhostRoles.All(role => role.Identifier != _windowRulesId);
|
||||
if (closeRulesWindow)
|
||||
{
|
||||
_windowRules?.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Ghost.Roles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
@@ -15,86 +12,20 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
||||
public event Action<GhostRoleInfo>? OnRoleRequestButtonClicked;
|
||||
public event Action<GhostRoleInfo>? OnRoleFollow;
|
||||
|
||||
private Dictionary<(string name, string description), Collapsible> _collapsibleBoxes = new();
|
||||
private HashSet<(string name, string description)> _uncollapsedStates = new();
|
||||
|
||||
public GhostRolesWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void ClearEntries()
|
||||
{
|
||||
NoRolesMessage.Visible = true;
|
||||
EntryContainer.DisposeAllChildren();
|
||||
_collapsibleBoxes.Clear();
|
||||
}
|
||||
|
||||
public void SaveCollapsibleBoxesStates()
|
||||
{
|
||||
_uncollapsedStates.Clear();
|
||||
foreach (var (key, collapsible) in _collapsibleBoxes)
|
||||
{
|
||||
if (collapsible.BodyVisible)
|
||||
{
|
||||
_uncollapsedStates.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreCollapsibleBoxesStates()
|
||||
{
|
||||
foreach (var (key, collapsible) in _collapsibleBoxes)
|
||||
{
|
||||
collapsible.BodyVisible = _uncollapsedStates.Contains(key);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddEntry(string name, string description, bool hasAccess, FormattedMessage? reason, IEnumerable<GhostRoleInfo> roles, SpriteSystem spriteSystem)
|
||||
{
|
||||
NoRolesMessage.Visible = false;
|
||||
|
||||
var ghostRoleInfos = roles.ToList();
|
||||
var rolesCount = ghostRoleInfos.Count;
|
||||
|
||||
var info = new GhostRoleInfoBox(name, description);
|
||||
var buttons = new GhostRoleButtonsBox(hasAccess, reason, ghostRoleInfos, spriteSystem);
|
||||
buttons.OnRoleSelected += OnRoleRequestButtonClicked;
|
||||
buttons.OnRoleFollow += OnRoleFollow;
|
||||
|
||||
EntryContainer.AddChild(info);
|
||||
|
||||
if (rolesCount > 1)
|
||||
{
|
||||
var buttonHeading = new CollapsibleHeading(Loc.GetString("ghost-roles-window-available-button", ("rolesCount", rolesCount)));
|
||||
|
||||
buttonHeading.AddStyleClass(ContainerButton.StyleClassButton);
|
||||
buttonHeading.Label.HorizontalAlignment = HAlignment.Center;
|
||||
buttonHeading.Label.HorizontalExpand = true;
|
||||
|
||||
var body = new CollapsibleBody
|
||||
{
|
||||
Margin = new Thickness(0, 5, 0, 0),
|
||||
};
|
||||
|
||||
// TODO: Add Requirements to this key when it'll be fixed and work as an equality key in GhostRolesEui
|
||||
var key = (name, description);
|
||||
|
||||
var collapsible = new Collapsible(buttonHeading, body)
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
||||
Margin = new Thickness(0, 0, 0, 8),
|
||||
};
|
||||
|
||||
body.AddChild(buttons);
|
||||
|
||||
EntryContainer.AddChild(collapsible);
|
||||
_collapsibleBoxes.Add(key, collapsible);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntryContainer.AddChild(buttons);
|
||||
}
|
||||
var entry = new GhostRolesEntry(name, description, hasAccess, reason, roles, spriteSystem);
|
||||
entry.OnRoleSelected += OnRoleRequestButtonClicked;
|
||||
entry.OnRoleFollow += OnRoleFollow;
|
||||
EntryContainer.AddChild(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
MinHeight="210">
|
||||
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls">
|
||||
<BoxContainer Name="MainContainer" Orientation="Vertical">
|
||||
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True" Margin ="4 4"/>
|
||||
<co:SearchListContainer Name="VendingContents" VerticalExpand="True" Margin="4 4"/>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
@@ -9,7 +8,6 @@ using Content.Shared.Voting;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.State;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
@@ -30,7 +28,6 @@ namespace Content.Client.Voting.UI
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IEntityNetworkManager _entNetManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IStateManager _state = default!;
|
||||
|
||||
private VotingSystem _votingSystem;
|
||||
|
||||
@@ -65,7 +62,7 @@ namespace Content.Client.Voting.UI
|
||||
|
||||
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
||||
CloseButton.OnPressed += _ => Close();
|
||||
VoteNotTrustedLabel.Text = Loc.GetString("ui-vote-trusted-users-notice", ("timeReq", _cfg.GetCVar(CCVars.VotekickEligibleVoterDeathtime)));
|
||||
VoteNotTrustedLabel.Text = Loc.GetString("ui-vote-trusted-users-notice", ("timeReq", _cfg.GetCVar(CCVars.VotekickEligibleVoterDeathtime) / 60));
|
||||
|
||||
foreach (StandardVoteType voteType in Enum.GetValues<StandardVoteType>())
|
||||
{
|
||||
@@ -73,7 +70,6 @@ namespace Content.Client.Voting.UI
|
||||
VoteTypeButton.AddItem(Loc.GetString(option.Name), (int)voteType);
|
||||
}
|
||||
|
||||
_state.OnStateChanged += OnStateChanged;
|
||||
VoteTypeButton.OnItemSelected += VoteTypeSelected;
|
||||
CreateButton.OnPressed += CreatePressed;
|
||||
FollowButton.OnPressed += FollowSelected;
|
||||
@@ -105,14 +101,6 @@ namespace Content.Client.Voting.UI
|
||||
UpdateVoteTimeout();
|
||||
}
|
||||
|
||||
private void OnStateChanged(StateChangedEventArgs obj)
|
||||
{
|
||||
if (obj.NewState is not GameplayState)
|
||||
return;
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CanCallVoteChanged(bool obj)
|
||||
{
|
||||
if (!obj)
|
||||
|
||||
@@ -19,6 +19,11 @@ public sealed class VotingSystem : EntitySystem
|
||||
|
||||
private void OnVotePlayerListResponseEvent(VotePlayerListResponseEvent msg)
|
||||
{
|
||||
if (!_ghostSystem.IsGhost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VotePlayerListResponse?.Invoke(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
|
||||
[Dependency] private readonly InputSystem _inputSystem = default!;
|
||||
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
|
||||
[Dependency] private readonly MapSystem _map = default!;
|
||||
|
||||
private EntityQuery<TransformComponent> _xformQuery;
|
||||
|
||||
@@ -110,11 +109,11 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
||||
|
||||
if (MapManager.TryFindGridAt(mousePos, out var gridUid, out _))
|
||||
{
|
||||
coordinates = TransformSystem.ToCoordinates(gridUid, mousePos);
|
||||
coordinates = EntityCoordinates.FromMap(gridUid, mousePos, TransformSystem, EntityManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
coordinates = TransformSystem.ToCoordinates(_map.GetMap(mousePos.MapId), mousePos);
|
||||
coordinates = EntityCoordinates.FromMap(MapManager.GetMapEntityId(mousePos.MapId), mousePos, TransformSystem, EntityManager);
|
||||
}
|
||||
|
||||
// Heavy attack.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
namespace Content.Client._CP14.Localization;
|
||||
|
||||
/// <summary>
|
||||
/// Controls the visual of the sprite, depending on the localization. Useful for drawn lettering
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class CP14LocalizationVisualsComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// map(map,(lang, state))
|
||||
/// in yml:
|
||||
///
|
||||
/// - type: Sprite
|
||||
/// layers:
|
||||
/// - state: stateName0
|
||||
/// map: ["map1"]
|
||||
/// - state: stateName0
|
||||
/// map: ["map2"]
|
||||
/// - type: CP14LocalizationVisuals
|
||||
/// mapStates:
|
||||
/// map1:
|
||||
/// ru-RU: stateName1
|
||||
/// en-US: stateName2
|
||||
/// map2:
|
||||
/// ru-RU: stateName3
|
||||
/// en-US: stateName4
|
||||
///
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public Dictionary<string, Dictionary<string, string>> MapStates;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using Content.Shared.Localizations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client._CP14.Localization;
|
||||
|
||||
public sealed class CP14LocalizationVisualsSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14LocalizationVisualsComponent, ComponentInit>(OnCompInit);
|
||||
}
|
||||
|
||||
private void OnCompInit(Entity<CP14LocalizationVisualsComponent> visuals, ref ComponentInit args)
|
||||
{
|
||||
if (!TryComp<SpriteComponent>(visuals, out var sprite))
|
||||
return;
|
||||
|
||||
foreach (var (map, pDictionary) in visuals.Comp.MapStates)
|
||||
{
|
||||
if (!pDictionary.TryGetValue(ContentLocalizationManager.Culture, out var state))
|
||||
return;
|
||||
|
||||
if (sprite.LayerMapTryGet(map, out _))
|
||||
sprite.LayerSetState(map, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
using Content.Shared._CP14.MagicSpell;
|
||||
|
||||
namespace Content.Client._CP14.MagicSpell;
|
||||
|
||||
public sealed partial class CP14ClientMagicSystem : CP14SharedMagicSystem
|
||||
{
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client._CP14.Shitcode;
|
||||
|
||||
/// <summary>
|
||||
/// Эта система - сборник разного мелкого барахла, который слишком мелкий чтобы иметь свои собственные системы. В идеале в будущем разнести по отдельным файлам.
|
||||
/// </summary>
|
||||
public sealed class CP14EdSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
_cfg.SetCVar(CVars.EntitiesCategoryFilter, "ForkFiltered");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared._CP14.Cargo;
|
||||
using Content.Shared._CP14.TravelingStoreShip;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared._CP14.Cargo;
|
||||
using Content.Shared._CP14.TravelingStoreShip;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared._CP14.Cargo;
|
||||
using Content.Shared._CP14.TravelingStoreShip;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
@@ -107,41 +107,13 @@ public sealed partial class TestPair
|
||||
/// <summary>
|
||||
/// Retrieve all entity prototypes that have some component.
|
||||
/// </summary>
|
||||
public List<(EntityPrototype, T)> GetPrototypesWithComponent<T>(
|
||||
public List<EntityPrototype> GetPrototypesWithComponent<T>(
|
||||
HashSet<string>? ignored = null,
|
||||
bool ignoreAbstract = true,
|
||||
bool ignoreTestPrototypes = true)
|
||||
where T : IComponent
|
||||
{
|
||||
var id = Server.ResolveDependency<IComponentFactory>().GetComponentName(typeof(T));
|
||||
var list = new List<(EntityPrototype, T)>();
|
||||
foreach (var proto in Server.ProtoMan.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (ignored != null && ignored.Contains(proto.ID))
|
||||
continue;
|
||||
|
||||
if (ignoreAbstract && proto.Abstract)
|
||||
continue;
|
||||
|
||||
if (ignoreTestPrototypes && IsTestPrototype(proto))
|
||||
continue;
|
||||
|
||||
if (proto.Components.TryGetComponent(id, out var cmp))
|
||||
list.Add((proto, (T)cmp));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all entity prototypes that have some component.
|
||||
/// </summary>
|
||||
public List<EntityPrototype> GetPrototypesWithComponent(Type type,
|
||||
HashSet<string>? ignored = null,
|
||||
bool ignoreAbstract = true,
|
||||
bool ignoreTestPrototypes = true)
|
||||
{
|
||||
var id = Server.ResolveDependency<IComponentFactory>().GetComponentName(type);
|
||||
var list = new List<EntityPrototype>();
|
||||
foreach (var proto in Server.ProtoMan.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
@@ -155,7 +127,7 @@ public sealed partial class TestPair
|
||||
continue;
|
||||
|
||||
if (proto.Components.ContainsKey(id))
|
||||
list.Add((proto));
|
||||
list.Add(proto);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.IntegrationTests.Tests.GameRules;
|
||||
// Lets not let that happen again.
|
||||
[TestFixture]
|
||||
public sealed class AntagPreferenceTest
|
||||
{/* CP14 disabled
|
||||
{
|
||||
[Test]
|
||||
public async Task TestLobbyPlayersValid()
|
||||
{
|
||||
@@ -72,5 +72,5 @@ public sealed class AntagPreferenceTest
|
||||
|
||||
await server.WaitPost(() => server.EntMan.DeleteEntity(uid));
|
||||
await pair.CleanReturnAsync();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Roles;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Reflection;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Minds;
|
||||
|
||||
[TestFixture]
|
||||
public sealed class RoleTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Check that any prototype with a <see cref="MindRoleComponent"/> is properly configured
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ValidateRolePrototypes()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
|
||||
var jobComp = pair.Server.ResolveDependency<IComponentFactory>().GetComponentName(typeof(JobRoleComponent));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var (proto, comp) in pair.GetPrototypesWithComponent<MindRoleComponent>())
|
||||
{
|
||||
Assert.That(comp.AntagPrototype == null || comp.JobPrototype == null, $"Role {proto.ID} has both a job and antag prototype.");
|
||||
Assert.That(!comp.ExclusiveAntag || comp.Antag, $"Role {proto.ID} is marked as an exclusive antag, despite not being an antag.");
|
||||
Assert.That(comp.Antag || comp.AntagPrototype == null, $"Role {proto.ID} has an antag prototype, despite not being an antag.");
|
||||
|
||||
if (comp.JobPrototype != null)
|
||||
Assert.That(proto.Components.ContainsKey(jobComp), $"Role {proto.ID} is a job, despite not having a job prototype.");
|
||||
|
||||
// It is possible that this is meant to be supported? Though I would assume that it would be for
|
||||
// admin / prototype uploads, and that pre-defined roles should still check this.
|
||||
Assert.That(!comp.Antag || comp.AntagPrototype != null , $"Role {proto.ID} is an antag, despite not having a antag prototype.");
|
||||
}
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check that any prototype with a <see cref="JobRoleComponent"/> also has a properly configured
|
||||
/// <see cref="MindRoleComponent"/>
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ValidateJobPrototypes()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
|
||||
var mindCompId = pair.Server.ResolveDependency<IComponentFactory>().GetComponentName(typeof(MindRoleComponent));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var (proto, comp) in pair.GetPrototypesWithComponent<JobRoleComponent>())
|
||||
{
|
||||
if (proto.Components.TryGetComponent(mindCompId, out var mindComp))
|
||||
Assert.That(((MindRoleComponent)mindComp).JobPrototype, Is.Not.Null);
|
||||
}
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check that any prototype with a component that inherits from <see cref="BaseMindRoleComponent"/> also has a
|
||||
/// <see cref="MindRoleComponent"/>
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ValidateRolesHaveMindRoleComp()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
|
||||
var refMan = pair.Server.ResolveDependency<IReflectionManager>();
|
||||
var mindCompId = pair.Server.ResolveDependency<IComponentFactory>().GetComponentName(typeof(MindRoleComponent));
|
||||
|
||||
var compTypes = refMan.GetAllChildren(typeof(BaseMindRoleComponent))
|
||||
.Append(typeof(RoleBriefingComponent))
|
||||
.Where(x => !x.IsAbstract);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var comp in compTypes)
|
||||
{
|
||||
foreach (var proto in pair.GetPrototypesWithComponent(comp))
|
||||
{
|
||||
Assert.That(proto.Components.ContainsKey(mindCompId), $"Role {proto.ID} does not have a {nameof(MindRoleComponent)} despite having a {comp.Name}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,9 @@ namespace Content.IntegrationTests.Tests
|
||||
"MeteorArena",
|
||||
|
||||
//CrystallPunk maps
|
||||
"Village",
|
||||
"Island",
|
||||
"AlchemyTest",
|
||||
"BattleRoyale",
|
||||
"ExpeditionTest",
|
||||
//CrystallPunk Map replacement end
|
||||
};
|
||||
|
||||
@@ -235,6 +236,7 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
// Test all availableJobs have spawnPoints
|
||||
// This is done inside gamemap test because loading the map takes ages and we already have it.
|
||||
/*
|
||||
var comp = entManager.GetComponent<StationJobsComponent>(station);
|
||||
var jobs = new HashSet<ProtoId<JobPrototype>>(comp.SetupAvailableJobs.Keys);
|
||||
|
||||
@@ -251,6 +253,7 @@ namespace Content.IntegrationTests.Tests
|
||||
jobs.ExceptWith(spawnPoints);
|
||||
|
||||
Assert.That(jobs, Is.Empty, $"There is no spawnpoints for {string.Join(", ", jobs)} on {mapProto}.");
|
||||
*/ //CP14 disable job spawners test
|
||||
}
|
||||
|
||||
try
|
||||
|
||||
@@ -35,16 +35,15 @@ public sealed class StartingGearPrototypeStorageTest
|
||||
{
|
||||
foreach (var gearProto in protos)
|
||||
{
|
||||
var backpackProto = ((IEquipmentLoadout) gearProto).GetGear("back");
|
||||
if (backpackProto == string.Empty)
|
||||
continue;
|
||||
|
||||
var bag = server.EntMan.SpawnEntity(backpackProto, coords);
|
||||
var ents = new ValueList<EntityUid>();
|
||||
|
||||
foreach (var (slot, entProtos) in gearProto.Storage)
|
||||
{
|
||||
ents.Clear();
|
||||
var storageProto = ((IEquipmentLoadout)gearProto).GetGear(slot);
|
||||
if (storageProto == string.Empty)
|
||||
continue;
|
||||
|
||||
var bag = server.EntMan.SpawnEntity(storageProto, coords);
|
||||
if (entProtos.Count == 0)
|
||||
continue;
|
||||
|
||||
@@ -60,8 +59,9 @@ public sealed class StartingGearPrototypeStorageTest
|
||||
|
||||
server.EntMan.DeleteEntity(ent);
|
||||
}
|
||||
server.EntMan.DeleteEntity(bag);
|
||||
}
|
||||
|
||||
server.EntMan.DeleteEntity(bag);
|
||||
}
|
||||
|
||||
mapManager.DeleteMap(testMap.MapId);
|
||||
|
||||
@@ -40,7 +40,7 @@ public sealed class PrototypeSaveTest
|
||||
|
||||
await pair.Client.WaitPost(() =>
|
||||
{
|
||||
foreach (var (proto, _) in pair.GetPrototypesWithComponent<ItemComponent>(Ignored))
|
||||
foreach (var proto in pair.GetPrototypesWithComponent<ItemComponent>(Ignored))
|
||||
{
|
||||
var dummy = pair.Client.EntMan.Spawn(proto.ID);
|
||||
pair.Client.EntMan.RunMapInit(dummy, pair.Client.MetaData(dummy));
|
||||
|
||||
@@ -94,13 +94,14 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
await Assert.MultipleAsync(async () =>
|
||||
{
|
||||
foreach (var (proto, fill) in pair.GetPrototypesWithComponent<StorageFillComponent>())
|
||||
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
|
||||
{
|
||||
if (proto.HasComponent<EntityStorageComponent>(compFact))
|
||||
continue;
|
||||
|
||||
StorageComponent? storage = null;
|
||||
ItemComponent? item = null;
|
||||
StorageFillComponent fill = default!;
|
||||
var size = 0;
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
@@ -111,6 +112,7 @@ namespace Content.IntegrationTests.Tests
|
||||
}
|
||||
|
||||
proto.TryGetComponent("Item", out item);
|
||||
fill = (StorageFillComponent) proto.Components[id].Component;
|
||||
size = GetFillSize(fill, false, protoMan, itemSys);
|
||||
});
|
||||
|
||||
@@ -177,7 +179,7 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
var itemSys = entMan.System<SharedItemSystem>();
|
||||
|
||||
foreach (var (proto, fill) in pair.GetPrototypesWithComponent<StorageFillComponent>())
|
||||
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
|
||||
{
|
||||
if (proto.HasComponent<StorageComponent>(compFact))
|
||||
continue;
|
||||
@@ -190,6 +192,7 @@ namespace Content.IntegrationTests.Tests
|
||||
if (entStorage == null)
|
||||
return;
|
||||
|
||||
var fill = (StorageFillComponent) proto.Components[id].Component;
|
||||
var size = GetFillSize(fill, true, protoMan, itemSys);
|
||||
Assert.That(size, Is.LessThanOrEqualTo(entStorage.Capacity),
|
||||
$"{proto.ID} storage fill is too large.");
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared._CP14.Cargo.Prototype;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests._CP14;
|
||||
|
||||
#nullable enable
|
||||
|
||||
[TestFixture]
|
||||
public sealed class CP14CargoTest
|
||||
{
|
||||
[Test]
|
||||
public async Task CheckAllBuyPositionsUniqueCode()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
|
||||
var compFactory = server.ResolveDependency<IComponentFactory>();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
HashSet<string> existedCodes = new();
|
||||
|
||||
foreach (var proto in protoManager.EnumeratePrototypes<CP14StoreBuyPositionPrototype>())
|
||||
{
|
||||
Assert.That(!existedCodes.Contains(proto.Code), $"Repeated purchasing code {proto.Code} of the {proto}");
|
||||
existedCodes.Add(proto.Code);
|
||||
}
|
||||
});
|
||||
});
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests._CP14;
|
||||
|
||||
#nullable enable
|
||||
|
||||
[TestFixture]
|
||||
public sealed class CP14EntityTest
|
||||
{
|
||||
[Test]
|
||||
public async Task CheckAllCP14EntityHasForkFilteredCategory()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
|
||||
var compFactory = server.ResolveDependency<IComponentFactory>();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
if (!protoManager.TryIndex<EntityCategoryPrototype>("ForkFiltered", out var indexedFilter))
|
||||
return;
|
||||
|
||||
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (!proto.ID.StartsWith("CP14"))
|
||||
continue;
|
||||
|
||||
if (proto.Abstract || proto.HideSpawnMenu)
|
||||
continue;
|
||||
|
||||
Assert.That(proto.Categories.Contains(indexedFilter), $"CP14 fork proto: {proto} does not marked abstract, or have a HideSpawnMenu or ForkFiltered category");
|
||||
}
|
||||
});
|
||||
});
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public sealed class CP14RitualTest
|
||||
|
||||
foreach (var edge in phase.Edges)
|
||||
{
|
||||
Assert.That(edge.Triggers.Count > 0, $"{proto} is ritual node, but edge to {edge.Target} has no triggers and cannot be activated.");
|
||||
Assert.That(edge.Triggers.Count > 0, $"{{proto}} is ritual node, but edge to {edge.Target} has no triggers and cannot be activated.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,13 +14,13 @@ using Content.Shared.Players.PlayTimeTracking;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Asynchronous;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Administration.Managers;
|
||||
|
||||
@@ -45,12 +45,14 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
public const string SawmillId = "admin.bans";
|
||||
public const string JobPrefix = "Job:";
|
||||
|
||||
private readonly Dictionary<ICommonSession, List<ServerRoleBanDef>> _cachedRoleBans = new();
|
||||
private readonly Dictionary<NetUserId, HashSet<ServerRoleBanDef>> _cachedRoleBans = new();
|
||||
// Cached ban exemption flags are used to handle
|
||||
private readonly Dictionary<ICommonSession, ServerBanExemptFlags> _cachedBanExemptions = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
|
||||
_netManager.RegisterNetMessage<MsgRoleBans>();
|
||||
|
||||
_db.SubscribeToNotifications(OnDatabaseNotification);
|
||||
@@ -61,23 +63,12 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
|
||||
private async Task CachePlayerData(ICommonSession player, CancellationToken cancel)
|
||||
{
|
||||
// Yeah so role ban loading code isn't integrated with exempt flag loading code.
|
||||
// Have you seen how garbage role ban code code is? I don't feel like refactoring it right now.
|
||||
|
||||
var flags = await _db.GetBanExemption(player.UserId, cancel);
|
||||
|
||||
var netChannel = player.Channel;
|
||||
ImmutableArray<byte>? hwId = netChannel.UserData.HWId.Length == 0 ? null : netChannel.UserData.HWId;
|
||||
var roleBans = await _db.GetServerRoleBansAsync(netChannel.RemoteEndPoint.Address, player.UserId, hwId, false);
|
||||
|
||||
var userRoleBans = new List<ServerRoleBanDef>();
|
||||
foreach (var ban in roleBans)
|
||||
{
|
||||
userRoleBans.Add(ban);
|
||||
}
|
||||
|
||||
cancel.ThrowIfCancellationRequested();
|
||||
_cachedBanExemptions[player] = flags;
|
||||
_cachedRoleBans[player] = userRoleBans;
|
||||
|
||||
SendRoleBans(player);
|
||||
}
|
||||
|
||||
private void ClearPlayerData(ICommonSession player)
|
||||
@@ -85,15 +76,25 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
_cachedBanExemptions.Remove(player);
|
||||
}
|
||||
|
||||
private async void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
||||
{
|
||||
if (e.NewStatus != SessionStatus.Connected || _cachedRoleBans.ContainsKey(e.Session.UserId))
|
||||
return;
|
||||
|
||||
var netChannel = e.Session.Channel;
|
||||
ImmutableArray<byte>? hwId = netChannel.UserData.HWId.Length == 0 ? null : netChannel.UserData.HWId;
|
||||
await CacheDbRoleBans(e.Session.UserId, netChannel.RemoteEndPoint.Address, hwId);
|
||||
|
||||
SendRoleBans(e.Session);
|
||||
}
|
||||
|
||||
private async Task<bool> AddRoleBan(ServerRoleBanDef banDef)
|
||||
{
|
||||
banDef = await _db.AddServerRoleBanAsync(banDef);
|
||||
|
||||
if (banDef.UserId != null
|
||||
&& _playerManager.TryGetSessionById(banDef.UserId, out var player)
|
||||
&& _cachedRoleBans.TryGetValue(player, out var cachedBans))
|
||||
if (banDef.UserId != null)
|
||||
{
|
||||
cachedBans.Add(banDef);
|
||||
_cachedRoleBans.GetOrNew(banDef.UserId.Value).Add(banDef);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -101,21 +102,31 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
|
||||
public HashSet<string>? GetRoleBans(NetUserId playerUserId)
|
||||
{
|
||||
if (!_playerManager.TryGetSessionById(playerUserId, out var session))
|
||||
return null;
|
||||
|
||||
return _cachedRoleBans.TryGetValue(session, out var roleBans)
|
||||
return _cachedRoleBans.TryGetValue(playerUserId, out var roleBans)
|
||||
? roleBans.Select(banDef => banDef.Role).ToHashSet()
|
||||
: null;
|
||||
}
|
||||
|
||||
private async Task CacheDbRoleBans(NetUserId userId, IPAddress? address = null, ImmutableArray<byte>? hwId = null)
|
||||
{
|
||||
var roleBans = await _db.GetServerRoleBansAsync(address, userId, hwId, false);
|
||||
|
||||
var userRoleBans = new HashSet<ServerRoleBanDef>();
|
||||
foreach (var ban in roleBans)
|
||||
{
|
||||
userRoleBans.Add(ban);
|
||||
}
|
||||
|
||||
_cachedRoleBans[userId] = userRoleBans;
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
// Clear out players that have disconnected.
|
||||
var toRemove = new ValueList<ICommonSession>();
|
||||
var toRemove = new List<NetUserId>();
|
||||
foreach (var player in _cachedRoleBans.Keys)
|
||||
{
|
||||
if (player.Status == SessionStatus.Disconnected)
|
||||
if (!_playerManager.TryGetSessionById(player, out _))
|
||||
toRemove.Add(player);
|
||||
}
|
||||
|
||||
@@ -127,7 +138,7 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
// Check for expired bans
|
||||
foreach (var roleBans in _cachedRoleBans.Values)
|
||||
{
|
||||
roleBans.RemoveAll(ban => DateTimeOffset.Now > ban.ExpirationTime);
|
||||
roleBans.RemoveWhere(ban => DateTimeOffset.Now > ban.ExpirationTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,9 +281,9 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
var length = expires == null ? Loc.GetString("cmd-roleban-inf") : Loc.GetString("cmd-roleban-until", ("expires", expires));
|
||||
_chat.SendAdminAlert(Loc.GetString("cmd-roleban-success", ("target", targetUsername ?? "null"), ("role", role), ("reason", reason), ("length", length)));
|
||||
|
||||
if (target != null && _playerManager.TryGetSessionById(target.Value, out var session))
|
||||
if (target != null)
|
||||
{
|
||||
SendRoleBans(session);
|
||||
SendRoleBans(target.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,12 +311,10 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
|
||||
await _db.AddServerRoleUnbanAsync(new ServerRoleUnbanDef(banId, unbanningAdmin, DateTimeOffset.Now));
|
||||
|
||||
if (ban.UserId is { } player
|
||||
&& _playerManager.TryGetSessionById(player, out var session)
|
||||
&& _cachedRoleBans.TryGetValue(session, out var roleBans))
|
||||
if (ban.UserId is { } player && _cachedRoleBans.TryGetValue(player, out var roleBans))
|
||||
{
|
||||
roleBans.RemoveAll(roleBan => roleBan.Id == ban.Id);
|
||||
SendRoleBans(session);
|
||||
roleBans.RemoveWhere(roleBan => roleBan.Id == ban.Id);
|
||||
SendRoleBans(player);
|
||||
}
|
||||
|
||||
return $"Pardoned ban with id {banId}";
|
||||
@@ -313,12 +322,8 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
|
||||
public HashSet<ProtoId<JobPrototype>>? GetJobBans(NetUserId playerUserId)
|
||||
{
|
||||
if (!_playerManager.TryGetSessionById(playerUserId, out var session))
|
||||
if (!_cachedRoleBans.TryGetValue(playerUserId, out var roleBans))
|
||||
return null;
|
||||
|
||||
if (!_cachedRoleBans.TryGetValue(session, out var roleBans))
|
||||
return null;
|
||||
|
||||
return roleBans
|
||||
.Where(ban => ban.Role.StartsWith(JobPrefix, StringComparison.Ordinal))
|
||||
.Select(ban => new ProtoId<JobPrototype>(ban.Role[JobPrefix.Length..]))
|
||||
@@ -326,9 +331,19 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void SendRoleBans(NetUserId userId)
|
||||
{
|
||||
if (!_playerManager.TryGetSessionById(userId, out var player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SendRoleBans(player);
|
||||
}
|
||||
|
||||
public void SendRoleBans(ICommonSession pSession)
|
||||
{
|
||||
var roleBans = _cachedRoleBans.GetValueOrDefault(pSession) ?? new List<ServerRoleBanDef>();
|
||||
var roleBans = _cachedRoleBans.GetValueOrDefault(pSession.UserId) ?? new HashSet<ServerRoleBanDef>();
|
||||
var bans = new MsgRoleBans()
|
||||
{
|
||||
Bans = roleBans.Select(o => o.Role).ToList()
|
||||
|
||||
@@ -47,6 +47,12 @@ public interface IBanManager
|
||||
/// <param name="unbanTime">The time at which this role ban was pardoned.</param>
|
||||
public Task<string> PardonRoleBan(int banId, NetUserId? unbanningAdmin, DateTimeOffset unbanTime);
|
||||
|
||||
/// <summary>
|
||||
/// Sends role bans to the target
|
||||
/// </summary>
|
||||
/// <param name="pSession">Player's user ID</param>
|
||||
public void SendRoleBans(NetUserId userId);
|
||||
|
||||
/// <summary>
|
||||
/// Sends role bans to the target
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server._CP14.Roles;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Antag;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
@@ -53,23 +52,6 @@ public sealed partial class AdminVerbSystem
|
||||
|
||||
var targetPlayer = targetActor.PlayerSession;
|
||||
|
||||
|
||||
Verb CP14Sociopath = new()
|
||||
{
|
||||
Text = Loc.GetString("cp14-admin-verb-text-make-sociopath"),
|
||||
Category = VerbCategory.Antag,
|
||||
Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Clothing/Hands/Gloves/Color/black.rsi"),
|
||||
"icon"), //TODO
|
||||
Act = () =>
|
||||
{
|
||||
//_antag.ForceMakeAntag<CP14BanditRoleComponent>(targetPlayer, "CP14Bandit"); //TODO
|
||||
},
|
||||
Impact = LogImpact.High,
|
||||
Message = Loc.GetString("cp14-admin-verb-make-sociopath"),
|
||||
};
|
||||
args.Verbs.Add(CP14Sociopath);
|
||||
|
||||
/* CP14 disable default antags
|
||||
Verb traitor = new()
|
||||
{
|
||||
Text = Loc.GetString("admin-verb-text-make-traitor"),
|
||||
@@ -169,6 +151,5 @@ public sealed partial class AdminVerbSystem
|
||||
Message = Loc.GetString("admin-verb-make-thief"),
|
||||
};
|
||||
args.Verbs.Add(thief);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +95,9 @@ public sealed partial class AdminVerbSystem
|
||||
if (HasComp<MapComponent>(args.Target) || HasComp<MapGridComponent>(args.Target))
|
||||
return;
|
||||
|
||||
var explodeName = Loc.GetString("admin-smite-explode-name").ToLowerInvariant();
|
||||
Verb explode = new()
|
||||
{
|
||||
Text = explodeName,
|
||||
Text = "admin-smite-explode-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/smite.svg.192dpi.png")),
|
||||
Act = () =>
|
||||
@@ -112,14 +111,13 @@ public sealed partial class AdminVerbSystem
|
||||
_bodySystem.GibBody(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", explodeName, Loc.GetString("admin-smite-explode-description")) // we do this so the description tells admins the Text to run it via console.
|
||||
Message = Loc.GetString("admin-smite-explode-description")
|
||||
};
|
||||
args.Verbs.Add(explode);
|
||||
|
||||
var chessName = Loc.GetString("admin-smite-chess-dimension-name").ToLowerInvariant();
|
||||
Verb chess = new()
|
||||
{
|
||||
Text = chessName,
|
||||
Text = "admin-smite-chess-dimension-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Fun/Tabletop/chessboard.rsi"), "chessboard"),
|
||||
Act = () =>
|
||||
@@ -139,13 +137,12 @@ public sealed partial class AdminVerbSystem
|
||||
xform.WorldRotation = Angle.Zero;
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", chessName, Loc.GetString("admin-smite-chess-dimension-description"))
|
||||
Message = Loc.GetString("admin-smite-chess-dimension-description")
|
||||
};
|
||||
args.Verbs.Add(chess);
|
||||
|
||||
if (TryComp<FlammableComponent>(args.Target, out var flammable))
|
||||
{
|
||||
var flamesName = Loc.GetString("admin-smite-set-alight-name").ToLowerInvariant();
|
||||
Verb flames = new()
|
||||
{
|
||||
Text = "admin-smite-set-alight-name",
|
||||
@@ -163,15 +160,14 @@ public sealed partial class AdminVerbSystem
|
||||
Filter.PvsExcept(args.Target), true, PopupType.MediumCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", flamesName, Loc.GetString("admin-smite-set-alight-description"))
|
||||
Message = Loc.GetString("admin-smite-set-alight-description")
|
||||
};
|
||||
args.Verbs.Add(flames);
|
||||
}
|
||||
|
||||
var monkeyName = Loc.GetString("admin-smite-monkeyify-name").ToLowerInvariant();
|
||||
Verb monkey = new()
|
||||
{
|
||||
Text = monkeyName,
|
||||
Text = "admin-smite-monkeyify-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Mobs/Animals/monkey.rsi"), "monkey"),
|
||||
Act = () =>
|
||||
@@ -179,14 +175,13 @@ public sealed partial class AdminVerbSystem
|
||||
_polymorphSystem.PolymorphEntity(args.Target, "AdminMonkeySmite");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", monkeyName, Loc.GetString("admin-smite-monkeyify-description"))
|
||||
Message = Loc.GetString("admin-smite-monkeyify-description")
|
||||
};
|
||||
args.Verbs.Add(monkey);
|
||||
|
||||
var disposalBinName = Loc.GetString("admin-smite-garbage-can-name").ToLowerInvariant();
|
||||
Verb disposalBin = new()
|
||||
{
|
||||
Text = disposalBinName,
|
||||
Text = "admin-smite-electrocute-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Structures/Piping/disposal.rsi"), "disposal"),
|
||||
Act = () =>
|
||||
@@ -194,17 +189,16 @@ public sealed partial class AdminVerbSystem
|
||||
_polymorphSystem.PolymorphEntity(args.Target, "AdminDisposalsSmite");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", disposalBinName, Loc.GetString("admin-smite-garbage-can-description"))
|
||||
Message = Loc.GetString("admin-smite-garbage-can-description")
|
||||
};
|
||||
args.Verbs.Add(disposalBin);
|
||||
|
||||
if (TryComp<DamageableComponent>(args.Target, out var damageable) &&
|
||||
HasComp<MobStateComponent>(args.Target))
|
||||
{
|
||||
var hardElectrocuteName = Loc.GetString("admin-smite-electrocute-name").ToLowerInvariant();
|
||||
Verb hardElectrocute = new()
|
||||
{
|
||||
Text = hardElectrocuteName,
|
||||
Text = "admin-smite-creampie-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Clothing/Hands/Gloves/Color/yellow.rsi"), "icon"),
|
||||
Act = () =>
|
||||
@@ -240,17 +234,16 @@ public sealed partial class AdminVerbSystem
|
||||
TimeSpan.FromSeconds(30), refresh: true, ignoreInsulation: true);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", hardElectrocuteName, Loc.GetString("admin-smite-electrocute-description"))
|
||||
Message = Loc.GetString("admin-smite-electrocute-description")
|
||||
};
|
||||
args.Verbs.Add(hardElectrocute);
|
||||
}
|
||||
|
||||
if (TryComp<CreamPiedComponent>(args.Target, out var creamPied))
|
||||
{
|
||||
var creamPieName = Loc.GetString("admin-smite-creampie-name").ToLowerInvariant();
|
||||
Verb creamPie = new()
|
||||
{
|
||||
Text = creamPieName,
|
||||
Text = "admin-smite-remove-blood-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Consumable/Food/Baked/pie.rsi"), "plain-slice"),
|
||||
Act = () =>
|
||||
@@ -258,17 +251,16 @@ public sealed partial class AdminVerbSystem
|
||||
_creamPieSystem.SetCreamPied(args.Target, creamPied, true);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", creamPieName, Loc.GetString("admin-smite-creampie-description"))
|
||||
Message = Loc.GetString("admin-smite-creampie-description")
|
||||
};
|
||||
args.Verbs.Add(creamPie);
|
||||
}
|
||||
|
||||
if (TryComp<BloodstreamComponent>(args.Target, out var bloodstream))
|
||||
{
|
||||
var bloodRemovalName = Loc.GetString("admin-smite-remove-blood-name").ToLowerInvariant();
|
||||
Verb bloodRemoval = new()
|
||||
{
|
||||
Text = bloodRemovalName,
|
||||
Text = "admin-smite-vomit-organs-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Fluids/tomato_splat.rsi"), "puddle-1"),
|
||||
Act = () =>
|
||||
@@ -281,7 +273,7 @@ public sealed partial class AdminVerbSystem
|
||||
Filter.PvsExcept(args.Target), true, PopupType.MediumCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", bloodRemovalName, Loc.GetString("admin-smite-remove-blood-description"))
|
||||
Message = Loc.GetString("admin-smite-remove-blood-description")
|
||||
};
|
||||
args.Verbs.Add(bloodRemoval);
|
||||
}
|
||||
@@ -289,10 +281,9 @@ public sealed partial class AdminVerbSystem
|
||||
// bobby...
|
||||
if (TryComp<BodyComponent>(args.Target, out var body))
|
||||
{
|
||||
var vomitOrgansName = Loc.GetString("admin-smite-vomit-organs-name").ToLowerInvariant();
|
||||
Verb vomitOrgans = new()
|
||||
{
|
||||
Text = vomitOrgansName,
|
||||
Text = "admin-smite-remove-hands-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new("/Textures/Fluids/vomit_toxin.rsi"), "vomit_toxin-1"),
|
||||
Act = () =>
|
||||
@@ -314,14 +305,13 @@ public sealed partial class AdminVerbSystem
|
||||
Filter.PvsExcept(args.Target), true, PopupType.MediumCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", vomitOrgansName, Loc.GetString("admin-smite-vomit-organs-description"))
|
||||
Message = Loc.GetString("admin-smite-vomit-organs-description")
|
||||
};
|
||||
args.Verbs.Add(vomitOrgans);
|
||||
|
||||
var handsRemovalName = Loc.GetString("admin-smite-remove-hands-name").ToLowerInvariant();
|
||||
Verb handsRemoval = new()
|
||||
{
|
||||
Text = handsRemovalName,
|
||||
Text = "admin-smite-remove-hand-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/AdminActions/remove-hands.png")),
|
||||
Act = () =>
|
||||
@@ -337,14 +327,13 @@ public sealed partial class AdminVerbSystem
|
||||
Filter.PvsExcept(args.Target), true, PopupType.Medium);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", handsRemovalName, Loc.GetString("admin-smite-remove-hands-description"))
|
||||
Message = Loc.GetString("admin-smite-remove-hands-description")
|
||||
};
|
||||
args.Verbs.Add(handsRemoval);
|
||||
|
||||
var handRemovalName = Loc.GetString("admin-smite-remove-hand-name").ToLowerInvariant();
|
||||
Verb handRemoval = new()
|
||||
{
|
||||
Text = handRemovalName,
|
||||
Text = "admin-smite-pinball-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/AdminActions/remove-hand.png")),
|
||||
Act = () =>
|
||||
@@ -361,14 +350,13 @@ public sealed partial class AdminVerbSystem
|
||||
Filter.PvsExcept(args.Target), true, PopupType.Medium);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", handRemovalName, Loc.GetString("admin-smite-remove-hand-description"))
|
||||
Message = Loc.GetString("admin-smite-remove-hand-description")
|
||||
};
|
||||
args.Verbs.Add(handRemoval);
|
||||
|
||||
var stomachRemovalName = Loc.GetString("admin-smite-stomach-removal-name").ToLowerInvariant();
|
||||
Verb stomachRemoval = new()
|
||||
{
|
||||
Text = stomachRemovalName,
|
||||
Text = "admin-smite-yeet-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Mobs/Species/Human/organs.rsi"), "stomach"),
|
||||
Act = () =>
|
||||
@@ -382,14 +370,13 @@ public sealed partial class AdminVerbSystem
|
||||
args.Target, PopupType.LargeCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", stomachRemovalName, Loc.GetString("admin-smite-stomach-removal-description"))
|
||||
Message = Loc.GetString("admin-smite-stomach-removal-description"),
|
||||
};
|
||||
args.Verbs.Add(stomachRemoval);
|
||||
|
||||
var lungRemovalName = Loc.GetString("admin-smite-lung-removal-name").ToLowerInvariant();
|
||||
Verb lungRemoval = new()
|
||||
{
|
||||
Text = lungRemovalName,
|
||||
Text = "admin-smite-become-bread-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Mobs/Species/Human/organs.rsi"), "lung-r"),
|
||||
Act = () =>
|
||||
@@ -403,17 +390,16 @@ public sealed partial class AdminVerbSystem
|
||||
args.Target, PopupType.LargeCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", lungRemovalName, Loc.GetString("admin-smite-lung-removal-description"))
|
||||
Message = Loc.GetString("admin-smite-lung-removal-description"),
|
||||
};
|
||||
args.Verbs.Add(lungRemoval);
|
||||
}
|
||||
|
||||
if (TryComp<PhysicsComponent>(args.Target, out var physics))
|
||||
{
|
||||
var pinballName = Loc.GetString("admin-smite-pinball-name").ToLowerInvariant();
|
||||
Verb pinball = new()
|
||||
{
|
||||
Text = pinballName,
|
||||
Text = "admin-smite-ghostkick-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Fun/toys.rsi"), "basketball"),
|
||||
Act = () =>
|
||||
@@ -441,14 +427,13 @@ public sealed partial class AdminVerbSystem
|
||||
_physics.SetAngularDamping(args.Target, physics, 0f);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", pinballName, Loc.GetString("admin-smite-pinball-description"))
|
||||
Message = Loc.GetString("admin-smite-pinball-description")
|
||||
};
|
||||
args.Verbs.Add(pinball);
|
||||
|
||||
var yeetName = Loc.GetString("admin-smite-yeet-name").ToLowerInvariant();
|
||||
Verb yeet = new()
|
||||
{
|
||||
Text = yeetName,
|
||||
Text = "admin-smite-nyanify-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/eject.svg.192dpi.png")),
|
||||
Act = () =>
|
||||
@@ -472,12 +457,11 @@ public sealed partial class AdminVerbSystem
|
||||
_physics.SetAngularDamping(args.Target, physics, 0f);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", yeetName, Loc.GetString("admin-smite-yeet-description"))
|
||||
Message = Loc.GetString("admin-smite-yeet-description")
|
||||
};
|
||||
args.Verbs.Add(yeet);
|
||||
}
|
||||
|
||||
var breadName = Loc.GetString("admin-smite-become-bread-name").ToLowerInvariant(); // Will I get cancelled for breadName-ing you?
|
||||
Verb bread = new()
|
||||
{
|
||||
Text = "admin-smite-kill-sign-name",
|
||||
@@ -488,11 +472,10 @@ public sealed partial class AdminVerbSystem
|
||||
_polymorphSystem.PolymorphEntity(args.Target, "AdminBreadSmite");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", breadName, Loc.GetString("admin-smite-become-bread-description"))
|
||||
Message = Loc.GetString("admin-smite-become-bread-description")
|
||||
};
|
||||
args.Verbs.Add(bread);
|
||||
|
||||
var mouseName = Loc.GetString("admin-smite-become-mouse-name").ToLowerInvariant();
|
||||
Verb mouse = new()
|
||||
{
|
||||
Text = "admin-smite-cluwne-name",
|
||||
@@ -503,16 +486,15 @@ public sealed partial class AdminVerbSystem
|
||||
_polymorphSystem.PolymorphEntity(args.Target, "AdminMouseSmite");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", mouseName, Loc.GetString("admin-smite-become-mouse-description"))
|
||||
Message = Loc.GetString("admin-smite-become-mouse-description")
|
||||
};
|
||||
args.Verbs.Add(mouse);
|
||||
|
||||
if (TryComp<ActorComponent>(args.Target, out var actorComponent))
|
||||
{
|
||||
var ghostKickName = Loc.GetString("admin-smite-ghostkick-name").ToLowerInvariant();
|
||||
Verb ghostKick = new()
|
||||
{
|
||||
Text = ghostKickName,
|
||||
Text = "admin-smite-anger-pointing-arrows-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/gavel.svg.192dpi.png")),
|
||||
Act = () =>
|
||||
@@ -520,18 +502,15 @@ public sealed partial class AdminVerbSystem
|
||||
_ghostKickManager.DoDisconnect(actorComponent.PlayerSession.Channel, "Smitten.");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", ghostKickName, Loc.GetString("admin-smite-ghostkick-description"))
|
||||
|
||||
Message = Loc.GetString("admin-smite-ghostkick-description")
|
||||
};
|
||||
args.Verbs.Add(ghostKick);
|
||||
}
|
||||
|
||||
if (TryComp<InventoryComponent>(args.Target, out var inventory))
|
||||
{
|
||||
var nyanifyName = Loc.GetString("admin-smite-nyanify-name").ToLowerInvariant();
|
||||
if (TryComp<InventoryComponent>(args.Target, out var inventory)) {
|
||||
Verb nyanify = new()
|
||||
{
|
||||
Text = nyanifyName,
|
||||
Text = "admin-smite-dust-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Clothing/Head/Hats/catears.rsi"), "icon"),
|
||||
Act = () =>
|
||||
@@ -542,14 +521,13 @@ public sealed partial class AdminVerbSystem
|
||||
_inventorySystem.TryEquip(args.Target, ears, "head", true, true, false, inventory);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", nyanifyName, Loc.GetString("admin-smite-nyanify-description"))
|
||||
Message = Loc.GetString("admin-smite-nyanify-description")
|
||||
};
|
||||
args.Verbs.Add(nyanify);
|
||||
|
||||
var killSignName = Loc.GetString("admin-smite-kill-sign-name").ToLowerInvariant();
|
||||
Verb killSign = new()
|
||||
{
|
||||
Text = killSignName,
|
||||
Text = "admin-smite-buffering-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Misc/killsign.rsi"), "icon"),
|
||||
Act = () =>
|
||||
@@ -557,14 +535,13 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<KillSignComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", killSignName, Loc.GetString("admin-smite-kill-sign-description"))
|
||||
Message = Loc.GetString("admin-smite-kill-sign-description")
|
||||
};
|
||||
args.Verbs.Add(killSign);
|
||||
|
||||
var cluwneName = Loc.GetString("admin-smite-cluwne-name").ToLowerInvariant();
|
||||
Verb cluwne = new()
|
||||
{
|
||||
Text = cluwneName,
|
||||
Text = "admin-smite-become-instrument-name",
|
||||
Category = VerbCategory.Smite,
|
||||
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Clothing/Mask/cluwne.rsi"), "icon"),
|
||||
@@ -574,14 +551,13 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<CluwneComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", cluwneName, Loc.GetString("admin-smite-cluwne-description"))
|
||||
Message = Loc.GetString("admin-smite-cluwne-description")
|
||||
};
|
||||
args.Verbs.Add(cluwne);
|
||||
|
||||
var maidenName = Loc.GetString("admin-smite-maid-name").ToLowerInvariant();
|
||||
Verb maiden = new()
|
||||
{
|
||||
Text = maidenName,
|
||||
Text = "admin-smite-remove-gravity-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Clothing/Uniforms/Jumpskirt/janimaid.rsi"), "icon"),
|
||||
Act = () =>
|
||||
@@ -594,15 +570,14 @@ public sealed partial class AdminVerbSystem
|
||||
});
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", maidenName, Loc.GetString("admin-smite-maid-description"))
|
||||
Message = Loc.GetString("admin-smite-maid-description")
|
||||
};
|
||||
args.Verbs.Add(maiden);
|
||||
}
|
||||
|
||||
var angerPointingArrowsName = Loc.GetString("admin-smite-anger-pointing-arrows-name").ToLowerInvariant();
|
||||
Verb angerPointingArrows = new()
|
||||
{
|
||||
Text = angerPointingArrowsName,
|
||||
Text = "admin-smite-reptilian-species-swap-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Interface/Misc/pointing.rsi"), "pointing"),
|
||||
Act = () =>
|
||||
@@ -610,14 +585,13 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<PointingArrowAngeringComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", angerPointingArrowsName, Loc.GetString("admin-smite-anger-pointing-arrows-description"))
|
||||
Message = Loc.GetString("admin-smite-anger-pointing-arrows-description")
|
||||
};
|
||||
args.Verbs.Add(angerPointingArrows);
|
||||
|
||||
var dustName = Loc.GetString("admin-smite-dust-name").ToLowerInvariant();
|
||||
Verb dust = new()
|
||||
{
|
||||
Text = dustName,
|
||||
Text = "admin-smite-locker-stuff-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Materials/materials.rsi"), "ash"),
|
||||
Act = () =>
|
||||
@@ -627,14 +601,13 @@ public sealed partial class AdminVerbSystem
|
||||
_popupSystem.PopupEntity(Loc.GetString("admin-smite-turned-ash-other", ("name", args.Target)), args.Target, PopupType.LargeCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", dustName, Loc.GetString("admin-smite-dust-description"))
|
||||
Message = Loc.GetString("admin-smite-dust-description"),
|
||||
};
|
||||
args.Verbs.Add(dust);
|
||||
|
||||
var youtubeVideoSimulationName = Loc.GetString("admin-smite-buffering-name").ToLowerInvariant();
|
||||
Verb youtubeVideoSimulation = new()
|
||||
{
|
||||
Text = youtubeVideoSimulationName,
|
||||
Text = "admin-smite-headstand-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/Misc/buffering_smite_icon.png")),
|
||||
Act = () =>
|
||||
@@ -642,11 +615,10 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<BufferingComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", youtubeVideoSimulationName, Loc.GetString("admin-smite-buffering-description"))
|
||||
Message = Loc.GetString("admin-smite-buffering-description"),
|
||||
};
|
||||
args.Verbs.Add(youtubeVideoSimulation);
|
||||
|
||||
var instrumentationName = Loc.GetString("admin-smite-become-instrument-name").ToLowerInvariant();
|
||||
Verb instrumentation = new()
|
||||
{
|
||||
Text = "admin-smite-become-mouse-name",
|
||||
@@ -657,14 +629,13 @@ public sealed partial class AdminVerbSystem
|
||||
_polymorphSystem.PolymorphEntity(args.Target, "AdminInstrumentSmite");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", instrumentationName, Loc.GetString("admin-smite-become-instrument-description"))
|
||||
Message = Loc.GetString("admin-smite-become-instrument-description"),
|
||||
};
|
||||
args.Verbs.Add(instrumentation);
|
||||
|
||||
var noGravityName = Loc.GetString("admin-smite-remove-gravity-name").ToLowerInvariant();
|
||||
Verb noGravity = new()
|
||||
{
|
||||
Text = noGravityName,
|
||||
Text = "admin-smite-maid-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new("/Textures/Structures/Machines/gravity_generator.rsi"), "off"),
|
||||
Act = () =>
|
||||
@@ -675,14 +646,13 @@ public sealed partial class AdminVerbSystem
|
||||
Dirty(args.Target, grav);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", noGravityName, Loc.GetString("admin-smite-remove-gravity-description"))
|
||||
Message = Loc.GetString("admin-smite-remove-gravity-description"),
|
||||
};
|
||||
args.Verbs.Add(noGravity);
|
||||
|
||||
var reptilianName = Loc.GetString("admin-smite-reptilian-species-swap-name").ToLowerInvariant();
|
||||
Verb reptilian = new()
|
||||
{
|
||||
Text = reptilianName,
|
||||
Text = "admin-smite-zoom-in-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Objects/Fun/toys.rsi"), "plushie_lizard"),
|
||||
Act = () =>
|
||||
@@ -690,14 +660,13 @@ public sealed partial class AdminVerbSystem
|
||||
_polymorphSystem.PolymorphEntity(args.Target, "AdminLizardSmite");
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", reptilianName, Loc.GetString("admin-smite-reptilian-species-swap-description"))
|
||||
Message = Loc.GetString("admin-smite-reptilian-species-swap-description"),
|
||||
};
|
||||
args.Verbs.Add(reptilian);
|
||||
|
||||
var lockerName = Loc.GetString("admin-smite-locker-stuff-name").ToLowerInvariant();
|
||||
Verb locker = new()
|
||||
{
|
||||
Text = lockerName,
|
||||
Text = "admin-smite-flip-eye-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new ("/Textures/Structures/Storage/closet.rsi"), "generic"),
|
||||
Act = () =>
|
||||
@@ -713,11 +682,10 @@ public sealed partial class AdminVerbSystem
|
||||
_weldableSystem.SetWeldedState(locker, true);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", lockerName, Loc.GetString("admin-smite-locker-stuff-description"))
|
||||
Message = Loc.GetString("admin-smite-locker-stuff-description"),
|
||||
};
|
||||
args.Verbs.Add(locker);
|
||||
|
||||
var headstandName = Loc.GetString("admin-smite-headstand-name").ToLowerInvariant();
|
||||
Verb headstand = new()
|
||||
{
|
||||
Text = "admin-smite-run-walk-swap-name",
|
||||
@@ -728,14 +696,13 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<HeadstandComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", headstandName, Loc.GetString("admin-smite-headstand-description"))
|
||||
Message = Loc.GetString("admin-smite-headstand-description"),
|
||||
};
|
||||
args.Verbs.Add(headstand);
|
||||
|
||||
var zoomInName = Loc.GetString("admin-smite-zoom-in-name").ToLowerInvariant();
|
||||
Verb zoomIn = new()
|
||||
{
|
||||
Text = zoomInName,
|
||||
Text = "admin-smite-super-speed-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/AdminActions/zoom.png")),
|
||||
Act = () =>
|
||||
@@ -744,14 +711,13 @@ public sealed partial class AdminVerbSystem
|
||||
_eyeSystem.SetZoom(args.Target, eye.TargetZoom * 0.2f, ignoreLimits: true);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", zoomInName, Loc.GetString("admin-smite-zoom-in-description"))
|
||||
Message = Loc.GetString("admin-smite-zoom-in-description"),
|
||||
};
|
||||
args.Verbs.Add(zoomIn);
|
||||
|
||||
var flipEyeName = Loc.GetString("admin-smite-flip-eye-name").ToLowerInvariant();
|
||||
Verb flipEye = new()
|
||||
{
|
||||
Text = flipEyeName,
|
||||
Text = "admin-smite-stomach-removal-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/AdminActions/flip.png")),
|
||||
Act = () =>
|
||||
@@ -760,14 +726,13 @@ public sealed partial class AdminVerbSystem
|
||||
_eyeSystem.SetZoom(args.Target, eye.TargetZoom * -1, ignoreLimits: true);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", flipEyeName, Loc.GetString("admin-smite-flip-eye-description"))
|
||||
Message = Loc.GetString("admin-smite-flip-eye-description"),
|
||||
};
|
||||
args.Verbs.Add(flipEye);
|
||||
|
||||
var runWalkSwapName = Loc.GetString("admin-smite-run-walk-swap-name").ToLowerInvariant();
|
||||
Verb runWalkSwap = new()
|
||||
{
|
||||
Text = runWalkSwapName,
|
||||
Text = "admin-smite-speak-backwards-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/AdminActions/run-walk-swap.png")),
|
||||
Act = () =>
|
||||
@@ -781,14 +746,13 @@ public sealed partial class AdminVerbSystem
|
||||
args.Target, PopupType.LargeCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", runWalkSwapName, Loc.GetString("admin-smite-run-walk-swap-description"))
|
||||
Message = Loc.GetString("admin-smite-run-walk-swap-description"),
|
||||
};
|
||||
args.Verbs.Add(runWalkSwap);
|
||||
|
||||
var backwardsAccentName = Loc.GetString("admin-smite-speak-backwards-name").ToLowerInvariant();
|
||||
Verb backwardsAccent = new()
|
||||
{
|
||||
Text = backwardsAccentName,
|
||||
Text = "admin-smite-lung-removal-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/AdminActions/help-backwards.png")),
|
||||
Act = () =>
|
||||
@@ -796,14 +760,13 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<BackwardsAccentComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", backwardsAccentName, Loc.GetString("admin-smite-speak-backwards-description"))
|
||||
Message = Loc.GetString("admin-smite-speak-backwards-description"),
|
||||
};
|
||||
args.Verbs.Add(backwardsAccent);
|
||||
|
||||
var disarmProneName = Loc.GetString("admin-smite-disarm-prone-name").ToLowerInvariant();
|
||||
Verb disarmProne = new()
|
||||
{
|
||||
Text = disarmProneName,
|
||||
Text = "admin-smite-disarm-prone-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/Actions/disarm.png")),
|
||||
Act = () =>
|
||||
@@ -811,11 +774,10 @@ public sealed partial class AdminVerbSystem
|
||||
EnsureComp<DisarmProneComponent>(args.Target);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", disarmProneName, Loc.GetString("admin-smite-disarm-prone-description"))
|
||||
Message = Loc.GetString("admin-smite-disarm-prone-description"),
|
||||
};
|
||||
args.Verbs.Add(disarmProne);
|
||||
|
||||
var superSpeedName = Loc.GetString("admin-smite-super-speed-name").ToLowerInvariant();
|
||||
Verb superSpeed = new()
|
||||
{
|
||||
Text = "admin-smite-garbage-can-name",
|
||||
@@ -830,45 +792,41 @@ public sealed partial class AdminVerbSystem
|
||||
args.Target, PopupType.LargeCaution);
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", superSpeedName, Loc.GetString("admin-smite-super-speed-description"))
|
||||
Message = Loc.GetString("admin-smite-super-speed-description"),
|
||||
};
|
||||
args.Verbs.Add(superSpeed);
|
||||
|
||||
//Bonk
|
||||
var superBonkLiteName = Loc.GetString("admin-smite-super-bonk-lite-name").ToLowerInvariant();
|
||||
Verb superBonkLite = new()
|
||||
{
|
||||
Text = superBonkLiteName,
|
||||
Text = "admin-smite-super-bonk-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new("Structures/Furniture/Tables/glass.rsi"), "full"),
|
||||
Act = () =>
|
||||
{
|
||||
_superBonkSystem.StartSuperBonk(args.Target, stopWhenDead: true);
|
||||
},
|
||||
Message = Loc.GetString("admin-smite-super-bonk-lite-description"),
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", superBonkLiteName, Loc.GetString("admin-smite-super-bonk-lite-description"))
|
||||
};
|
||||
args.Verbs.Add(superBonkLite);
|
||||
|
||||
var superBonkName = Loc.GetString("admin-smite-super-bonk-name").ToLowerInvariant();
|
||||
Verb superBonk= new()
|
||||
{
|
||||
Text = superBonkName,
|
||||
Text = "admin-smite-super-bonk-lite-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new("Structures/Furniture/Tables/generic.rsi"), "full"),
|
||||
Act = () =>
|
||||
{
|
||||
_superBonkSystem.StartSuperBonk(args.Target);
|
||||
},
|
||||
Message = Loc.GetString("admin-smite-super-bonk-description"),
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", superBonkName, Loc.GetString("admin-smite-super-bonk-description"))
|
||||
};
|
||||
args.Verbs.Add(superBonk);
|
||||
|
||||
var superslipName = Loc.GetString("admin-smite-super-slip-name").ToLowerInvariant();
|
||||
Verb superslip = new()
|
||||
{
|
||||
Text = superslipName,
|
||||
Text = "admin-smite-super-slip-name",
|
||||
Category = VerbCategory.Smite,
|
||||
Icon = new SpriteSpecifier.Rsi(new("Objects/Specific/Janitorial/soap.rsi"), "omega-4"),
|
||||
Act = () =>
|
||||
@@ -888,7 +846,7 @@ public sealed partial class AdminVerbSystem
|
||||
}
|
||||
},
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = string.Join(": ", superslipName, Loc.GetString("admin-smite-super-slip-description"))
|
||||
Message = Loc.GetString("admin-smite-super-slip-description")
|
||||
};
|
||||
args.Verbs.Add(superslip);
|
||||
}
|
||||
|
||||
@@ -35,10 +35,8 @@ using Robust.Shared.Toolshed;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Linq;
|
||||
using Content.Server.Silicons.Laws;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Silicons.Laws.Components;
|
||||
using Robust.Server.Player;
|
||||
using Content.Shared.Silicons.StationAi;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using static Content.Shared.Configurable.ConfigurationComponent;
|
||||
|
||||
@@ -347,30 +345,7 @@ namespace Content.Server.Administration.Systems
|
||||
Impact = LogImpact.Low
|
||||
});
|
||||
|
||||
// This logic is needed to be able to modify the AI's laws through its core and eye.
|
||||
EntityUid? target = null;
|
||||
SiliconLawBoundComponent? lawBoundComponent = null;
|
||||
|
||||
if (TryComp(args.Target, out lawBoundComponent))
|
||||
{
|
||||
target = args.Target;
|
||||
}
|
||||
// When inspecting the core we can find the entity with its laws by looking at the AiHolderComponent.
|
||||
else if (TryComp<StationAiHolderComponent>(args.Target, out var holder) && holder.Slot.Item != null
|
||||
&& TryComp(holder.Slot.Item, out lawBoundComponent))
|
||||
{
|
||||
target = holder.Slot.Item.Value;
|
||||
// For the eye we can find the entity with its laws as the source of the movement relay since the eye
|
||||
// is just a proxy for it to move around and look around the station.
|
||||
}
|
||||
else if (TryComp<MovementRelayTargetComponent>(args.Target, out var relay)
|
||||
&& TryComp(relay.Source, out lawBoundComponent))
|
||||
{
|
||||
target = relay.Source;
|
||||
|
||||
}
|
||||
|
||||
if (lawBoundComponent != null && target != null)
|
||||
if (TryComp<SiliconLawBoundComponent>(args.Target, out var lawBoundComponent))
|
||||
{
|
||||
args.Verbs.Add(new Verb()
|
||||
{
|
||||
@@ -384,7 +359,7 @@ namespace Content.Server.Administration.Systems
|
||||
return;
|
||||
}
|
||||
_euiManager.OpenEui(ui, session);
|
||||
ui.UpdateLaws(lawBoundComponent, target.Value);
|
||||
ui.UpdateLaws(lawBoundComponent, args.Target);
|
||||
},
|
||||
Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Interface/Actions/actions_borg.rsi"), "state-laws"),
|
||||
});
|
||||
|
||||
@@ -47,23 +47,20 @@ namespace Content.Server.Administration.Systems
|
||||
[GeneratedRegex(@"^https://discord\.com/api/webhooks/(\d+)/((?!.*/).*)$")]
|
||||
private static partial Regex DiscordRegex();
|
||||
|
||||
private string _webhookUrl = string.Empty;
|
||||
private WebhookData? _webhookData;
|
||||
|
||||
private string _onCallUrl = string.Empty;
|
||||
private WebhookData? _onCallData;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
private readonly HttpClient _httpClient = new();
|
||||
|
||||
private string _webhookUrl = string.Empty;
|
||||
private WebhookData? _webhookData;
|
||||
private string _footerIconUrl = string.Empty;
|
||||
private string _avatarUrl = string.Empty;
|
||||
private string _serverName = string.Empty;
|
||||
|
||||
private readonly Dictionary<NetUserId, DiscordRelayInteraction> _relayMessages = new();
|
||||
private readonly
|
||||
Dictionary<NetUserId, (string? id, string username, string description, string? characterName, GameRunLevel
|
||||
lastRunLevel)> _relayMessages = new();
|
||||
|
||||
private Dictionary<NetUserId, string> _oldMessageIds = new();
|
||||
private readonly Dictionary<NetUserId, Queue<DiscordRelayedData>> _messageQueues = new();
|
||||
private readonly Dictionary<NetUserId, Queue<string>> _messageQueues = new();
|
||||
private readonly HashSet<NetUserId> _processingChannels = new();
|
||||
private readonly Dictionary<NetUserId, (TimeSpan Timestamp, bool Typing)> _typingUpdateTimestamps = new();
|
||||
private string _overrideClientName = string.Empty;
|
||||
@@ -85,16 +82,12 @@ namespace Content.Server.Administration.Systems
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Subs.CVar(_config, CCVars.DiscordOnCallWebhook, OnCallChanged, true);
|
||||
|
||||
Subs.CVar(_config, CCVars.DiscordAHelpWebhook, OnWebhookChanged, true);
|
||||
Subs.CVar(_config, CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged, true);
|
||||
Subs.CVar(_config, CCVars.DiscordAHelpAvatar, OnAvatarChanged, true);
|
||||
Subs.CVar(_config, CVars.GameHostName, OnServerNameChanged, true);
|
||||
Subs.CVar(_config, CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
|
||||
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
|
||||
|
||||
var defaultParams = new AHelpMessageParams(
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
@@ -103,7 +96,7 @@ namespace Content.Server.Administration.Systems
|
||||
_gameTicker.RunLevel,
|
||||
playedSound: false
|
||||
);
|
||||
_maxAdditionalChars = GenerateAHelpMessage(defaultParams).Message.Length;
|
||||
_maxAdditionalChars = GenerateAHelpMessage(defaultParams).Length;
|
||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
|
||||
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
|
||||
@@ -118,33 +111,6 @@ namespace Content.Server.Administration.Systems
|
||||
);
|
||||
}
|
||||
|
||||
private async void OnCallChanged(string url)
|
||||
{
|
||||
_onCallUrl = url;
|
||||
|
||||
if (url == string.Empty)
|
||||
return;
|
||||
|
||||
var match = DiscordRegex().Match(url);
|
||||
|
||||
if (!match.Success)
|
||||
{
|
||||
Log.Error("On call URL does not appear to be valid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (match.Groups.Count <= 2)
|
||||
{
|
||||
Log.Error("Could not get webhook ID or token for on call URL.");
|
||||
return;
|
||||
}
|
||||
|
||||
var webhookId = match.Groups[1].Value;
|
||||
var webhookToken = match.Groups[2].Value;
|
||||
|
||||
_onCallData = await GetWebhookData(webhookId, webhookToken);
|
||||
}
|
||||
|
||||
private void PlayerRateLimitedAction(ICommonSession obj)
|
||||
{
|
||||
RaiseNetworkEvent(
|
||||
@@ -293,13 +259,13 @@ namespace Content.Server.Administration.Systems
|
||||
|
||||
// Store the Discord message IDs of the previous round
|
||||
_oldMessageIds = new Dictionary<NetUserId, string>();
|
||||
foreach (var (user, interaction) in _relayMessages)
|
||||
foreach (var message in _relayMessages)
|
||||
{
|
||||
var id = interaction.Id;
|
||||
var id = message.Value.id;
|
||||
if (id == null)
|
||||
return;
|
||||
|
||||
_oldMessageIds[user] = id;
|
||||
_oldMessageIds[message.Key] = id;
|
||||
}
|
||||
|
||||
_relayMessages.Clear();
|
||||
@@ -364,10 +330,10 @@ namespace Content.Server.Administration.Systems
|
||||
var webhookToken = match.Groups[2].Value;
|
||||
|
||||
// Fire and forget
|
||||
_webhookData = await GetWebhookData(webhookId, webhookToken);
|
||||
await SetWebhookData(webhookId, webhookToken);
|
||||
}
|
||||
|
||||
private async Task<WebhookData?> GetWebhookData(string id, string token)
|
||||
private async Task SetWebhookData(string id, string token)
|
||||
{
|
||||
var response = await _httpClient.GetAsync($"https://discord.com/api/v10/webhooks/{id}/{token}");
|
||||
|
||||
@@ -376,10 +342,10 @@ namespace Content.Server.Administration.Systems
|
||||
{
|
||||
_sawmill.Log(LogLevel.Error,
|
||||
$"Discord returned bad status code when trying to get webhook data (perhaps the webhook URL is invalid?): {response.StatusCode}\nResponse: {content}");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<WebhookData>(content);
|
||||
_webhookData = JsonSerializer.Deserialize<WebhookData>(content);
|
||||
}
|
||||
|
||||
private void OnFooterIconChanged(string url)
|
||||
@@ -392,14 +358,14 @@ namespace Content.Server.Administration.Systems
|
||||
_avatarUrl = url;
|
||||
}
|
||||
|
||||
private async void ProcessQueue(NetUserId userId, Queue<DiscordRelayedData> messages)
|
||||
private async void ProcessQueue(NetUserId userId, Queue<string> messages)
|
||||
{
|
||||
// Whether an embed already exists for this player
|
||||
var exists = _relayMessages.TryGetValue(userId, out var existingEmbed);
|
||||
|
||||
// Whether the message will become too long after adding these new messages
|
||||
var tooLong = exists && messages.Sum(msg => Math.Min(msg.Message.Length, MessageLengthCap) + "\n".Length)
|
||||
+ existingEmbed?.Description.Length > DescriptionMax;
|
||||
var tooLong = exists && messages.Sum(msg => Math.Min(msg.Length, MessageLengthCap) + "\n".Length)
|
||||
+ existingEmbed.description.Length > DescriptionMax;
|
||||
|
||||
// If there is no existing embed, or it is getting too long, we create a new embed
|
||||
if (!exists || tooLong)
|
||||
@@ -419,10 +385,10 @@ namespace Content.Server.Administration.Systems
|
||||
// If we have all the data required, we can link to the embed of the previous round or embed that was too long
|
||||
if (_webhookData is { GuildId: { } guildId, ChannelId: { } channelId })
|
||||
{
|
||||
if (tooLong && existingEmbed?.Id != null)
|
||||
if (tooLong && existingEmbed.id != null)
|
||||
{
|
||||
linkToPrevious =
|
||||
$"**[Go to previous embed of this round](https://discord.com/channels/{guildId}/{channelId}/{existingEmbed.Id})**\n";
|
||||
$"**[Go to previous embed of this round](https://discord.com/channels/{guildId}/{channelId}/{existingEmbed.id})**\n";
|
||||
}
|
||||
else if (_oldMessageIds.TryGetValue(userId, out var id) && !string.IsNullOrEmpty(id))
|
||||
{
|
||||
@@ -432,22 +398,13 @@ namespace Content.Server.Administration.Systems
|
||||
}
|
||||
|
||||
var characterName = _minds.GetCharacterName(userId);
|
||||
existingEmbed = new DiscordRelayInteraction()
|
||||
{
|
||||
Id = null,
|
||||
CharacterName = characterName,
|
||||
Description = linkToPrevious,
|
||||
Username = lookup.Username,
|
||||
LastRunLevel = _gameTicker.RunLevel,
|
||||
};
|
||||
|
||||
_relayMessages[userId] = existingEmbed;
|
||||
existingEmbed = (null, lookup.Username, linkToPrevious, characterName, _gameTicker.RunLevel);
|
||||
}
|
||||
|
||||
// Previous message was in another RunLevel, so show that in the embed
|
||||
if (existingEmbed!.LastRunLevel != _gameTicker.RunLevel)
|
||||
if (existingEmbed.lastRunLevel != _gameTicker.RunLevel)
|
||||
{
|
||||
existingEmbed.Description += _gameTicker.RunLevel switch
|
||||
existingEmbed.description += _gameTicker.RunLevel switch
|
||||
{
|
||||
GameRunLevel.PreRoundLobby => "\n\n:arrow_forward: _**Pre-round lobby started**_\n",
|
||||
GameRunLevel.InRound => "\n\n:arrow_forward: _**Round started**_\n",
|
||||
@@ -456,35 +413,26 @@ namespace Content.Server.Administration.Systems
|
||||
$"{_gameTicker.RunLevel} was not matched."),
|
||||
};
|
||||
|
||||
existingEmbed.LastRunLevel = _gameTicker.RunLevel;
|
||||
existingEmbed.lastRunLevel = _gameTicker.RunLevel;
|
||||
}
|
||||
|
||||
// If last message of the new batch is SOS then relay it to on-call.
|
||||
// ... as long as it hasn't been relayed already.
|
||||
var discordMention = messages.Last();
|
||||
var onCallRelay = !discordMention.Receivers && !existingEmbed.OnCall;
|
||||
|
||||
// Add available messages to the embed description
|
||||
while (messages.TryDequeue(out var message))
|
||||
{
|
||||
string text;
|
||||
|
||||
// In case someone thinks they're funny
|
||||
if (message.Message.Length > MessageLengthCap)
|
||||
text = message.Message[..(MessageLengthCap - TooLongText.Length)] + TooLongText;
|
||||
else
|
||||
text = message.Message;
|
||||
if (message.Length > MessageLengthCap)
|
||||
message = message[..(MessageLengthCap - TooLongText.Length)] + TooLongText;
|
||||
|
||||
existingEmbed.Description += $"\n{text}";
|
||||
existingEmbed.description += $"\n{message}";
|
||||
}
|
||||
|
||||
var payload = GeneratePayload(existingEmbed.Description,
|
||||
existingEmbed.Username,
|
||||
existingEmbed.CharacterName);
|
||||
var payload = GeneratePayload(existingEmbed.description,
|
||||
existingEmbed.username,
|
||||
existingEmbed.characterName);
|
||||
|
||||
// If there is no existing embed, create a new one
|
||||
// Otherwise patch (edit) it
|
||||
if (existingEmbed.Id == null)
|
||||
if (existingEmbed.id == null)
|
||||
{
|
||||
var request = await _httpClient.PostAsync($"{_webhookUrl}?wait=true",
|
||||
new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));
|
||||
@@ -507,11 +455,11 @@ namespace Content.Server.Administration.Systems
|
||||
return;
|
||||
}
|
||||
|
||||
existingEmbed.Id = id.ToString();
|
||||
existingEmbed.id = id.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = await _httpClient.PatchAsync($"{_webhookUrl}/messages/{existingEmbed.Id}",
|
||||
var request = await _httpClient.PatchAsync($"{_webhookUrl}/messages/{existingEmbed.id}",
|
||||
new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));
|
||||
|
||||
if (!request.IsSuccessStatusCode)
|
||||
@@ -526,43 +474,6 @@ namespace Content.Server.Administration.Systems
|
||||
|
||||
_relayMessages[userId] = existingEmbed;
|
||||
|
||||
// Actually do the on call relay last, we just need to grab it before we dequeue every message above.
|
||||
if (onCallRelay &&
|
||||
_onCallData != null)
|
||||
{
|
||||
existingEmbed.OnCall = true;
|
||||
var roleMention = _config.GetCVar(CCVars.DiscordAhelpMention);
|
||||
|
||||
if (!string.IsNullOrEmpty(roleMention))
|
||||
{
|
||||
var message = new StringBuilder();
|
||||
message.AppendLine($"<@&{roleMention}>");
|
||||
message.AppendLine("Unanswered SOS");
|
||||
|
||||
// Need webhook data to get the correct link for that channel rather than on-call data.
|
||||
if (_webhookData is { GuildId: { } guildId, ChannelId: { } channelId })
|
||||
{
|
||||
message.AppendLine(
|
||||
$"**[Go to ahelp](https://discord.com/channels/{guildId}/{channelId}/{existingEmbed.Id})**");
|
||||
}
|
||||
|
||||
payload = GeneratePayload(message.ToString(), existingEmbed.Username, existingEmbed.CharacterName);
|
||||
|
||||
var request = await _httpClient.PostAsync($"{_onCallUrl}?wait=true",
|
||||
new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));
|
||||
|
||||
var content = await request.Content.ReadAsStringAsync();
|
||||
if (!request.IsSuccessStatusCode)
|
||||
{
|
||||
_sawmill.Log(LogLevel.Error, $"Discord returned bad status code when posting relay message (perhaps the message is too long?): {request.StatusCode}\nResponse: {content}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingEmbed.OnCall = false;
|
||||
}
|
||||
|
||||
_processingChannels.Remove(userId);
|
||||
}
|
||||
|
||||
@@ -741,7 +652,7 @@ namespace Content.Server.Administration.Systems
|
||||
if (sendsWebhook)
|
||||
{
|
||||
if (!_messageQueues.ContainsKey(msg.UserId))
|
||||
_messageQueues[msg.UserId] = new Queue<DiscordRelayedData>();
|
||||
_messageQueues[msg.UserId] = new Queue<string>();
|
||||
|
||||
var str = message.Text;
|
||||
var unameLength = senderSession.Name.Length;
|
||||
@@ -790,7 +701,7 @@ namespace Content.Server.Administration.Systems
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static DiscordRelayedData GenerateAHelpMessage(AHelpMessageParams parameters)
|
||||
private static string GenerateAHelpMessage(AHelpMessageParams parameters)
|
||||
{
|
||||
var stringbuilder = new StringBuilder();
|
||||
|
||||
@@ -807,57 +718,13 @@ namespace Content.Server.Administration.Systems
|
||||
stringbuilder.Append($" **{parameters.RoundTime}**");
|
||||
if (!parameters.PlayedSound)
|
||||
stringbuilder.Append(" **(S)**");
|
||||
|
||||
if (parameters.Icon == null)
|
||||
stringbuilder.Append($" **{parameters.Username}:** ");
|
||||
else
|
||||
stringbuilder.Append($" **{parameters.Username}** ");
|
||||
stringbuilder.Append(parameters.Message);
|
||||
|
||||
return new DiscordRelayedData()
|
||||
{
|
||||
Receivers = !parameters.NoReceivers,
|
||||
Message = stringbuilder.ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
private record struct DiscordRelayedData
|
||||
{
|
||||
/// <summary>
|
||||
/// Was anyone online to receive it.
|
||||
/// </summary>
|
||||
public bool Receivers;
|
||||
|
||||
/// <summary>
|
||||
/// What's the payload to send to discord.
|
||||
/// </summary>
|
||||
public string Message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class specifically for holding information regarding existing Discord embeds
|
||||
/// </summary>
|
||||
private sealed class DiscordRelayInteraction
|
||||
{
|
||||
public string? Id;
|
||||
|
||||
public string Username = String.Empty;
|
||||
|
||||
public string? CharacterName;
|
||||
|
||||
/// <summary>
|
||||
/// Contents for the discord message.
|
||||
/// </summary>
|
||||
public string Description = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Run level of the last interaction. If different we'll link to the last Id.
|
||||
/// </summary>
|
||||
public GameRunLevel LastRunLevel;
|
||||
|
||||
/// <summary>
|
||||
/// Did we relay this interaction to OnCall previously.
|
||||
/// </summary>
|
||||
public bool OnCall;
|
||||
return stringbuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public sealed partial class AmeControllerComponent : SharedAmeControllerComponen
|
||||
/// </summary>
|
||||
[DataField("injectSound")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Machines/ame_fuelinjection.ogg");
|
||||
public SoundSpecifier InjectSound = new SoundCollectionSpecifier("MetalThud");
|
||||
|
||||
/// <summary>
|
||||
/// The last time this could have injected fuel into the AME.
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Atmos.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by FixGridAtmos. Entities with this may get magically auto-deleted on map initialization in future.
|
||||
/// </summary>
|
||||
[RegisterComponent, EntityCategory("Mapping")]
|
||||
[RegisterComponent]
|
||||
public sealed partial class AtmosFixMarkerComponent : Component
|
||||
{
|
||||
// See FixGridAtmos for more details
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Pinpointer;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Components;
|
||||
using Content.Shared.Atmos.Consoles;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Monitor.Components;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.Pinpointer;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Player;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
@@ -25,12 +21,6 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
[Dependency] private readonly AirAlarmSystem _airAlarmSystem = default!;
|
||||
[Dependency] private readonly AtmosDeviceNetworkSystem _atmosDevNet = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly MapSystem _mapSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly NavMapSystem _navMapSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly DeviceListSystem _deviceListSystem = default!;
|
||||
|
||||
private const float UpdateTime = 1.0f;
|
||||
|
||||
@@ -48,9 +38,6 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
|
||||
// Grid events
|
||||
SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
|
||||
|
||||
// Alarm events
|
||||
SubscribeLocalEvent<AtmosAlertsDeviceComponent, EntityTerminatingEvent>(OnDeviceTerminatingEvent);
|
||||
SubscribeLocalEvent<AtmosAlertsDeviceComponent, AnchorStateChangedEvent>(OnDeviceAnchorChanged);
|
||||
}
|
||||
|
||||
@@ -94,16 +81,6 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
}
|
||||
|
||||
private void OnDeviceAnchorChanged(EntityUid uid, AtmosAlertsDeviceComponent component, AnchorStateChangedEvent args)
|
||||
{
|
||||
OnDeviceAdditionOrRemoval(uid, component, args.Anchored);
|
||||
}
|
||||
|
||||
private void OnDeviceTerminatingEvent(EntityUid uid, AtmosAlertsDeviceComponent component, ref EntityTerminatingEvent args)
|
||||
{
|
||||
OnDeviceAdditionOrRemoval(uid, component, false);
|
||||
}
|
||||
|
||||
private void OnDeviceAdditionOrRemoval(EntityUid uid, AtmosAlertsDeviceComponent component, bool isAdding)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var gridUid = xform.GridUid;
|
||||
@@ -111,13 +88,10 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
if (gridUid == null)
|
||||
return;
|
||||
|
||||
if (!TryComp<NavMapComponent>(xform.GridUid, out var navMap))
|
||||
if (!TryGetAtmosDeviceNavMapData(uid, component, xform, gridUid.Value, out var data))
|
||||
return;
|
||||
|
||||
if (!TryGetAtmosDeviceNavMapData(uid, component, xform, out var data))
|
||||
return;
|
||||
|
||||
var netEntity = GetNetEntity(uid);
|
||||
var netEntity = EntityManager.GetNetEntity(uid);
|
||||
|
||||
var query = AllEntityQuery<AtmosAlertsComputerComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var ent, out var entConsole, out var entXform))
|
||||
@@ -125,18 +99,11 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
if (gridUid != entXform.GridUid)
|
||||
continue;
|
||||
|
||||
if (isAdding)
|
||||
{
|
||||
if (args.Anchored)
|
||||
entConsole.AtmosDevices.Add(data.Value);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
else if (!args.Anchored)
|
||||
entConsole.AtmosDevices.RemoveWhere(x => x.NetEntity == netEntity);
|
||||
_navMapSystem.RemoveNavMapRegion(gridUid.Value, navMap, netEntity);
|
||||
}
|
||||
|
||||
Dirty(ent, entConsole);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,12 +209,6 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
if (entDevice.Group != group)
|
||||
continue;
|
||||
|
||||
if (!TryComp<MapGridComponent>(entXform.GridUid, out var mapGrid))
|
||||
continue;
|
||||
|
||||
if (!TryComp<NavMapComponent>(entXform.GridUid, out var navMap))
|
||||
continue;
|
||||
|
||||
// If emagged, change the alarm type to normal
|
||||
var alarmState = (entAtmosAlarmable.LastAlarmState == AtmosAlarmType.Emagged) ? AtmosAlarmType.Normal : entAtmosAlarmable.LastAlarmState;
|
||||
|
||||
@@ -255,45 +216,14 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
if (TryComp<ApcPowerReceiverComponent>(ent, out var entAPCPower) && !entAPCPower.Powered)
|
||||
alarmState = AtmosAlarmType.Invalid;
|
||||
|
||||
// Create entry
|
||||
var netEnt = GetNetEntity(ent);
|
||||
|
||||
var entry = new AtmosAlertsComputerEntry
|
||||
(netEnt,
|
||||
(GetNetEntity(ent),
|
||||
GetNetCoordinates(entXform.Coordinates),
|
||||
entDevice.Group,
|
||||
alarmState,
|
||||
MetaData(ent).EntityName,
|
||||
entDeviceNetwork.Address);
|
||||
|
||||
// Get the list of sensors attached to the alarm
|
||||
var sensorList = TryComp<DeviceListComponent>(ent, out var entDeviceList) ? _deviceListSystem.GetDeviceList(ent, entDeviceList) : null;
|
||||
|
||||
if (sensorList?.Any() == true)
|
||||
{
|
||||
var alarmRegionSeeds = new HashSet<Vector2i>();
|
||||
|
||||
// If valid and anchored, use the position of sensors as seeds for the region
|
||||
foreach (var (address, sensorEnt) in sensorList)
|
||||
{
|
||||
if (!sensorEnt.IsValid() || !HasComp<AtmosMonitorComponent>(sensorEnt))
|
||||
continue;
|
||||
|
||||
var sensorXform = Transform(sensorEnt);
|
||||
|
||||
if (sensorXform.Anchored && sensorXform.GridUid == entXform.GridUid)
|
||||
alarmRegionSeeds.Add(_mapSystem.CoordinatesToTile(entXform.GridUid.Value, mapGrid, _transformSystem.GetMapCoordinates(sensorEnt, sensorXform)));
|
||||
}
|
||||
|
||||
var regionProperties = new SharedNavMapSystem.NavMapRegionProperties(netEnt, AtmosAlertsComputerUiKey.Key, alarmRegionSeeds);
|
||||
_navMapSystem.AddOrUpdateNavMapRegion(gridUid, navMap, netEnt, regionProperties);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_navMapSystem.RemoveNavMapRegion(entXform.GridUid.Value, navMap, netEnt);
|
||||
}
|
||||
|
||||
alarmStateData.Add(entry);
|
||||
}
|
||||
|
||||
@@ -376,10 +306,7 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
var query = AllEntityQuery<AtmosAlertsDeviceComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var ent, out var entComponent, out var entXform))
|
||||
{
|
||||
if (entXform.GridUid != gridUid)
|
||||
continue;
|
||||
|
||||
if (TryGetAtmosDeviceNavMapData(ent, entComponent, entXform, out var data))
|
||||
if (TryGetAtmosDeviceNavMapData(ent, entComponent, entXform, gridUid, out var data))
|
||||
atmosDeviceNavMapData.Add(data.Value);
|
||||
}
|
||||
|
||||
@@ -390,10 +317,14 @@ public sealed class AtmosAlertsComputerSystem : SharedAtmosAlertsComputerSystem
|
||||
(EntityUid uid,
|
||||
AtmosAlertsDeviceComponent component,
|
||||
TransformComponent xform,
|
||||
EntityUid gridUid,
|
||||
[NotNullWhen(true)] out AtmosAlertsDeviceNavMapData? output)
|
||||
{
|
||||
output = null;
|
||||
|
||||
if (xform.GridUid != gridUid)
|
||||
return false;
|
||||
|
||||
if (!xform.Anchored)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ public sealed class BloodstreamSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
var currentVolume = bloodSolution.RemoveReagent(component.BloodReagent, bloodSolution.Volume, ignoreReagentData: true);
|
||||
var currentVolume = bloodSolution.RemoveReagent(component.BloodReagent, bloodSolution.Volume);
|
||||
|
||||
component.BloodReagent = reagent;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Botany.Components;
|
||||
|
||||
@@ -24,9 +23,6 @@ public sealed partial class PlantHolderComponent : Component
|
||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
public TimeSpan LastCycle = TimeSpan.Zero;
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier? WateringSound;
|
||||
|
||||
[DataField]
|
||||
public bool UpdateSpriteAfterUpdate;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Botany.Components;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Kitchen.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
@@ -17,6 +18,7 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Random;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -35,6 +37,7 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly SharedPointLightSystem _pointLight = default!;
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
|
||||
@@ -50,7 +53,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
SubscribeLocalEvent<PlantHolderComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<PlantHolderComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<PlantHolderComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<PlantHolderComponent, SolutionTransferredEvent>(OnSolutionTransferred);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -156,7 +158,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
if (!_botany.TryGetSeed(seeds, out var seed))
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
var name = Loc.GetString(seed.Name);
|
||||
var noun = Loc.GetString(seed.Noun);
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-plant-success-message",
|
||||
@@ -184,7 +185,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-already-seeded-message",
|
||||
("name", Comp<MetaDataComponent>(uid).EntityName)), args.User, PopupType.Medium);
|
||||
return;
|
||||
@@ -192,7 +192,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
|
||||
if (_tagSystem.HasTag(args.Used, "Hoe"))
|
||||
{
|
||||
args.Handled = true;
|
||||
if (component.WeedLevel > 0)
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-remove-weeds-message",
|
||||
@@ -212,7 +211,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
|
||||
if (HasComp<ShovelComponent>(args.Used))
|
||||
{
|
||||
args.Handled = true;
|
||||
if (component.Seed != null)
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-remove-plant-message",
|
||||
@@ -230,9 +228,39 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (_solutionContainerSystem.TryGetDrainableSolution(args.Used, out var solution, out _)
|
||||
&& _solutionContainerSystem.ResolveSolution(uid, component.SoilSolutionName, ref component.SoilSolution)
|
||||
&& TryComp(args.Used, out SprayComponent? spray))
|
||||
{
|
||||
var amount = FixedPoint2.New(1);
|
||||
|
||||
var targetEntity = uid;
|
||||
var solutionEntity = args.Used;
|
||||
|
||||
_audio.PlayPvs(spray.SpraySound, args.Used, AudioParams.Default.WithVariation(0.125f));
|
||||
|
||||
var split = _solutionContainerSystem.Drain(solutionEntity, solution.Value, amount);
|
||||
|
||||
if (split.Volume == 0)
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-no-plant-message",
|
||||
("owner", args.Used)), args.User);
|
||||
return;
|
||||
}
|
||||
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-spray-message",
|
||||
("owner", uid),
|
||||
("amount", split.Volume)), args.User, PopupType.Medium);
|
||||
|
||||
_solutionContainerSystem.TryAddSolution(component.SoilSolution.Value, split);
|
||||
|
||||
ForceUpdateByExternalCause(uid, component);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tagSystem.HasTag(args.Used, "PlantSampleTaker"))
|
||||
{
|
||||
args.Handled = true;
|
||||
if (component.Seed == null)
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-nothing-to-sample-message"), args.User);
|
||||
@@ -288,15 +316,10 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
}
|
||||
|
||||
if (HasComp<SharpComponent>(args.Used))
|
||||
{
|
||||
args.Handled = true;
|
||||
DoHarvest(uid, args.User, component);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryComp<ProduceComponent>(args.Used, out var produce))
|
||||
{
|
||||
args.Handled = true;
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-compost-message",
|
||||
("owner", uid),
|
||||
("usingItem", args.Used)), args.User, PopupType.Medium);
|
||||
@@ -328,10 +351,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSolutionTransferred(Entity<PlantHolderComponent> ent, ref SolutionTransferredEvent args)
|
||||
{
|
||||
_audio.PlayPvs(ent.Comp.WateringSound, ent.Owner);
|
||||
}
|
||||
private void OnInteractHand(Entity<PlantHolderComponent> entity, ref InteractHandEvent args)
|
||||
{
|
||||
DoHarvest(entity, args.User, entity.Comp);
|
||||
@@ -680,10 +699,7 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
if (TryComp<HandsComponent>(user, out var hands))
|
||||
{
|
||||
if (!_botany.CanHarvest(component.Seed, hands.ActiveHandEntity))
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("plant-holder-component-ligneous-cant-harvest-message"), user);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!_botany.CanHarvest(component.Seed))
|
||||
{
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Globalization;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Server.Chat.Managers;
|
||||
|
||||
/// <summary>
|
||||
/// Sanitizes messages!
|
||||
/// It currently ony removes the shorthands for emotes (like "lol" or "^-^") from a chat message and returns the last
|
||||
/// emote in their message
|
||||
/// </summary>
|
||||
public sealed class ChatSanitizationManager : IChatSanitizationManager
|
||||
{
|
||||
private static readonly Dictionary<string, string> ShorthandToEmote = new()
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
|
||||
private static readonly Dictionary<string, string> SmileyToEmote = new()
|
||||
{
|
||||
// CP14-RU-Localization-Start
|
||||
{ "лол", "chatsan-laughs" },
|
||||
@@ -63,7 +60,7 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
|
||||
{ ":D", "chatsan-smiles-widely" },
|
||||
{ "D:", "chatsan-frowns-deeply" },
|
||||
{ ":O", "chatsan-surprised" },
|
||||
{ ":3", "chatsan-smiles" },
|
||||
{ ":3", "chatsan-smiles" }, //nope
|
||||
{ ":S", "chatsan-uncertain" },
|
||||
{ ":>", "chatsan-grins" },
|
||||
{ ":<", "chatsan-pouts" },
|
||||
@@ -105,7 +102,7 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
|
||||
{ "kek", "chatsan-laughs" },
|
||||
{ "rofl", "chatsan-laughs" },
|
||||
{ "o7", "chatsan-salutes" },
|
||||
{ ";_;7", "chatsan-tearfully-salutes" },
|
||||
{ ";_;7", "chatsan-tearfully-salutes"},
|
||||
{ "idk", "chatsan-shrugs" },
|
||||
{ ";)", "chatsan-winks" },
|
||||
{ ";]", "chatsan-winks" },
|
||||
@@ -118,12 +115,9 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
|
||||
{ "(':", "chatsan-tearfully-smiles" },
|
||||
{ "[':", "chatsan-tearfully-smiles" },
|
||||
{ "('=", "chatsan-tearfully-smiles" },
|
||||
{ "['=", "chatsan-tearfully-smiles" }
|
||||
{ "['=", "chatsan-tearfully-smiles" },
|
||||
};
|
||||
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
[Dependency] private readonly ILocalizationManager _loc = default!;
|
||||
|
||||
private bool _doSanitize;
|
||||
|
||||
public void Initialize()
|
||||
@@ -131,60 +125,29 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
|
||||
_configurationManager.OnValueChanged(CCVars.ChatSanitizerEnabled, x => _doSanitize = x, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the shorthands from the message, returning the last one found as the emote
|
||||
/// </summary>
|
||||
/// <param name="message">The pre-sanitized message</param>
|
||||
/// <param name="speaker">The speaker</param>
|
||||
/// <param name="sanitized">The sanitized message with shorthands removed</param>
|
||||
/// <param name="emote">The localized emote</param>
|
||||
/// <returns>True if emote has been sanitized out</returns>
|
||||
public bool TrySanitizeEmoteShorthands(string message,
|
||||
EntityUid speaker,
|
||||
out string sanitized,
|
||||
[NotNullWhen(true)] out string? emote)
|
||||
public bool TrySanitizeOutSmilies(string input, EntityUid speaker, out string sanitized, [NotNullWhen(true)] out string? emote)
|
||||
{
|
||||
emote = null;
|
||||
sanitized = message;
|
||||
|
||||
if (!_doSanitize)
|
||||
return false;
|
||||
|
||||
// -1 is just a canary for nothing found yet
|
||||
var lastEmoteIndex = -1;
|
||||
|
||||
foreach (var (shorthand, emoteKey) in ShorthandToEmote)
|
||||
{
|
||||
// We have to escape it because shorthands like ":)" or "-_-" would break the regex otherwise.
|
||||
var escaped = Regex.Escape(shorthand);
|
||||
|
||||
// So there are 2 cases:
|
||||
// - If there is whitespace before it and after it is either punctuation, whitespace, or the end of the line
|
||||
// Delete the word and the whitespace before
|
||||
// - If it is at the start of the string and is followed by punctuation, whitespace, or the end of the line
|
||||
// Delete the word and the punctuation if it exists.
|
||||
var pattern =
|
||||
$@"\s{escaped}(?=\p{{P}}|\s|$)|^{escaped}(?:\p{{P}}|(?=\s|$))";
|
||||
|
||||
var r = new Regex(pattern, RegexOptions.RightToLeft | RegexOptions.IgnoreCase);
|
||||
|
||||
// We're using sanitized as the original message until the end so that we can make sure the indices of
|
||||
// the emotes are accurate.
|
||||
var lastMatch = r.Match(sanitized);
|
||||
|
||||
if (!lastMatch.Success)
|
||||
continue;
|
||||
|
||||
if (lastMatch.Index > lastEmoteIndex)
|
||||
{
|
||||
lastEmoteIndex = lastMatch.Index;
|
||||
emote = _loc.GetString(emoteKey, ("ent", speaker));
|
||||
}
|
||||
|
||||
message = r.Replace(message, string.Empty);
|
||||
sanitized = input;
|
||||
emote = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
sanitized = message.Trim();
|
||||
return emote is not null;
|
||||
input = input.TrimEnd();
|
||||
|
||||
foreach (var (smiley, replacement) in SmileyToEmote)
|
||||
{
|
||||
if (input.EndsWith(smiley, true, CultureInfo.InvariantCulture))
|
||||
{
|
||||
sanitized = input.Remove(input.Length - smiley.Length).TrimEnd();
|
||||
emote = Loc.GetString(replacement, ("ent", speaker));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sanitized = input;
|
||||
emote = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,5 @@ public interface IChatSanitizationManager
|
||||
{
|
||||
public void Initialize();
|
||||
|
||||
public bool TrySanitizeEmoteShorthands(string input,
|
||||
EntityUid speaker,
|
||||
out string sanitized,
|
||||
[NotNullWhen(true)] out string? emote);
|
||||
public bool TrySanitizeOutSmilies(string input, EntityUid speaker, out string sanitized, [NotNullWhen(true)] out string? emote);
|
||||
}
|
||||
|
||||
@@ -746,12 +746,8 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private string SanitizeInGameICMessage(EntityUid source, string message, out string? emoteStr, bool capitalize = true, bool punctuate = false, bool capitalizeTheWordI = true)
|
||||
{
|
||||
var newMessage = SanitizeMessageReplaceWords(message.Trim());
|
||||
|
||||
GetRadioKeycodePrefix(source, newMessage, out newMessage, out var prefix);
|
||||
|
||||
// Sanitize it first as it might change the word order
|
||||
_sanitizer.TrySanitizeEmoteShorthands(newMessage, source, out newMessage, out emoteStr);
|
||||
var newMessage = message.Trim();
|
||||
newMessage = SanitizeMessageReplaceWords(newMessage);
|
||||
|
||||
if (capitalize)
|
||||
newMessage = SanitizeMessageCapital(newMessage);
|
||||
@@ -760,7 +756,9 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
if (punctuate)
|
||||
newMessage = SanitizeMessagePeriod(newMessage);
|
||||
|
||||
return prefix + newMessage;
|
||||
_sanitizer.TrySanitizeOutSmilies(newMessage, source, out newMessage, out emoteStr);
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
private string SanitizeInGameOOCMessage(string message)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
|
||||
namespace Content.Server.Chemistry.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Used for embeddable entities that should try to inject a
|
||||
/// contained solution into a target over time while they are embbeded into.
|
||||
/// </summary>
|
||||
[RegisterComponent, AutoGenerateComponentPause]
|
||||
public sealed partial class SolutionInjectWhileEmbeddedComponent : BaseSolutionInjectOnEventComponent {
|
||||
///<summary>
|
||||
///The time at which the injection will happen.
|
||||
///</summary>
|
||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
|
||||
public TimeSpan NextUpdate;
|
||||
|
||||
///<summary>
|
||||
///The delay between each injection in seconds.
|
||||
///</summary>
|
||||
[DataField]
|
||||
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(3);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Projectiles;
|
||||
@@ -30,7 +29,6 @@ public sealed class SolutionInjectOnCollideSystem : EntitySystem
|
||||
SubscribeLocalEvent<SolutionInjectOnProjectileHitComponent, ProjectileHitEvent>(HandleProjectileHit);
|
||||
SubscribeLocalEvent<SolutionInjectOnEmbedComponent, EmbedEvent>(HandleEmbed);
|
||||
SubscribeLocalEvent<MeleeChemicalInjectorComponent, MeleeHitEvent>(HandleMeleeHit);
|
||||
SubscribeLocalEvent<SolutionInjectWhileEmbeddedComponent, InjectOverTimeEvent>(OnInjectOverTime);
|
||||
}
|
||||
|
||||
private void HandleProjectileHit(Entity<SolutionInjectOnProjectileHitComponent> entity, ref ProjectileHitEvent args)
|
||||
@@ -51,11 +49,6 @@ public sealed class SolutionInjectOnCollideSystem : EntitySystem
|
||||
TryInjectTargets((entity.Owner, entity.Comp), args.HitEntities, args.User);
|
||||
}
|
||||
|
||||
private void OnInjectOverTime(Entity<SolutionInjectWhileEmbeddedComponent> entity, ref InjectOverTimeEvent args)
|
||||
{
|
||||
DoInjection((entity.Owner, entity.Comp), args.EmbeddedIntoUid);
|
||||
}
|
||||
|
||||
private void DoInjection(Entity<BaseSolutionInjectOnEventComponent> injectorEntity, EntityUid target, EntityUid? source = null)
|
||||
{
|
||||
TryInjectTargets(injectorEntity, [target], source);
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Chemistry.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// System for handling injecting into an entity while a projectile is embedded.
|
||||
/// </summary>
|
||||
public sealed class SolutionInjectWhileEmbeddedSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SolutionInjectWhileEmbeddedComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<SolutionInjectWhileEmbeddedComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
ent.Comp.NextUpdate = _gameTiming.CurTime + ent.Comp.UpdateInterval;
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<SolutionInjectWhileEmbeddedComponent, EmbeddableProjectileComponent>();
|
||||
while (query.MoveNext(out var uid, out var injectComponent, out var projectileComponent))
|
||||
{
|
||||
if (_gameTiming.CurTime < injectComponent.NextUpdate)
|
||||
continue;
|
||||
|
||||
injectComponent.NextUpdate += injectComponent.UpdateInterval;
|
||||
|
||||
if(projectileComponent.EmbeddedIntoUid == null)
|
||||
continue;
|
||||
|
||||
var ev = new InjectOverTimeEvent(projectileComponent.EmbeddedIntoUid.Value);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public sealed class ExaminableDamageSystem : EntitySystem
|
||||
|
||||
var level = GetDamageLevel(uid, component);
|
||||
var msg = Loc.GetString(messages[level]);
|
||||
args.PushMarkup(msg,-99);
|
||||
args.PushMarkup(msg);
|
||||
}
|
||||
|
||||
private int GetDamageLevel(EntityUid uid, ExaminableDamageComponent? component = null,
|
||||
|
||||
@@ -875,41 +875,10 @@ INSERT INTO player_round (players_id, rounds_id) VALUES ({players[player]}, {id}
|
||||
|
||||
public async Task AddAdminLogs(List<AdminLog> logs)
|
||||
{
|
||||
const int maxRetryAttempts = 5;
|
||||
var initialRetryDelay = TimeSpan.FromSeconds(5);
|
||||
|
||||
DebugTools.Assert(logs.All(x => x.RoundId > 0), "Adding logs with invalid round ids.");
|
||||
|
||||
var attempt = 0;
|
||||
var retryDelay = initialRetryDelay;
|
||||
|
||||
while (attempt < maxRetryAttempts)
|
||||
{
|
||||
try
|
||||
{
|
||||
await using var db = await GetDb();
|
||||
db.DbContext.AdminLog.AddRange(logs);
|
||||
await db.DbContext.SaveChangesAsync();
|
||||
_opsLog.Debug($"Successfully saved {logs.Count} admin logs.");
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
attempt += 1;
|
||||
_opsLog.Error($"Attempt {attempt} failed to save logs: {ex}");
|
||||
|
||||
if (attempt >= maxRetryAttempts)
|
||||
{
|
||||
_opsLog.Error($"Max retry attempts reached. Failed to save {logs.Count} admin logs.");
|
||||
return;
|
||||
}
|
||||
|
||||
_opsLog.Warning($"Retrying in {retryDelay.TotalSeconds} seconds...");
|
||||
await Task.Delay(retryDelay);
|
||||
|
||||
retryDelay *= 2;
|
||||
}
|
||||
}
|
||||
await using var db = await GetDb();
|
||||
db.DbContext.AdminLog.AddRange(logs);
|
||||
await db.DbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
protected abstract IQueryable<AdminLog> StartAdminLogsQuery(ServerDbContext db, LogFilter? filter = null);
|
||||
|
||||
@@ -46,8 +46,8 @@ public sealed class DoorSystem : SharedDoorSystem
|
||||
SetBoltsDown(ent, true);
|
||||
}
|
||||
|
||||
UpdateBoltLightStatus(ent);
|
||||
ent.Comp.Powered = args.Powered;
|
||||
Dirty(ent, ent.Comp);
|
||||
UpdateBoltLightStatus(ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,17 +26,9 @@ public sealed partial class JobCondition : EntityEffectCondition
|
||||
if(!args.EntityManager.HasComponent<JobRoleComponent>(roleId))
|
||||
continue;
|
||||
|
||||
if (!args.EntityManager.TryGetComponent<MindRoleComponent>(roleId, out var mindRole))
|
||||
{
|
||||
Logger.Error($"Encountered job mind role entity {roleId} without a {nameof(MindRoleComponent)}");
|
||||
if(!args.EntityManager.TryGetComponent<MindRoleComponent>(roleId, out var mindRole)
|
||||
|| mindRole.JobPrototype is null)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mindRole.JobPrototype == null)
|
||||
{
|
||||
Logger.Error($"Encountered job mind role entity {roleId} without a {nameof(JobPrototype)}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Job.Contains(mindRole.JobPrototype.Value))
|
||||
return true;
|
||||
|
||||
@@ -192,6 +192,9 @@ namespace Content.Server.GameTicking
|
||||
if (!_playerManager.TryGetSessionById(userId, out _))
|
||||
continue;
|
||||
|
||||
if (_banManager.GetRoleBans(userId) == null)
|
||||
continue;
|
||||
|
||||
total++;
|
||||
}
|
||||
|
||||
@@ -235,7 +238,11 @@ namespace Content.Server.GameTicking
|
||||
#if DEBUG
|
||||
DebugTools.Assert(_userDb.IsLoadComplete(session), $"Player was readied up but didn't have user DB data loaded yet??");
|
||||
#endif
|
||||
|
||||
if (_banManager.GetRoleBans(userId) == null)
|
||||
{
|
||||
Logger.ErrorS("RoleBans", $"Role bans for player {session} {userId} have not been loaded yet.");
|
||||
continue;
|
||||
}
|
||||
readyPlayers.Add(session);
|
||||
HumanoidCharacterProfile profile;
|
||||
if (_prefsManager.TryGetCachedPreferences(userId, out var preferences))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.NPC.Prototypes;
|
||||
using Content.Shared.Random;
|
||||
using Content.Shared.Roles;
|
||||
@@ -32,24 +31,6 @@ public sealed partial class TraitorRuleComponent : Component
|
||||
[DataField]
|
||||
public ProtoId<DatasetPrototype> ObjectiveIssuers = "TraitorCorporations";
|
||||
|
||||
/// <summary>
|
||||
/// Give this traitor an Uplink on spawn.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool GiveUplink = true;
|
||||
|
||||
/// <summary>
|
||||
/// Give this traitor the codewords.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool GiveCodewords = true;
|
||||
|
||||
/// <summary>
|
||||
/// Give this traitor a briefing in chat.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool GiveBriefing = true;
|
||||
|
||||
public int TotalTraitors => TraitorMinds.Count;
|
||||
public string[] Codewords = new string[3];
|
||||
|
||||
@@ -87,5 +68,5 @@ public sealed partial class TraitorRuleComponent : Component
|
||||
/// The amount of TC traitors start with.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public FixedPoint2 StartingBalance = 20;
|
||||
public int StartingBalance = 20;
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
|
||||
|
||||
if (_mind.TryGetMind(ev.User.Value, out var revMindId, out _))
|
||||
{
|
||||
if (_role.MindHasRole<RevolutionaryRoleComponent>(revMindId, out var role))
|
||||
role.Value.Comp2.ConvertedCount++;
|
||||
if (_role.MindHasRole<RevolutionaryRoleComponent>(revMindId, out _, out var role))
|
||||
role.Value.Comp.ConvertedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using Content.Server.PDA.Ringer;
|
||||
using Content.Server.Roles;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.GameTicking.Components;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.NPC.Systems;
|
||||
@@ -76,46 +75,38 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
|
||||
return codewords;
|
||||
}
|
||||
|
||||
public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component)
|
||||
public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool giveUplink = true)
|
||||
{
|
||||
//Grab the mind if it wasn't provided
|
||||
if (!_mindSystem.TryGetMind(traitor, out var mindId, out var mind))
|
||||
return false;
|
||||
|
||||
var briefing = "";
|
||||
|
||||
if (component.GiveCodewords)
|
||||
briefing = Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", component.Codewords)));
|
||||
|
||||
var briefing = Loc.GetString("traitor-role-codewords-short", ("codewords", string.Join(", ", component.Codewords)));
|
||||
var issuer = _random.Pick(_prototypeManager.Index(component.ObjectiveIssuers).Values);
|
||||
|
||||
// Uplink code will go here if applicable, but we still need the variable if there aren't any
|
||||
Note[]? code = null;
|
||||
|
||||
if (component.GiveUplink)
|
||||
if (giveUplink)
|
||||
{
|
||||
// Calculate the amount of currency on the uplink.
|
||||
var startingBalance = component.StartingBalance;
|
||||
if (_jobs.MindTryGetJob(mindId, out var prototype))
|
||||
{
|
||||
if (startingBalance < prototype.AntagAdvantage) // Can't use Math functions on FixedPoint2
|
||||
startingBalance = 0;
|
||||
else
|
||||
startingBalance = startingBalance - prototype.AntagAdvantage;
|
||||
}
|
||||
startingBalance = Math.Max(startingBalance - prototype.AntagAdvantage, 0);
|
||||
|
||||
// Choose and generate an Uplink, and return the uplink code if applicable
|
||||
var uplinkParams = RequestUplink(traitor, startingBalance, briefing);
|
||||
code = uplinkParams.Item1;
|
||||
briefing = uplinkParams.Item2;
|
||||
// creadth: we need to create uplink for the antag.
|
||||
// PDA should be in place already
|
||||
var pda = _uplink.FindUplinkTarget(traitor);
|
||||
if (pda == null || !_uplink.AddUplink(traitor, startingBalance, giveDiscounts: true))
|
||||
return false;
|
||||
|
||||
// Give traitors their codewords and uplink code to keep in their character info menu
|
||||
code = EnsureComp<RingerUplinkComponent>(pda.Value).Code;
|
||||
|
||||
// If giveUplink is false the uplink code part is omitted
|
||||
briefing = string.Format("{0}\n{1}", briefing,
|
||||
Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("-", code).Replace("sharp", "#"))));
|
||||
}
|
||||
|
||||
string[]? codewords = null;
|
||||
if (component.GiveCodewords)
|
||||
codewords = component.Codewords;
|
||||
|
||||
if (component.GiveBriefing)
|
||||
_antag.SendBriefing(traitor, GenerateBriefing(codewords, code, issuer), null, component.GreetSoundNotification);
|
||||
_antag.SendBriefing(traitor, GenerateBriefing(component.Codewords, code, issuer), null, component.GreetSoundNotification);
|
||||
|
||||
component.TraitorMinds.Add(mindId);
|
||||
|
||||
@@ -143,51 +134,20 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
|
||||
return true;
|
||||
}
|
||||
|
||||
private (Note[]?, string) RequestUplink(EntityUid traitor, FixedPoint2 startingBalance, string briefing)
|
||||
{
|
||||
var pda = _uplink.FindUplinkTarget(traitor);
|
||||
Note[]? code = null;
|
||||
|
||||
var uplinked = _uplink.AddUplink(traitor, startingBalance, pda, true);
|
||||
|
||||
if (pda is not null && uplinked)
|
||||
{
|
||||
// Codes are only generated if the uplink is a PDA
|
||||
code = EnsureComp<RingerUplinkComponent>(pda.Value).Code;
|
||||
|
||||
// If giveUplink is false the uplink code part is omitted
|
||||
briefing = string.Format("{0}\n{1}",
|
||||
briefing,
|
||||
Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("-", code).Replace("sharp", "#"))));
|
||||
return (code, briefing);
|
||||
}
|
||||
else if (pda is null && uplinked)
|
||||
{
|
||||
briefing += "\n" + Loc.GetString("traitor-role-uplink-implant-short");
|
||||
}
|
||||
|
||||
return (null, briefing);
|
||||
}
|
||||
|
||||
// TODO: AntagCodewordsComponent
|
||||
private void OnObjectivesTextPrepend(EntityUid uid, TraitorRuleComponent comp, ref ObjectivesTextPrependEvent args)
|
||||
{
|
||||
if(comp.GiveCodewords)
|
||||
args.Text += "\n" + Loc.GetString("traitor-round-end-codewords", ("codewords", string.Join(", ", comp.Codewords)));
|
||||
args.Text += "\n" + Loc.GetString("traitor-round-end-codewords", ("codewords", string.Join(", ", comp.Codewords)));
|
||||
}
|
||||
|
||||
// TODO: figure out how to handle this? add priority to briefing event?
|
||||
private string GenerateBriefing(string[]? codewords, Note[]? uplinkCode, string? objectiveIssuer = null)
|
||||
private string GenerateBriefing(string[] codewords, Note[]? uplinkCode, string? objectiveIssuer = null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(Loc.GetString("traitor-role-greeting", ("corporation", objectiveIssuer ?? Loc.GetString("objective-issuer-unknown"))));
|
||||
if (codewords != null)
|
||||
sb.AppendLine(Loc.GetString("traitor-role-codewords", ("codewords", string.Join(", ", codewords))));
|
||||
sb.AppendLine(Loc.GetString("traitor-role-codewords", ("codewords", string.Join(", ", codewords))));
|
||||
if (uplinkCode != null)
|
||||
sb.AppendLine(Loc.GetString("traitor-role-uplink-code", ("code", string.Join("-", uplinkCode).Replace("sharp", "#"))));
|
||||
else
|
||||
sb.AppendLine(Loc.GetString("traitor-role-uplink-implant"));
|
||||
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
@@ -516,8 +516,8 @@ public sealed class GhostRoleSystem : EntitySystem
|
||||
|
||||
_roleSystem.MindAddRole(newMind, "MindRoleGhostMarker");
|
||||
|
||||
if(_roleSystem.MindHasRole<GhostRoleMarkerRoleComponent>(newMind!, out var markerRole))
|
||||
markerRole.Value.Comp2.Name = role.RoleName;
|
||||
if(_roleSystem.MindHasRole<GhostRoleMarkerRoleComponent>(newMind, out _, out var markerRole))
|
||||
markerRole.Value.Comp.Name = role.RoleName;
|
||||
|
||||
_mindSystem.SetUserId(newMind, player.UserId);
|
||||
_mindSystem.TransferTo(newMind, mob);
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed class HolosignSystem : EntitySystem
|
||||
if (args.Handled
|
||||
|| !args.CanReach // prevent placing out of range
|
||||
|| HasComp<StorageComponent>(args.Target) // if it's a storage component like a bag, we ignore usage so it can be stored
|
||||
|| !_powerCell.TryUseCharge(uid, component.ChargeUse, user: args.User) // if no battery or no charge, doesn't work
|
||||
|| !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work
|
||||
)
|
||||
return;
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
// How much the cell score should be increased per 1 AutoRechargeRate.
|
||||
private const int AutoRechargeValue = 100;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -62,26 +59,15 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
return;
|
||||
|
||||
// no power cell for some reason??? allow it
|
||||
if (!_powerCell.TryGetBatteryFromSlot(uid, out var batteryUid, out var battery))
|
||||
if (!_powerCell.TryGetBatteryFromSlot(uid, out var battery))
|
||||
return;
|
||||
|
||||
if (!TryComp<BatteryComponent>(args.EntityUid, out var inserting))
|
||||
{
|
||||
args.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
var user = Transform(uid).ParentUid;
|
||||
|
||||
// can only upgrade power cell, not swap to recharge instantly otherwise ninja could just swap batteries with flashlights in maints for easy power
|
||||
if (GetCellScore(inserting.Owner, inserting) <= GetCellScore(battery.Owner, battery))
|
||||
{
|
||||
if (!TryComp<BatteryComponent>(args.EntityUid, out var inserting) || inserting.MaxCharge <= battery.MaxCharge)
|
||||
args.Cancel();
|
||||
Popup.PopupEntity(Loc.GetString("ninja-cell-downgrade"), user, user);
|
||||
return;
|
||||
}
|
||||
|
||||
// tell ninja abilities that use battery to update it so they don't use charge from the old one
|
||||
var user = Transform(uid).ParentUid;
|
||||
if (!_ninja.IsNinja(user))
|
||||
return;
|
||||
|
||||
@@ -90,16 +76,6 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
RaiseLocalEvent(user, ref ev);
|
||||
}
|
||||
|
||||
// this function assigns a score to a power cell depending on the capacity, to be used when comparing which cell is better.
|
||||
private float GetCellScore(EntityUid uid, BatteryComponent battcomp)
|
||||
{
|
||||
// if a cell is able to automatically recharge, boost the score drastically depending on the recharge rate,
|
||||
// this is to ensure a ninja can still upgrade to a micro reactor cell even if they already have a medium or high.
|
||||
if (TryComp<BatterySelfRechargerComponent>(uid, out var selfcomp) && selfcomp.AutoRecharge)
|
||||
return battcomp.MaxCharge + (selfcomp.AutoRechargeRate*AutoRechargeValue);
|
||||
return battcomp.MaxCharge;
|
||||
}
|
||||
|
||||
private void OnEmpAttempt(EntityUid uid, NinjaSuitComponent comp, EmpAttemptEvent args)
|
||||
{
|
||||
// ninja suit (battery) is immune to emp
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Objectives.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Roles;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Content.Shared.Ninja.Systems;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Sticky;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Ninja.Systems;
|
||||
|
||||
@@ -17,7 +19,6 @@ public sealed class SpiderChargeSystem : SharedSpiderChargeSystem
|
||||
{
|
||||
[Dependency] private readonly MindSystem _mind = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedRoleSystem _role = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SpaceNinjaSystem _ninja = default!;
|
||||
|
||||
@@ -40,10 +41,7 @@ public sealed class SpiderChargeSystem : SharedSpiderChargeSystem
|
||||
|
||||
var user = args.User;
|
||||
|
||||
if (!_mind.TryGetMind(args.User, out var mind, out _))
|
||||
return;
|
||||
|
||||
if (!_role.MindHasRole<NinjaRoleComponent>(mind))
|
||||
if (!_mind.TryGetRole<NinjaRoleComponent>(user, out var _))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("spider-charge-not-ninja"), user, user);
|
||||
args.Cancelled = true;
|
||||
|
||||
@@ -49,9 +49,12 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
{
|
||||
_puddle.TrySpillAt(uid, solution, out _, false);
|
||||
}
|
||||
foreach (var trash in foodComp.Trash)
|
||||
if (foodComp.Trash.Count == 0)
|
||||
{
|
||||
EntityManager.SpawnEntity(trash, Transform(uid).Coordinates);
|
||||
foreach (var trash in foodComp.Trash)
|
||||
{
|
||||
EntityManager.SpawnEntity(trash, Transform(uid).Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
ActivatePayload(uid);
|
||||
|
||||
@@ -317,7 +317,7 @@ public sealed class DrinkSystem : SharedDrinkSystem
|
||||
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} drank {ToPrettyString(entity.Owner):drink}");
|
||||
}
|
||||
|
||||
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-2f).WithVariation(0.25f));
|
||||
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-2f));
|
||||
|
||||
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
|
||||
_stomach.TryTransferSolution(firstStomach.Value.Owner, drained, firstStomach.Value.Comp1);
|
||||
|
||||
@@ -296,7 +296,7 @@ public sealed class FoodSystem : EntitySystem
|
||||
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} ate {ToPrettyString(entity.Owner):food}");
|
||||
}
|
||||
|
||||
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-1f).WithVariation(0.20f));
|
||||
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-1f));
|
||||
|
||||
// Try to break all used utensils
|
||||
foreach (var utensil in utensils)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using Content.Server._CP14.Objectives.Systems;
|
||||
using Content.Server._CP14.StealArea;
|
||||
using Content.Server.Objectives.Systems;
|
||||
using Content.Server.Thief.Systems;
|
||||
|
||||
@@ -8,7 +6,7 @@ namespace Content.Server.Objectives.Components;
|
||||
/// <summary>
|
||||
/// An abstract component that allows other systems to count adjacent objects as "stolen" when controlling other systems
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(StealConditionSystem), typeof(ThiefBeaconSystem), typeof(CP14CurrencyCollectConditionSystem), typeof(CP14StealAreaAutoJobConnectSystem))] //CP14 add currency condition access
|
||||
[RegisterComponent, Access(typeof(StealConditionSystem), typeof(ThiefBeaconSystem))]
|
||||
public sealed partial class StealAreaComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Content.Server.Objectives.Components;
|
||||
using Content.Server.Revolutionary.Components;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Objectives.Components;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -17,6 +17,7 @@ public sealed class KillPersonConditionSystem : EntitySystem
|
||||
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
|
||||
[Dependency] private readonly IConfigurationManager _config = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedJobSystem _job = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||
[Dependency] private readonly TargetObjectiveSystem _target = default!;
|
||||
|
||||
@@ -85,10 +86,11 @@ public sealed class KillPersonConditionSystem : EntitySystem
|
||||
}
|
||||
|
||||
var allHeads = new List<EntityUid>();
|
||||
foreach (var person in allHumans)
|
||||
foreach (var mind in allHumans)
|
||||
{
|
||||
if (TryComp<MindComponent>(person, out var mind) && mind.OwnedEntity is { } ent && HasComp<CommandStaffComponent>(ent))
|
||||
allHeads.Add(person);
|
||||
// RequireAdminNotify used as a cheap way to check for command department
|
||||
if (_job.MindTryGetJob(mind, out var prototype) && prototype.RequireAdminNotify)
|
||||
allHeads.Add(mind);
|
||||
}
|
||||
|
||||
if (allHeads.Count == 0)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Content.Server.Objectives.Components;
|
||||
using Content.Server.Revolutionary.Components;
|
||||
using Content.Shared.Objectives.Components;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
|
||||
namespace Content.Server.Objectives.Systems;
|
||||
|
||||
public sealed class NotCommandRequirementSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedJobSystem _job = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -18,7 +20,8 @@ public sealed class NotCommandRequirementSystem : EntitySystem
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
if (args.Mind.OwnedEntity is { } ent && HasComp<CommandStaffComponent>(ent))
|
||||
// cheap equivalent to checking that job department is command, since all command members require admin notification when leaving
|
||||
if (_job.MindTryGetJob(args.MindId, out var prototype) && prototype.RequireAdminNotify)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ using Content.Server.Shuttles.Events;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Decals;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Parallax.Biomes.Layers;
|
||||
@@ -52,7 +51,6 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
||||
|
||||
private EntityQuery<BiomeComponent> _biomeQuery;
|
||||
private EntityQuery<FixturesComponent> _fixturesQuery;
|
||||
private EntityQuery<GhostComponent> _ghostQuery;
|
||||
private EntityQuery<TransformComponent> _xformQuery;
|
||||
|
||||
private readonly HashSet<EntityUid> _handledEntities = new();
|
||||
@@ -83,7 +81,6 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
||||
Log.Level = LogLevel.Debug;
|
||||
_biomeQuery = GetEntityQuery<BiomeComponent>();
|
||||
_fixturesQuery = GetEntityQuery<FixturesComponent>();
|
||||
_ghostQuery = GetEntityQuery<GhostComponent>();
|
||||
_xformQuery = GetEntityQuery<TransformComponent>();
|
||||
SubscribeLocalEvent<BiomeComponent, MapInitEvent>(OnBiomeMapInit);
|
||||
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
|
||||
@@ -318,11 +315,6 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanLoad(EntityUid uid)
|
||||
{
|
||||
return !_ghostQuery.HasComp(uid);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
@@ -340,8 +332,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
||||
if (_xformQuery.TryGetComponent(pSession.AttachedEntity, out var xform) &&
|
||||
_handledEntities.Add(pSession.AttachedEntity.Value) &&
|
||||
_biomeQuery.TryGetComponent(xform.MapUid, out var biome) &&
|
||||
biome.Enabled &&
|
||||
CanLoad(pSession.AttachedEntity.Value))
|
||||
biome.Enabled)
|
||||
{
|
||||
var worldPos = _transform.GetWorldPosition(xform);
|
||||
AddChunksInRange(biome, worldPos);
|
||||
@@ -358,8 +349,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
||||
if (!_handledEntities.Add(viewer) ||
|
||||
!_xformQuery.TryGetComponent(viewer, out xform) ||
|
||||
!_biomeQuery.TryGetComponent(xform.MapUid, out biome) ||
|
||||
!biome.Enabled ||
|
||||
!CanLoad(viewer))
|
||||
!biome.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ public sealed partial class ApcComponent : BaseApcNetComponent
|
||||
|
||||
[DataField("enabled")]
|
||||
public bool MainBreakerEnabled = true;
|
||||
// TODO: remove this since it probably breaks when 2 people use it
|
||||
[DataField("hasAccess")]
|
||||
public bool HasAccess = false;
|
||||
|
||||
/// <summary>
|
||||
/// APC state needs to always be updated after first processing tick.
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Emp;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.Pow3r;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.APC;
|
||||
using Content.Shared.Emag.Components;
|
||||
@@ -70,8 +71,11 @@ public sealed class ApcSystem : EntitySystem
|
||||
component.NeedStateUpdate = true;
|
||||
}
|
||||
|
||||
//Update the HasAccess var for UI to read
|
||||
private void OnBoundUiOpen(EntityUid uid, ApcComponent component, BoundUIOpenedEvent args)
|
||||
{
|
||||
// TODO: this should be per-player not stored on the apc
|
||||
component.HasAccess = _accessReader.IsAllowed(args.Actor, uid);
|
||||
UpdateApcState(uid, component);
|
||||
}
|
||||
|
||||
@@ -161,7 +165,7 @@ public sealed class ApcSystem : EntitySystem
|
||||
// TODO: Fix ContentHelpers or make a new one coz this is cooked.
|
||||
var charge = ContentHelpers.RoundToNearestLevels(battery.CurrentStorage / battery.Capacity, 1.0, 100 / ChargeAccuracy) / 100f * ChargeAccuracy;
|
||||
|
||||
var state = new ApcBoundInterfaceState(apc.MainBreakerEnabled,
|
||||
var state = new ApcBoundInterfaceState(apc.MainBreakerEnabled, apc.HasAccess,
|
||||
(int) MathF.Ceiling(battery.CurrentSupply), apc.LastExternalState,
|
||||
charge);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.Components;
|
||||
using Content.Shared.Procedural.DungeonLayers;
|
||||
@@ -21,52 +20,44 @@ public sealed partial class DungeonJob
|
||||
{
|
||||
// Doesn't use dungeon data because layers and we don't need top-down support at the moment.
|
||||
|
||||
var emptyTiles = false;
|
||||
var replaceEntities = new Dictionary<Vector2i, EntityUid>();
|
||||
var availableTiles = new List<Vector2i>();
|
||||
var tiles = _maps.GetAllTilesEnumerator(_gridUid, _grid);
|
||||
|
||||
while (tiles.MoveNext(out var tileRef))
|
||||
foreach (var node in dungeon.AllTiles)
|
||||
{
|
||||
var tile = tileRef.Value.GridIndices;
|
||||
// Empty tile, skip if relevant.
|
||||
if (!emptyTiles && (!_maps.TryGetTile(_grid, node, out var tile) || tile.IsEmpty))
|
||||
continue;
|
||||
|
||||
//Tile mask filtering
|
||||
if (gen.TileMask is not null)
|
||||
{
|
||||
if (!gen.TileMask.Contains(((ContentTileDefinition) _tileDefManager[tileRef.Value.Tile.TypeId]).ID))
|
||||
continue;
|
||||
}
|
||||
// Check if it's a valid spawn, if so then use it.
|
||||
var enumerator = _maps.GetAnchoredEntitiesEnumerator(_gridUid, _grid, node);
|
||||
var found = false;
|
||||
|
||||
//Entity mask filtering
|
||||
if (gen.EntityMask is not null)
|
||||
// We use existing entities as a mark to spawn in place
|
||||
// OR
|
||||
// We check for any existing entities to see if we can spawn there.
|
||||
while (enumerator.MoveNext(out var uid))
|
||||
{
|
||||
var found = false;
|
||||
var enumerator2 = _maps.GetAnchoredEntitiesEnumerator(_gridUid, _grid, tile);
|
||||
while (enumerator2.MoveNext(out var uid))
|
||||
// We can't replace so just stop here.
|
||||
if (gen.Replacement == null)
|
||||
break;
|
||||
|
||||
var prototype = _entManager.GetComponent<MetaDataComponent>(uid.Value).EntityPrototype;
|
||||
|
||||
if (prototype?.ID == gen.Replacement)
|
||||
{
|
||||
var prototype = _entManager.GetComponent<MetaDataComponent>(uid.Value).EntityPrototype;
|
||||
|
||||
if (prototype?.ID is null)
|
||||
continue;
|
||||
|
||||
if (!gen.EntityMask.Contains(prototype.ID))
|
||||
continue;
|
||||
|
||||
replaceEntities[tile] = uid.Value;
|
||||
replaceEntities[node] = uid.Value;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//If entity mask null - we ignore the tiles that have anything on them.
|
||||
if (!_anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
}
|
||||
if (!found)
|
||||
continue;
|
||||
|
||||
// Add it to valid nodes.
|
||||
availableTiles.Add(tile);
|
||||
availableTiles.Add(node);
|
||||
|
||||
await SuspendDungeon();
|
||||
|
||||
@@ -148,7 +139,7 @@ public sealed partial class DungeonJob
|
||||
|
||||
if (groupSize > 0)
|
||||
{
|
||||
_sawmill.Warning($"Found remaining group size for ore veins of {gen.Entity.Id ?? "null"}!");
|
||||
_sawmill.Warning($"Found remaining group size for ore veins of {gen.Replacement ?? "null"}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Parallax;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.PostGeneration;
|
||||
@@ -16,35 +15,27 @@ public sealed partial class DungeonJob
|
||||
/// </summary>
|
||||
private async Task PostGen(BiomeDunGen dunGen, DungeonData data, Dungeon dungeon, HashSet<Vector2i> reservedTiles, Random random)
|
||||
{
|
||||
if (!_prototype.TryIndex(dunGen.BiomeTemplate, out var indexedBiome))
|
||||
if (_entManager.TryGetComponent(_gridUid, out BiomeComponent? biomeComp))
|
||||
return;
|
||||
|
||||
biomeComp = _entManager.AddComponent<BiomeComponent>(_gridUid);
|
||||
var biomeSystem = _entManager.System<BiomeSystem>();
|
||||
|
||||
biomeSystem.SetTemplate(_gridUid, biomeComp, _prototype.Index(dunGen.BiomeTemplate));
|
||||
var seed = random.Next();
|
||||
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
var tiles = _maps.GetAllTilesEnumerator(_gridUid, _grid);
|
||||
while (tiles.MoveNext(out var tileRef))
|
||||
foreach (var node in dungeon.RoomTiles)
|
||||
{
|
||||
var node = tileRef.Value.GridIndices;
|
||||
|
||||
if (reservedTiles.Contains(node))
|
||||
continue;
|
||||
|
||||
if (dunGen.TileMask is not null)
|
||||
{
|
||||
if (!dunGen.TileMask.Contains(((ContentTileDefinition) _tileDefManager[tileRef.Value.Tile.TypeId]).ID))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Need to set per-tile to override data.
|
||||
if (biomeSystem.TryGetTile(node, indexedBiome.Layers, seed, _grid, out var tile))
|
||||
if (biomeSystem.TryGetTile(node, biomeComp.Layers, seed, _grid, out var tile))
|
||||
{
|
||||
_maps.SetTile(_gridUid, _grid, node, tile.Value);
|
||||
}
|
||||
|
||||
if (biomeSystem.TryGetDecals(node, indexedBiome.Layers, seed, _grid, out var decals))
|
||||
if (biomeSystem.TryGetDecals(node, biomeComp.Layers, seed, _grid, out var decals))
|
||||
{
|
||||
foreach (var decal in decals)
|
||||
{
|
||||
@@ -52,7 +43,7 @@ public sealed partial class DungeonJob
|
||||
}
|
||||
}
|
||||
|
||||
if (tile is not null && biomeSystem.TryGetEntity(node, indexedBiome.Layers, tile.Value, seed, _grid, out var entityProto))
|
||||
if (biomeSystem.TryGetEntity(node, biomeComp, _grid, out var entityProto))
|
||||
{
|
||||
var ent = _entManager.SpawnEntity(entityProto, new EntityCoordinates(_gridUid, node + _grid.TileSizeHalfVector));
|
||||
var xform = xformQuery.Get(ent);
|
||||
@@ -70,5 +61,7 @@ public sealed partial class DungeonJob
|
||||
if (!ValidateResume())
|
||||
return;
|
||||
}
|
||||
|
||||
biomeComp.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,13 @@ namespace Content.Server.Procedural;
|
||||
public sealed partial class DungeonSystem
|
||||
{
|
||||
// Temporary caches.
|
||||
private readonly HashSet<EntityUid> _entitySet = new();
|
||||
private readonly List<DungeonRoomPrototype> _availableRooms = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random dungeon room matching the specified area and whitelist.
|
||||
/// </summary>
|
||||
public DungeonRoomPrototype? GetRoomPrototype(Random random, EntityWhitelist? whitelist = null, Vector2i? size = null)
|
||||
public DungeonRoomPrototype? GetRoomPrototype(Vector2i size, Random random, EntityWhitelist? whitelist = null)
|
||||
{
|
||||
// Can never be true.
|
||||
if (whitelist is { Tags: null })
|
||||
@@ -30,7 +31,7 @@ public sealed partial class DungeonSystem
|
||||
|
||||
foreach (var proto in _prototype.EnumeratePrototypes<DungeonRoomPrototype>())
|
||||
{
|
||||
if (size is not null && proto.Size != size)
|
||||
if (proto.Size != size)
|
||||
continue;
|
||||
|
||||
if (whitelist == null)
|
||||
@@ -98,20 +99,6 @@ public sealed partial class DungeonSystem
|
||||
return roomRotation;
|
||||
}
|
||||
|
||||
private static Box2 GetRotatedBox(Vector2 point1, Vector2 point2, double angle)
|
||||
{
|
||||
if (angle == 0)
|
||||
return new Box2(point1, point2);
|
||||
if (Math.Abs(angle - Math.PI / 2) < 1E-5)
|
||||
return new Box2(point2.X, point1.Y, point1.X, point2.Y);
|
||||
if (Math.Abs(angle - Math.PI) < 1E-5)
|
||||
return new Box2(point2, point1);
|
||||
if (Math.Abs(angle + Math.PI / 2) < 1E-5)
|
||||
return new Box2(point1.X, point2.Y, point2.X, point1.Y);
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SpawnRoom(
|
||||
EntityUid gridUid,
|
||||
MapGridComponent grid,
|
||||
@@ -126,24 +113,18 @@ public sealed partial class DungeonSystem
|
||||
var templateGrid = Comp<MapGridComponent>(templateMapUid);
|
||||
var roomDimensions = room.Size;
|
||||
|
||||
var entitySet = new HashSet<EntityUid>();
|
||||
|
||||
var finalRoomRotation = roomTransform.Rotation();
|
||||
|
||||
/*
|
||||
// go BRRNNTTT on existing stuff
|
||||
if (clearExisting)
|
||||
{
|
||||
var point1 = Vector2.Transform(-room.Size / 2, roomTransform);
|
||||
var point2 = Vector2.Transform(room.Size / 2, roomTransform);
|
||||
|
||||
var gridBounds = GetRotatedBox(point1, point2, finalRoomRotation);
|
||||
|
||||
entitySet.Clear();
|
||||
var gridBounds = new Box2(Vector2.Transform(-room.Size/2, roomTransform), Vector2.Transform(room.Size/2, roomTransform));
|
||||
_entitySet.Clear();
|
||||
// Polygon skin moment
|
||||
gridBounds = gridBounds.Enlarged(-0.05f);
|
||||
_lookup.GetLocalEntitiesIntersecting(gridUid, gridBounds, entitySet, LookupFlags.Uncontained);
|
||||
_lookup.GetLocalEntitiesIntersecting(gridUid, gridBounds, _entitySet, LookupFlags.Uncontained);
|
||||
|
||||
foreach (var templateEnt in entitySet)
|
||||
foreach (var templateEnt in _entitySet)
|
||||
{
|
||||
Del(templateEnt);
|
||||
}
|
||||
@@ -156,7 +137,6 @@ public sealed partial class DungeonSystem
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
var roomCenter = (room.Offset + room.Size / 2f) * grid.TileSize;
|
||||
var tileOffset = -roomCenter + grid.TileSizeHalfVector;
|
||||
@@ -176,24 +156,7 @@ public sealed partial class DungeonSystem
|
||||
if (!clearExisting && reservedTiles?.Contains(rounded) == true)
|
||||
continue;
|
||||
|
||||
if (room.IgnoreTile is not null)
|
||||
{
|
||||
if (_maps.TryGetTileDef(templateGrid, indices, out var tileDef) && room.IgnoreTile == tileDef.ID)
|
||||
continue;
|
||||
}
|
||||
|
||||
_tiles.Add((rounded, tileRef.Tile));
|
||||
|
||||
//CP14 clearExisting variant
|
||||
if (clearExisting)
|
||||
{
|
||||
var anchored = _maps.GetAnchoredEntities((gridUid, grid), rounded);
|
||||
foreach (var ent in anchored)
|
||||
{
|
||||
QueueDel(ent);
|
||||
}
|
||||
}
|
||||
//CP14 clearExisting variant end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ public sealed partial class DungeonSystem : SharedDungeonSystem
|
||||
|
||||
private const double DungeonJobTime = 0.005;
|
||||
|
||||
public const int CollisionMask = (int) CollisionGroup.AllMask; //CP14 replace to AllMask
|
||||
public const int CollisionLayer = (int) CollisionGroup.AllMask; //CP14 replace to AllMask
|
||||
public const int CollisionMask = (int) CollisionGroup.Impassable;
|
||||
public const int CollisionLayer = (int) CollisionGroup.Impassable;
|
||||
|
||||
private readonly JobQueue _dungeonJobQueue = new(DungeonJobTime);
|
||||
private readonly Dictionary<DungeonJob.DungeonJob, CancellationTokenSource> _dungeonJobs = new();
|
||||
|
||||
@@ -20,15 +20,15 @@ public sealed partial class RoomFillComponent : Component
|
||||
/// <summary>
|
||||
/// Size of the room to fill.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public Vector2i? Size;
|
||||
[DataField(required: true)]
|
||||
public Vector2i Size;
|
||||
|
||||
/// <summary>
|
||||
/// Rooms allowed for the marker.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityWhitelist? RoomWhitelist;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Should any existing entities / decals be bulldozed first.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,7 +24,7 @@ public sealed class RoomFillSystem : EntitySystem
|
||||
if (xform.GridUid != null)
|
||||
{
|
||||
var random = new Random();
|
||||
var room = _dungeon.GetRoomPrototype(random, component.RoomWhitelist, component.Size);
|
||||
var room = _dungeon.GetRoomPrototype(component.Size, random, component.RoomWhitelist);
|
||||
|
||||
if (room != null)
|
||||
{
|
||||
@@ -32,7 +32,7 @@ public sealed class RoomFillSystem : EntitySystem
|
||||
_dungeon.SpawnRoom(
|
||||
xform.GridUid.Value,
|
||||
mapGrid,
|
||||
_maps.LocalToTile(xform.GridUid.Value, mapGrid, xform.Coordinates) - new Vector2i(room.Size.X/2,room.Size.Y/2), //CP14 Offset for halfroom
|
||||
_maps.LocalToTile(xform.GridUid.Value, mapGrid, xform.Coordinates),
|
||||
room,
|
||||
random,
|
||||
null,
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
// Used to prevent a shitter from using a bunch of radios to spam chat.
|
||||
private HashSet<(string, EntityUid, RadioChannelPrototype)> _recentlySent = new();
|
||||
private HashSet<(string, EntityUid)> _recentlySent = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
{
|
||||
if (args.Powered)
|
||||
return;
|
||||
SetMicrophoneEnabled(uid, null, false, true, component);
|
||||
SetMicrophoneEnabled(uid, null, false, true, component);
|
||||
}
|
||||
|
||||
public void SetMicrophoneEnabled(EntityUid uid, EntityUid? user, bool enabled, bool quiet = false, RadioMicrophoneComponent? component = null)
|
||||
@@ -191,9 +191,8 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
if (HasComp<RadioSpeakerComponent>(args.Source))
|
||||
return; // no feedback loops please.
|
||||
|
||||
var channel = _protoMan.Index<RadioChannelPrototype>(component.BroadcastChannel)!;
|
||||
if (_recentlySent.Add((args.Message, args.Source, channel)))
|
||||
_radio.SendRadioMessage(args.Source, args.Message, channel, uid);
|
||||
if (_recentlySent.Add((args.Message, args.Source)))
|
||||
_radio.SendRadioMessage(args.Source, args.Message, _protoMan.Index<RadioChannelPrototype>(component.BroadcastChannel), uid);
|
||||
}
|
||||
|
||||
private void OnAttemptListen(EntityUid uid, RadioMicrophoneComponent component, ListenAttemptEvent args)
|
||||
@@ -280,7 +279,7 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
if (TryComp<RadioMicrophoneComponent>(ent, out var mic))
|
||||
mic.BroadcastChannel = channel;
|
||||
if (TryComp<RadioSpeakerComponent>(ent, out var speaker))
|
||||
speaker.Channels = new() { channel };
|
||||
speaker.Channels = new(){ channel };
|
||||
Dirty(ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Content.Server.GameTicking.Rules;
|
||||
|
||||
namespace Content.Server.Revolutionary.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Given to heads at round start. Used for assigning traitors to kill heads and for revs to check if the heads died or not.
|
||||
/// Given to heads at round start for Revs. Used for tracking if heads died or not.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, Access(typeof(RevolutionaryRuleSystem))]
|
||||
public sealed partial class CommandStaffComponent : Component
|
||||
{
|
||||
|
||||
|
||||
@@ -12,13 +12,9 @@ using Robust.Shared.Timing;
|
||||
namespace Content.Server.ServerUpdates;
|
||||
|
||||
/// <summary>
|
||||
/// Responsible for restarting the server periodically or for update, when not disruptive.
|
||||
/// Responsible for restarting the server for update, when not disruptive.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This was originally only designed for restarting on *update*,
|
||||
/// but now also handles periodic restarting to keep server uptime via <see cref="CCVars.ServerUptimeRestartMinutes"/>.
|
||||
/// </remarks>
|
||||
public sealed class ServerUpdateManager : IPostInjectInit
|
||||
public sealed class ServerUpdateManager
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IWatchdogApi _watchdog = default!;
|
||||
@@ -26,43 +22,23 @@ public sealed class ServerUpdateManager : IPostInjectInit
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
[Dependency] private readonly IBaseServer _server = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private bool _updateOnRoundEnd;
|
||||
|
||||
private TimeSpan? _restartTime;
|
||||
|
||||
private TimeSpan _uptimeRestart;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_watchdog.UpdateReceived += WatchdogOnUpdateReceived;
|
||||
_playerManager.PlayerStatusChanged += PlayerManagerOnPlayerStatusChanged;
|
||||
|
||||
_cfg.OnValueChanged(
|
||||
CCVars.ServerUptimeRestartMinutes,
|
||||
minutes => _uptimeRestart = TimeSpan.FromMinutes(minutes),
|
||||
true);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_restartTime != null)
|
||||
if (_restartTime != null && _restartTime < _gameTiming.RealTime)
|
||||
{
|
||||
if (_restartTime < _gameTiming.RealTime)
|
||||
{
|
||||
DoShutdown();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ShouldShutdownDueToUptime())
|
||||
{
|
||||
ServerEmptyUpdateRestartCheck("uptime");
|
||||
}
|
||||
DoShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +48,7 @@ public sealed class ServerUpdateManager : IPostInjectInit
|
||||
/// <returns>True if the server is going to restart.</returns>
|
||||
public bool RoundEnded()
|
||||
{
|
||||
if (_updateOnRoundEnd || ShouldShutdownDueToUptime())
|
||||
if (_updateOnRoundEnd)
|
||||
{
|
||||
DoShutdown();
|
||||
return true;
|
||||
@@ -85,14 +61,11 @@ public sealed class ServerUpdateManager : IPostInjectInit
|
||||
{
|
||||
switch (e.NewStatus)
|
||||
{
|
||||
case SessionStatus.Connected:
|
||||
if (_restartTime != null)
|
||||
_sawmill.Debug("Aborting server restart timer due to player connection");
|
||||
|
||||
case SessionStatus.Connecting:
|
||||
_restartTime = null;
|
||||
break;
|
||||
case SessionStatus.Disconnected:
|
||||
ServerEmptyUpdateRestartCheck("last player disconnect");
|
||||
ServerEmptyUpdateRestartCheck();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -101,20 +74,20 @@ public sealed class ServerUpdateManager : IPostInjectInit
|
||||
{
|
||||
_chatManager.DispatchServerAnnouncement(Loc.GetString("server-updates-received"));
|
||||
_updateOnRoundEnd = true;
|
||||
ServerEmptyUpdateRestartCheck("update notification");
|
||||
ServerEmptyUpdateRestartCheck();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether there are still players on the server,
|
||||
/// and if not starts a timer to automatically reboot the server if an update is available.
|
||||
/// </summary>
|
||||
private void ServerEmptyUpdateRestartCheck(string reason)
|
||||
private void ServerEmptyUpdateRestartCheck()
|
||||
{
|
||||
// Can't simple check the current connected player count since that doesn't update
|
||||
// before PlayerStatusChanged gets fired.
|
||||
// So in the disconnect handler we'd still see a single player otherwise.
|
||||
var playersOnline = _playerManager.Sessions.Any(p => p.Status != SessionStatus.Disconnected);
|
||||
if (playersOnline || !(_updateOnRoundEnd || ShouldShutdownDueToUptime()))
|
||||
if (playersOnline || !_updateOnRoundEnd)
|
||||
{
|
||||
// Still somebody online.
|
||||
return;
|
||||
@@ -122,30 +95,16 @@ public sealed class ServerUpdateManager : IPostInjectInit
|
||||
|
||||
if (_restartTime != null)
|
||||
{
|
||||
// Do nothing because we already have a timer running.
|
||||
// Do nothing because I guess we already have a timer running..?
|
||||
return;
|
||||
}
|
||||
|
||||
var restartDelay = TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.UpdateRestartDelay));
|
||||
_restartTime = restartDelay + _gameTiming.RealTime;
|
||||
|
||||
_sawmill.Debug("Started server-empty restart timer due to {Reason}", reason);
|
||||
}
|
||||
|
||||
private void DoShutdown()
|
||||
{
|
||||
_sawmill.Debug($"Shutting down via {nameof(ServerUpdateManager)}!");
|
||||
var reason = _updateOnRoundEnd ? "server-updates-shutdown" : "server-updates-shutdown-uptime";
|
||||
_server.Shutdown(Loc.GetString(reason));
|
||||
}
|
||||
|
||||
private bool ShouldShutdownDueToUptime()
|
||||
{
|
||||
return _uptimeRestart != TimeSpan.Zero && _gameTiming.RealTime > _uptimeRestart;
|
||||
}
|
||||
|
||||
void IPostInjectInit.PostInject()
|
||||
{
|
||||
_sawmill = _logManager.GetSawmill("restart");
|
||||
_server.Shutdown(Loc.GetString("server-updates-shutdown"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Labels;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Creates FTL disks, to maps, grids, or entities.
|
||||
/// </summary>
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
|
||||
public sealed class FTLDiskCommand : LocalizedCommands
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _entSystemManager = default!;
|
||||
|
||||
public override string Command => "ftldisk";
|
||||
|
||||
[ValidatePrototypeId<EntityPrototype>]
|
||||
public const string CoordinatesDisk = "CoordinatesDisk";
|
||||
|
||||
[ValidatePrototypeId<EntityPrototype>]
|
||||
public const string DiskCase = "DiskCase";
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-need-minimum-one-argument"));
|
||||
return;
|
||||
}
|
||||
|
||||
var player = shell.Player;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("shell-only-players-can-run-this-command"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity == null)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("shell-must-be-attached-to-entity"));
|
||||
return;
|
||||
}
|
||||
|
||||
EntityUid entity = player.AttachedEntity.Value;
|
||||
var coords = _entManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
|
||||
var handsSystem = _entSystemManager.GetEntitySystem<SharedHandsSystem>();
|
||||
var labelSystem = _entSystemManager.GetEntitySystem<LabelSystem>();
|
||||
var mapSystem = _entSystemManager.GetEntitySystem<SharedMapSystem>();
|
||||
var storageSystem = _entSystemManager.GetEntitySystem<SharedStorageSystem>();
|
||||
|
||||
foreach (var destinations in args)
|
||||
{
|
||||
DebugTools.AssertNotNull(destinations);
|
||||
|
||||
// make sure destination is an id.
|
||||
EntityUid dest;
|
||||
|
||||
if (_entManager.TryParseNetEntity(destinations, out var nullableDest))
|
||||
{
|
||||
DebugTools.AssertNotNull(nullableDest);
|
||||
|
||||
dest = (EntityUid) nullableDest;
|
||||
|
||||
// we need to go to a map, so check if the EntID is something else then try for its map
|
||||
if (!_entManager.HasComponent<MapComponent>(dest))
|
||||
{
|
||||
if (!_entManager.TryGetComponent<TransformComponent>(dest, out var entTransform))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-no-transform", ("destination", destinations)));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mapSystem.TryGetMap(entTransform.MapID, out var mapDest))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-no-map", ("destination", destinations)));
|
||||
continue;
|
||||
}
|
||||
|
||||
DebugTools.AssertNotNull(mapDest);
|
||||
dest = mapDest!.Value; // explicit cast here should be fine since the previous if should catch it.
|
||||
}
|
||||
|
||||
// find and verify the map is not somehow unusable.
|
||||
if (!_entManager.TryGetComponent<MapComponent>(dest, out var mapComp)) // We have to check for a MapComponent here and above since we could have changed our dest entity.
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-no-map-comp", ("destination", destinations), ("map", dest)));
|
||||
continue;
|
||||
}
|
||||
if (mapComp.MapInitialized == false)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-map-not-init", ("destination", destinations), ("map", dest)));
|
||||
continue;
|
||||
}
|
||||
if (mapComp.MapPaused == true)
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-map-paused", ("destination", destinations), ("map", dest)));
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if our destination works already, if not, make it.
|
||||
if (!_entManager.TryGetComponent<FTLDestinationComponent>(dest, out var ftlDestComp))
|
||||
{
|
||||
FTLDestinationComponent ftlDest = _entManager.AddComponent<FTLDestinationComponent>(dest);
|
||||
ftlDest.RequireCoordinateDisk = true;
|
||||
|
||||
if (_entManager.HasComponent<MapGridComponent>(dest))
|
||||
{
|
||||
ftlDest.BeaconsOnly = true;
|
||||
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-planet", ("destination", destinations), ("map", dest)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't do these automatically, since it isn't clear what the correct resolution is. Instead we provide feedback to the user and carry on like they know what theyre doing.
|
||||
if (ftlDestComp.Enabled == false)
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-already-dest-not-enabled", ("destination", destinations), ("map", dest)));
|
||||
|
||||
if (ftlDestComp.BeaconsOnly == true)
|
||||
shell.WriteLine(Loc.GetString("cmd-ftldisk-requires-ftl-point", ("destination", destinations), ("map", dest)));
|
||||
}
|
||||
|
||||
// create the FTL disk
|
||||
EntityUid cdUid = _entManager.SpawnEntity(CoordinatesDisk, coords);
|
||||
var cd = _entManager.EnsureComponent<ShuttleDestinationCoordinatesComponent>(cdUid);
|
||||
cd.Destination = dest;
|
||||
_entManager.Dirty(cdUid, cd);
|
||||
|
||||
// create disk case
|
||||
EntityUid cdCaseUid = _entManager.SpawnEntity(DiskCase, coords);
|
||||
|
||||
// apply labels
|
||||
if (_entManager.TryGetComponent<MetaDataComponent>(dest, out var meta) && meta != null && meta.EntityName != null)
|
||||
{
|
||||
labelSystem.Label(cdUid, meta.EntityName);
|
||||
labelSystem.Label(cdCaseUid, meta.EntityName);
|
||||
}
|
||||
|
||||
// if the case has a storage, try to place the disk in there and then the case inhand
|
||||
|
||||
if (_entManager.TryGetComponent<StorageComponent>(cdCaseUid, out var storage) && storageSystem.Insert(cdCaseUid, cdUid, out _, storageComp: storage, playSound: false))
|
||||
{
|
||||
if (_entManager.TryGetComponent<HandsComponent>(entity, out var handsComponent) && handsSystem.TryGetEmptyHand(entity, out var emptyHand, handsComponent))
|
||||
{
|
||||
handsSystem.TryPickup(entity, cdCaseUid, emptyHand, checkActionBlocker: false, handsComp: handsComponent);
|
||||
}
|
||||
}
|
||||
else // the case was messed up, put disk inhand
|
||||
{
|
||||
_entManager.DeleteEntity(cdCaseUid); // something went wrong so just yeet the chaf
|
||||
|
||||
if (_entManager.TryGetComponent<HandsComponent>(entity, out var handsComponent) && handsSystem.TryGetEmptyHand(entity, out var emptyHand, handsComponent))
|
||||
{
|
||||
handsSystem.TryPickup(entity, cdUid, emptyHand, checkActionBlocker: false, handsComp: handsComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("shell-invalid-entity-uid", ("uid", destinations)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length >= 1)
|
||||
return CompletionResult.FromHintOptions(CompletionHelper.MapUids(_entManager), Loc.GetString("cmd-ftldisk-hint"));
|
||||
return CompletionResult.Empty;
|
||||
}
|
||||
}
|
||||
@@ -60,10 +60,6 @@ public sealed partial class BorgSystem
|
||||
|
||||
if (_actions.AddAction(chassis, ref component.ModuleSwapActionEntity, out var action, component.ModuleSwapActionId, uid))
|
||||
{
|
||||
if(TryComp<BorgModuleIconComponent>(uid, out var moduleIconComp))
|
||||
{
|
||||
action.Icon = moduleIconComp.Icon;
|
||||
};
|
||||
action.EntityIcon = uid;
|
||||
Dirty(component.ModuleSwapActionEntity.Value, action);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Eui;
|
||||
@@ -52,8 +52,8 @@ public sealed class SiliconLawEui : BaseEui
|
||||
return;
|
||||
|
||||
var player = _entityManager.GetEntity(message.Target);
|
||||
if (_entityManager.TryGetComponent<SiliconLawProviderComponent>(player, out var playerProviderComp))
|
||||
_siliconLawSystem.SetLaws(message.Laws, player, playerProviderComp.LawUploadSound);
|
||||
|
||||
_siliconLawSystem.SetLaws(message.Laws, player);
|
||||
}
|
||||
|
||||
private bool IsAllowed()
|
||||
|
||||
@@ -21,8 +21,6 @@ using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Toolshed;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Silicons.Laws;
|
||||
|
||||
@@ -115,7 +113,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
component.Lawset = args.Lawset;
|
||||
|
||||
// gotta tell player to check their laws
|
||||
NotifyLawsChanged(uid, component.LawUploadSound);
|
||||
NotifyLawsChanged(uid);
|
||||
|
||||
// new laws may allow antagonist behaviour so make it clear for admins
|
||||
if (TryComp<EmagSiliconLawComponent>(uid, out var emag))
|
||||
@@ -151,11 +149,14 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
return;
|
||||
|
||||
base.OnGotEmagged(uid, component, ref args);
|
||||
NotifyLawsChanged(uid, component.EmaggedSound);
|
||||
NotifyLawsChanged(uid);
|
||||
EnsureEmaggedRole(uid, component);
|
||||
|
||||
_stunSystem.TryParalyze(uid, component.StunTime, true);
|
||||
|
||||
if (!_mind.TryGetMind(uid, out var mindId, out _))
|
||||
return;
|
||||
_roles.MindPlaySound(mindId, component.EmaggedSound);
|
||||
}
|
||||
|
||||
private void OnEmagMindAdded(EntityUid uid, EmagSiliconLawComponent component, MindAddedMessage args)
|
||||
@@ -236,7 +237,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
return ev.Laws;
|
||||
}
|
||||
|
||||
public void NotifyLawsChanged(EntityUid uid, SoundSpecifier? cue = null)
|
||||
public void NotifyLawsChanged(EntityUid uid)
|
||||
{
|
||||
if (!TryComp<ActorComponent>(uid, out var actor))
|
||||
return;
|
||||
@@ -244,9 +245,6 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
var msg = Loc.GetString("laws-update-notify");
|
||||
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", msg));
|
||||
_chatManager.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.Channel, colorOverride: Color.Red);
|
||||
|
||||
if (cue != null && _mind.TryGetMind(uid, out var mindId, out _))
|
||||
_roles.MindPlaySound(mindId, cue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -271,7 +269,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
/// <summary>
|
||||
/// Set the laws of a silicon entity while notifying the player.
|
||||
/// </summary>
|
||||
public void SetLaws(List<SiliconLaw> newLaws, EntityUid target, SoundSpecifier? cue = null)
|
||||
public void SetLaws(List<SiliconLaw> newLaws, EntityUid target)
|
||||
{
|
||||
if (!TryComp<SiliconLawProviderComponent>(target, out var component))
|
||||
return;
|
||||
@@ -280,7 +278,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
component.Lawset = new SiliconLawset();
|
||||
|
||||
component.Lawset.Laws = newLaws;
|
||||
NotifyLawsChanged(target, cue);
|
||||
NotifyLawsChanged(target);
|
||||
}
|
||||
|
||||
protected override void OnUpdaterInsert(Entity<SiliconLawUpdaterComponent> ent, ref EntInsertedIntoContainerMessage args)
|
||||
@@ -294,7 +292,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
|
||||
while (query.MoveNext(out var update))
|
||||
{
|
||||
SetLaws(lawset, update, provider.LawUploadSound);
|
||||
SetLaws(lawset, update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user