diff --git a/Robust.Client/Audio/AudioManager.Public.cs b/Robust.Client/Audio/AudioManager.Public.cs
index 7677c680e..8cb573f38 100644
--- a/Robust.Client/Audio/AudioManager.Public.cs
+++ b/Robust.Client/Audio/AudioManager.Public.cs
@@ -302,7 +302,7 @@ internal partial class AudioManager
}
///
- IBufferedAudioSource? IAudioInternal.CreateBufferedAudioSource(int buffers, bool floatAudio=false)
+ IBufferedAudioSource? IAudioInternal.CreateBufferedAudioSource(int buffers, bool floatAudio)
{
var source = AL.GenSource();
diff --git a/Robust.Client/Audio/AudioOverlay.cs b/Robust.Client/Audio/AudioOverlay.cs
index 9cf129d0a..0900eacb9 100644
--- a/Robust.Client/Audio/AudioOverlay.cs
+++ b/Robust.Client/Audio/AudioOverlay.cs
@@ -46,7 +46,7 @@ public sealed class AudioOverlay : Overlay
var screenHandle = args.ScreenHandle;
var output = new StringBuilder();
- var listenerPos = _entManager.GetComponent(localPlayer.Value).MapPosition;
+ var listenerPos = _transform.GetMapCoordinates(_entManager.GetComponent(localPlayer.Value));
if (listenerPos.MapId != args.MapId)
return;
diff --git a/Robust.Client/Audio/Sources/BufferedAudioSource.cs b/Robust.Client/Audio/Sources/BufferedAudioSource.cs
index 3ce4e456f..066887ddf 100644
--- a/Robust.Client/Audio/Sources/BufferedAudioSource.cs
+++ b/Robust.Client/Audio/Sources/BufferedAudioSource.cs
@@ -1,24 +1,18 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Numerics;
using OpenTK.Audio.OpenAL;
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
-using Robust.Client.Graphics;
using Robust.Shared.Audio.Sources;
-using Robust.Shared.Maths;
namespace Robust.Client.Audio.Sources;
internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSource
{
- private int? SourceHandle = null;
private int[] BufferHandles;
private Dictionary BufferMap = new();
private readonly AudioManager _master;
private bool _mono = true;
private bool _float = false;
- private int FilterHandle;
public int SampleRate { get; set; } = 44100;
@@ -43,7 +37,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
get
{
_checkDisposed();
- var state = AL.GetSourceState(SourceHandle!.Value);
+ var state = AL.GetSourceState(SourceHandle);
_master._checkAlError();
return state == ALSourceState.Playing;
}
@@ -53,7 +47,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
{
_checkDisposed();
// IDK why this stackallocs but gonna leave it for now.
- AL.SourcePlay(stackalloc int[] {SourceHandle!.Value});
+ AL.SourcePlay(stackalloc int[] {SourceHandle});
_master._checkAlError();
}
else
@@ -61,7 +55,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
if (_isDisposed())
return;
- AL.SourceStop(SourceHandle!.Value);
+ AL.SourceStop(SourceHandle);
_master._checkAlError();
}
}
@@ -74,13 +68,13 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
protected override void Dispose(bool disposing)
{
- if (SourceHandle == null)
+ if (SourceHandle == -1)
return;
if (!_master.IsMainThread())
{
// We can't run this code inside another thread so tell Clyde to clear it up later.
- _master.DeleteBufferedSourceOnMainThread(SourceHandle.Value, FilterHandle);
+ _master.DeleteBufferedSourceOnMainThread(SourceHandle, FilterHandle);
foreach (var handle in BufferHandles)
{
@@ -92,21 +86,21 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
if (FilterHandle != 0)
EFX.DeleteFilter(FilterHandle);
- AL.DeleteSource(SourceHandle.Value);
+ AL.DeleteSource(SourceHandle);
AL.DeleteBuffers(BufferHandles);
- _master.RemoveBufferedAudioSource(SourceHandle.Value);
+ _master.RemoveBufferedAudioSource(SourceHandle);
_master._checkAlError();
}
FilterHandle = 0;
- SourceHandle = null;
+ SourceHandle = -1;
}
public int GetNumberOfBuffersProcessed()
{
_checkDisposed();
// ReSharper disable once PossibleInvalidOperationException
- AL.GetSource(SourceHandle!.Value, ALGetSourcei.BuffersProcessed, out var buffersProcessed);
+ AL.GetSource(SourceHandle, ALGetSourcei.BuffersProcessed, out var buffersProcessed);
return buffersProcessed;
}
@@ -116,7 +110,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
var entries = Math.Min(Math.Min(handles.Length, BufferHandles.Length), GetNumberOfBuffersProcessed());
fixed (int* ptr = handles)
{
- AL.SourceUnqueueBuffers(SourceHandle!.Value, entries, ptr);
+ AL.SourceUnqueueBuffers(SourceHandle, entries, ptr);
}
for (var i = 0; i < entries; i++)
@@ -183,7 +177,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
fixed (int* ptr = realHandles)
// ReSharper disable once PossibleInvalidOperationException
{
- AL.SourceQueueBuffers(SourceHandle!.Value, handles.Length, ptr);
+ AL.SourceQueueBuffers(SourceHandle, handles.Length, ptr);
}
}
diff --git a/Robust.Client/Console/Commands/Debug.cs b/Robust.Client/Console/Commands/Debug.cs
index 3a5e2df0a..af9c472ef 100644
--- a/Robust.Client/Console/Commands/Debug.cs
+++ b/Robust.Client/Console/Commands/Debug.cs
@@ -291,9 +291,9 @@ namespace Robust.Client.Console.Commands
}
}
- internal sealed class SnapGridGetCell : LocalizedCommands
+ internal sealed class SnapGridGetCell : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entManager = default!;
+ [Dependency] private readonly SharedMapSystem _map = default!;
public override string Command => "sggcell";
@@ -319,9 +319,10 @@ namespace Robust.Client.Console.Commands
return;
}
- if (_entManager.TryGetComponent(_entManager.GetEntity(gridNet), out var grid))
+ var gridEnt = EntityManager.GetEntity(gridNet);
+ if (EntityManager.TryGetComponent(gridEnt, out var grid))
{
- foreach (var entity in grid.GetAnchoredEntities(new Vector2i(
+ foreach (var entity in _map.GetAnchoredEntities(gridEnt, grid, new Vector2i(
int.Parse(indices.Split(',')[0], CultureInfo.InvariantCulture),
int.Parse(indices.Split(',')[1], CultureInfo.InvariantCulture))))
{
@@ -425,9 +426,9 @@ namespace Robust.Client.Console.Commands
}
}
- internal sealed class GridTileCount : LocalizedCommands
+ internal sealed class GridTileCount : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entManager = default!;
+ [Dependency] private readonly SharedMapSystem _map = default!;
public override string Command => "gridtc";
@@ -440,15 +441,15 @@ namespace Robust.Client.Console.Commands
}
if (!NetEntity.TryParse(args[0], out var gridUidNet) ||
- !_entManager.TryGetEntity(gridUidNet, out var gridUid))
+ !EntityManager.TryGetEntity(gridUidNet, out var gridUid))
{
shell.WriteLine($"{args[0]} is not a valid entity UID.");
return;
}
- if (_entManager.TryGetComponent(gridUid, out var grid))
+ if (EntityManager.TryGetComponent(gridUid, out var grid))
{
- shell.WriteLine(grid.GetAllTiles().Count().ToString());
+ shell.WriteLine(_map.GetAllTiles(gridUid.Value, grid).Count().ToString());
}
else
{
@@ -680,12 +681,12 @@ namespace Robust.Client.Console.Commands
}
}
- internal sealed class ChunkInfoCommand : LocalizedCommands
+ internal sealed class ChunkInfoCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IEyeManager _eye = default!;
[Dependency] private readonly IInputManager _input = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "chunkinfo";
@@ -699,8 +700,8 @@ namespace Robust.Client.Console.Commands
return;
}
- var mapSystem = _entManager.System();
- var chunkIndex = mapSystem.LocalToChunkIndices(gridUid, grid, grid.MapToGrid(mousePos));
+ var mapSystem = EntityManager.System();
+ var chunkIndex = mapSystem.LocalToChunkIndices(gridUid, grid, _mapSystem.MapToGrid(gridUid, mousePos));
var chunk = mapSystem.GetOrAddChunk(gridUid, grid, chunkIndex);
shell.WriteLine($"worldBounds: {mapSystem.CalcWorldAABB(gridUid, grid, chunk)} localBounds: {chunk.CachedBounds}");
diff --git a/Robust.Client/Console/Commands/GridChunkBBCommand.cs b/Robust.Client/Console/Commands/GridChunkBBCommand.cs
index 2b14097c3..bd0d8774b 100644
--- a/Robust.Client/Console/Commands/GridChunkBBCommand.cs
+++ b/Robust.Client/Console/Commands/GridChunkBBCommand.cs
@@ -1,16 +1,19 @@
using Robust.Client.GameObjects;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
+using Robust.Shared.IoC;
namespace Robust.Client.Console.Commands
{
- public sealed class GridChunkBBCommand : LocalizedCommands
+ public sealed class GridChunkBBCommand : LocalizedEntityCommands
{
+ [Dependency] private readonly GridChunkBoundsDebugSystem _system = default!;
+
public override string Command => "showchunkbb";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
- EntitySystem.Get().Enabled ^= true;
+ _system.Enabled ^= true;
}
}
}
diff --git a/Robust.Client/Console/Commands/UITestCommand.cs b/Robust.Client/Console/Commands/UITestCommand.cs
index caeeea94c..4c43cbd46 100644
--- a/Robust.Client/Console/Commands/UITestCommand.cs
+++ b/Robust.Client/Console/Commands/UITestCommand.cs
@@ -204,7 +204,7 @@ Suspendisse hendrerit blandit urna ut laoreet. Suspendisse ac elit at erat males
private Control TabRichText()
{
var label = new RichTextLabel();
- label.SetMessage(FormattedMessage.FromMarkup(Lipsum));
+ label.SetMessage(FormattedMessage.FromMarkupOrThrow(Lipsum));
TabContainer.SetTabTitle(label, "RichText");
return label;
diff --git a/Robust.Client/Debugging/DebugDrawingSystem.cs b/Robust.Client/Debugging/DebugDrawingSystem.cs
index 11051909e..897fee0d6 100644
--- a/Robust.Client/Debugging/DebugDrawingSystem.cs
+++ b/Robust.Client/Debugging/DebugDrawingSystem.cs
@@ -1,4 +1,5 @@
using System.Numerics;
+using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
@@ -14,6 +15,8 @@ namespace Robust.Client.Debugging
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
+
private bool _debugPositions;
private bool _debugRotations;
@@ -35,7 +38,7 @@ namespace Robust.Client.Debugging
if (value && !_overlayManager.HasOverlay())
{
- _overlayManager.AddOverlay(new EntityPositionOverlay(_lookup, EntityManager));
+ _overlayManager.AddOverlay(new EntityPositionOverlay(_lookup, EntityManager, _transform));
}
else
{
@@ -74,13 +77,15 @@ namespace Robust.Client.Debugging
{
private readonly EntityLookupSystem _lookup;
private readonly IEntityManager _entityManager;
+ private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
- public EntityPositionOverlay(EntityLookupSystem lookup, IEntityManager entityManager)
+ public EntityPositionOverlay(EntityLookupSystem lookup, IEntityManager entityManager, SharedTransformSystem transform)
{
_lookup = lookup;
_entityManager = entityManager;
+ _transform = transform;
}
protected internal override void Draw(in OverlayDrawArgs args)
@@ -88,11 +93,10 @@ namespace Robust.Client.Debugging
const float stubLength = 0.25f;
var worldHandle = (DrawingHandleWorld) args.DrawingHandle;
- var xformQuery = _entityManager.GetEntityQuery();
foreach (var entity in _lookup.GetEntitiesIntersecting(args.MapId, args.WorldBounds))
{
- var (center, worldRotation) = xformQuery.GetComponent(entity).GetWorldPositionRotation();
+ var (center, worldRotation) = _transform.GetWorldPositionRotation(entity);
var xLine = worldRotation.RotateVec(Vector2.UnitX);
var yLine = worldRotation.RotateVec(Vector2.UnitY);
diff --git a/Robust.Client/Debugging/DebugPhysicsSystem.cs b/Robust.Client/Debugging/DebugPhysicsSystem.cs
index e84ad2055..757dd5a95 100644
--- a/Robust.Client/Debugging/DebugPhysicsSystem.cs
+++ b/Robust.Client/Debugging/DebugPhysicsSystem.cs
@@ -47,6 +47,7 @@
using System;
using System.Collections.Generic;
using System.Numerics;
+using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
@@ -78,6 +79,14 @@ namespace Robust.Client.Debugging
internal int PointCount;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ [Dependency] private readonly EntityLookupSystem _entityLookup = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
+ [Dependency] private readonly IOverlayManager _overlay = default!;
+ [Dependency] private readonly IEyeManager _eye = default!;
+ [Dependency] private readonly IInputManager _input = default!;
+ [Dependency] private readonly IMapManager _map = default!;
+ [Dependency] private readonly IPlayerManager _player = default!;
+ [Dependency] private readonly IResourceCache _resourceCache = default!;
internal ContactPoint[] Points = new ContactPoint[MaxContactPoints];
@@ -89,20 +98,21 @@ namespace Robust.Client.Debugging
if (value == _flags) return;
if (_flags == PhysicsDebugFlags.None)
- IoCManager.Resolve().AddOverlay(
+ _overlay.AddOverlay(
new PhysicsDebugOverlay(
EntityManager,
- IoCManager.Resolve(),
- IoCManager.Resolve(),
- IoCManager.Resolve(),
- IoCManager.Resolve(),
- IoCManager.Resolve(),
+ _eye,
+ _input,
+ _map,
+ _player,
+ _resourceCache,
this,
- Get(),
- Get()));
+ _entityLookup,
+ _physics,
+ _transform));
if (value == PhysicsDebugFlags.None)
- IoCManager.Resolve().RemoveOverlay(typeof(PhysicsDebugOverlay));
+ _overlay.RemoveOverlay(typeof(PhysicsDebugOverlay));
_flags = value;
}
@@ -198,6 +208,7 @@ namespace Robust.Client.Debugging
private readonly DebugPhysicsSystem _debugPhysicsSystem;
private readonly EntityLookupSystem _lookup;
private readonly SharedPhysicsSystem _physicsSystem;
+ private readonly SharedTransformSystem _transformSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpace | OverlaySpace.ScreenSpace;
@@ -208,7 +219,7 @@ namespace Robust.Client.Debugging
private HashSet _drawnJoints = new();
private List> _grids = new();
- public PhysicsDebugOverlay(IEntityManager entityManager, IEyeManager eyeManager, IInputManager inputManager, IMapManager mapManager, IPlayerManager playerManager, IResourceCache cache, DebugPhysicsSystem system, EntityLookupSystem lookup, SharedPhysicsSystem physicsSystem)
+ public PhysicsDebugOverlay(IEntityManager entityManager, IEyeManager eyeManager, IInputManager inputManager, IMapManager mapManager, IPlayerManager playerManager, IResourceCache cache, DebugPhysicsSystem system, EntityLookupSystem lookup, SharedPhysicsSystem physicsSystem, SharedTransformSystem transformSystem)
{
_entityManager = entityManager;
_eyeManager = eyeManager;
@@ -218,6 +229,7 @@ namespace Robust.Client.Debugging
_debugPhysicsSystem = system;
_lookup = lookup;
_physicsSystem = physicsSystem;
+ _transformSystem = transformSystem;
_font = new VectorFont(cache.GetResource("/EngineFonts/NotoSans/NotoSans-Regular.ttf"), 10);
}
@@ -327,7 +339,7 @@ namespace Robust.Client.Debugging
{
if (jointComponent.JointCount == 0 ||
!_entityManager.TryGetComponent(uid, out TransformComponent? xf1) ||
- !viewAABB.Contains(xf1.WorldPosition)) continue;
+ !viewAABB.Contains(_transformSystem.GetWorldPosition(xf1))) continue;
foreach (var (_, joint) in jointComponent.Joints)
{
@@ -517,8 +529,8 @@ namespace Robust.Client.Debugging
if (!_entityManager.TryGetComponent(joint.BodyAUid, out TransformComponent? xform1) ||
!_entityManager.TryGetComponent(joint.BodyBUid, out TransformComponent? xform2)) return;
- var matrix1 = xform1.WorldMatrix;
- var matrix2 = xform2.WorldMatrix;
+ var matrix1 = _transformSystem.GetWorldMatrix(xform1);
+ var matrix2 = _transformSystem.GetWorldMatrix(xform2);
var xf1 = new Vector2(matrix1.M31, matrix1.M32);
var xf2 = new Vector2(matrix2.M31, matrix2.M32);
@@ -526,8 +538,8 @@ namespace Robust.Client.Debugging
var p1 = Vector2.Transform(joint.LocalAnchorA, matrix1);
var p2 = Vector2.Transform(joint.LocalAnchorB, matrix2);
- var xfa = new Transform(xf1, xform1.WorldRotation);
- var xfb = new Transform(xf2, xform2.WorldRotation);
+ var xfa = new Transform(xf1, _transformSystem.GetWorldRotation(xform1));
+ var xfb = new Transform(xf2, _transformSystem.GetWorldRotation(xform2));
switch (joint)
{
diff --git a/Robust.Client/GameObjects/ClientEntityManager.cs b/Robust.Client/GameObjects/ClientEntityManager.cs
index 00e7c3cc8..0b517a421 100644
--- a/Robust.Client/GameObjects/ClientEntityManager.cs
+++ b/Robust.Client/GameObjects/ClientEntityManager.cs
@@ -48,16 +48,6 @@ namespace Robust.Client.GameObjects
return base.CreateEntity(prototypeName, out metadata);
}
- void IClientEntityManagerInternal.InitializeEntity(EntityUid entity, MetaDataComponent? meta)
- {
- base.InitializeEntity(entity, meta);
- }
-
- void IClientEntityManagerInternal.StartEntity(EntityUid entity)
- {
- base.StartEntity(entity);
- }
-
///
public override void DirtyEntity(EntityUid uid, MetaDataComponent? meta = null)
{
diff --git a/Robust.Client/GameObjects/EntitySystems/GridChunkBoundsDebugSystem.cs b/Robust.Client/GameObjects/EntitySystems/GridChunkBoundsDebugSystem.cs
index 448b2eeaa..0472ec6f2 100644
--- a/Robust.Client/GameObjects/EntitySystems/GridChunkBoundsDebugSystem.cs
+++ b/Robust.Client/GameObjects/EntitySystems/GridChunkBoundsDebugSystem.cs
@@ -18,6 +18,8 @@ namespace Robust.Client.GameObjects
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
+ [Dependency] private readonly SharedMapSystem _map = default!;
private GridChunkBoundsOverlay? _overlay;
@@ -36,7 +38,9 @@ namespace Robust.Client.GameObjects
_overlay = new GridChunkBoundsOverlay(
EntityManager,
_eyeManager,
- _mapManager);
+ _mapManager,
+ _transform,
+ _map);
_overlayManager.AddOverlay(_overlay);
}
@@ -56,16 +60,20 @@ namespace Robust.Client.GameObjects
private readonly IEntityManager _entityManager;
private readonly IEyeManager _eyeManager;
private readonly IMapManager _mapManager;
+ private readonly SharedTransformSystem _transformSystem;
+ private readonly SharedMapSystem _mapSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private List> _grids = new();
- public GridChunkBoundsOverlay(IEntityManager entManager, IEyeManager eyeManager, IMapManager mapManager)
+ public GridChunkBoundsOverlay(IEntityManager entManager, IEyeManager eyeManager, IMapManager mapManager, SharedTransformSystem transformSystem, SharedMapSystem mapSystem)
{
_entityManager = entManager;
_eyeManager = eyeManager;
_mapManager = mapManager;
+ _transformSystem = transformSystem;
+ _mapSystem = mapSystem;
}
protected internal override void Draw(in OverlayDrawArgs args)
@@ -78,11 +86,11 @@ namespace Robust.Client.GameObjects
_mapManager.FindGridsIntersecting(currentMap, viewport, ref _grids);
foreach (var grid in _grids)
{
- var worldMatrix = _entityManager.GetComponent(grid).WorldMatrix;
+ var worldMatrix = _transformSystem.GetWorldMatrix(grid);
worldHandle.SetTransform(worldMatrix);
var transform = new Transform(Vector2.Zero, Angle.Zero);
- var chunkEnumerator = grid.Comp.GetMapChunks(viewport);
+ var chunkEnumerator = _mapSystem.GetMapChunks(grid.Owner, grid.Comp, viewport);
while (chunkEnumerator.MoveNext(out var chunk))
{
diff --git a/Robust.Client/GameObjects/EntitySystems/InputSystem.cs b/Robust.Client/GameObjects/EntitySystems/InputSystem.cs
index 5a4b66a8c..8bc5cca0d 100644
--- a/Robust.Client/GameObjects/EntitySystems/InputSystem.cs
+++ b/Robust.Client/GameObjects/EntitySystems/InputSystem.cs
@@ -196,7 +196,7 @@ namespace Robust.Client.GameObjects
wOffset = new Vector2(wX, wY);
}
- var coords = EntityCoordinates.FromMap(pent, _transform.GetMapCoordinates(pent).Offset(wOffset), _transform, EntityManager);
+ var coords = _transform.ToCoordinates(pent, _transform.GetMapCoordinates(pent).Offset(wOffset));
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(keyFunction);
var message = new ClientFullInputCmdMessage(_timing.CurTick,
diff --git a/Robust.Client/GameObjects/EntitySystems/VelocityDebugSystem.cs b/Robust.Client/GameObjects/EntitySystems/VelocityDebugSystem.cs
index b621a1ca3..f7369ac74 100644
--- a/Robust.Client/GameObjects/EntitySystems/VelocityDebugSystem.cs
+++ b/Robust.Client/GameObjects/EntitySystems/VelocityDebugSystem.cs
@@ -14,6 +14,7 @@ namespace Robust.Client.GameObjects
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
internal bool Enabled { get; set; }
@@ -43,7 +44,7 @@ namespace Robust.Client.GameObjects
return;
}
- var screenPos = _eyeManager.WorldToScreen(EntityManager.GetComponent(player.Value).WorldPosition);
+ var screenPos = _eyeManager.WorldToScreen(_transform.GetWorldPosition(Transform(player.Value)));
LayoutContainer.SetPosition(_label, screenPos + new Vector2(0, 50));
_label.Visible = true;
diff --git a/Robust.Client/GameObjects/IClientEntityManagerInternal.cs b/Robust.Client/GameObjects/IClientEntityManagerInternal.cs
index cce415bac..dd0c6bf7f 100644
--- a/Robust.Client/GameObjects/IClientEntityManagerInternal.cs
+++ b/Robust.Client/GameObjects/IClientEntityManagerInternal.cs
@@ -7,9 +7,5 @@ namespace Robust.Client.GameObjects
// These methods are used by the Game State Manager.
EntityUid CreateEntity(string? prototypeName, out MetaDataComponent metadata);
-
- void InitializeEntity(EntityUid entity, MetaDataComponent? meta = null);
-
- void StartEntity(EntityUid entity);
}
}
diff --git a/Robust.Client/ViewVariables/Editors/VVPropEditorIPrototype.cs b/Robust.Client/ViewVariables/Editors/VVPropEditorIPrototype.cs
index 0b0cdcf82..1fd809a09 100644
--- a/Robust.Client/ViewVariables/Editors/VVPropEditorIPrototype.cs
+++ b/Robust.Client/ViewVariables/Editors/VVPropEditorIPrototype.cs
@@ -77,7 +77,7 @@ namespace Robust.Client.ViewVariables.Editors
{
var protoMan = IoCManager.Resolve();
- if (!protoMan.TryGetVariantFrom(typeof(T), out var variant)) return;
+ if (!protoMan.TryGetKindFrom(typeof(T), out var variant)) return;
var list = new List();
diff --git a/Robust.Shared/CPUJob/JobQueues/Job.cs b/Robust.Shared/CPUJob/JobQueues/Job.cs
index 0da30d88c..1299cbd3c 100644
--- a/Robust.Shared/CPUJob/JobQueues/Job.cs
+++ b/Robust.Shared/CPUJob/JobQueues/Job.cs
@@ -18,6 +18,8 @@ namespace Robust.Shared.CPUJob.JobQueues
/// The type of result this job generates
public abstract class Job : IJob
{
+ private readonly ISawmill _sawmill = Logger.GetSawmill("job");
+
public JobStatus Status { get; private set; } = JobStatus.Pending;
///
@@ -184,7 +186,7 @@ namespace Robust.Shared.CPUJob.JobQueues
{
// TODO: Should this be exposed differently?
// I feel that people might forget to check whether the job failed.
- Logger.ErrorS("job", "Job failed on exception:\n{0}", e);
+ _sawmill.Error("Job failed on exception:\n{0}", e);
Exception = e;
_taskTcs.TrySetException(e);
}
diff --git a/Robust.Shared/ComponentTrees/ComponentTreeSystem.cs b/Robust.Shared/ComponentTrees/ComponentTreeSystem.cs
index 1dc1d926f..45a418d71 100644
--- a/Robust.Shared/ComponentTrees/ComponentTreeSystem.cs
+++ b/Robust.Shared/ComponentTrees/ComponentTreeSystem.cs
@@ -24,6 +24,7 @@ public abstract class ComponentTreeSystem : EntitySystem
[Dependency] private readonly RecursiveMoveSystem _recursiveMoveSys = default!;
[Dependency] protected readonly SharedTransformSystem XformSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
private readonly Queue> _updateQueue = new();
private readonly HashSet _updated = new();
@@ -288,11 +289,9 @@ public abstract class ComponentTreeSystem : EntitySystem
return true;
}, includeMap: false);
- var mapUid = _mapManager.GetMapEntityId(mapId);
-
- if (TryComp(mapUid, out TTreeComp? mapTreeComp))
+ if (_mapSystem.TryGetMap(mapId, out var mapUid) && TryComp(mapUid, out TTreeComp? mapTreeComp))
{
- state.trees.Add((mapUid, mapTreeComp));
+ state.trees.Add((mapUid.Value, mapTreeComp));
}
return state.trees;
diff --git a/Robust.Shared/Console/Commands/MapCommands.cs b/Robust.Shared/Console/Commands/MapCommands.cs
index 517dcf938..c6608e535 100644
--- a/Robust.Shared/Console/Commands/MapCommands.cs
+++ b/Robust.Shared/Console/Commands/MapCommands.cs
@@ -8,10 +8,9 @@ using Robust.Shared.Map.Components;
namespace Robust.Shared.Console.Commands;
-sealed class AddMapCommand : LocalizedCommands
+sealed class AddMapCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IMapManagerInternal _map = default!;
- [Dependency] private readonly IEntityManager _entMan = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "addmap";
public override bool RequireServerOrSingleplayer => true;
@@ -23,10 +22,10 @@ sealed class AddMapCommand : LocalizedCommands
var mapId = new MapId(int.Parse(args[0]));
- if (!_map.MapExists(mapId))
+ if (!_mapSystem.MapExists(mapId))
{
var init = args.Length < 2 || !bool.Parse(args[1]);
- _entMan.System().CreateMap(mapId, runMapInit: init);
+ EntityManager.System().CreateMap(mapId, runMapInit: init);
shell.WriteLine($"Map with ID {mapId} created.");
return;
@@ -64,11 +63,8 @@ sealed class RemoveMapCommand : LocalizedCommands
}
}
-sealed class RemoveGridCommand : LocalizedCommands
+sealed class RemoveGridCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _entManager = default!;
- [Dependency] private readonly IMapManager _map = default!;
-
public override string Command => "rmgrid";
public override bool RequireServerOrSingleplayer => true;
@@ -82,20 +78,20 @@ sealed class RemoveGridCommand : LocalizedCommands
var gridIdNet = NetEntity.Parse(args[0]);
- if (!_entManager.TryGetEntity(gridIdNet, out var gridId) || !_entManager.HasComponent(gridId))
+ if (!EntityManager.TryGetEntity(gridIdNet, out var gridId) || !EntityManager.HasComponent(gridId))
{
shell.WriteError($"Grid {gridId} does not exist.");
return;
}
- _map.DeleteGrid(gridId.Value);
+ EntityManager.DeleteEntity(gridId);
shell.WriteLine($"Grid {gridId} was removed.");
}
}
-internal sealed class RunMapInitCommand : LocalizedCommands
+internal sealed class RunMapInitCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IMapManager _map = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "mapinit";
public override bool RequireServerOrSingleplayer => true;
@@ -111,26 +107,27 @@ internal sealed class RunMapInitCommand : LocalizedCommands
var arg = args[0];
var mapId = new MapId(int.Parse(arg, CultureInfo.InvariantCulture));
- if (!_map.MapExists(mapId))
+ if (!_mapSystem.MapExists(mapId))
{
shell.WriteError("Map does not exist!");
return;
}
- if (_map.IsMapInitialized(mapId))
+ if (_mapSystem.IsInitialized(mapId))
{
shell.WriteError("Map is already initialized!");
return;
}
- _map.DoMapInitialize(mapId);
+ _mapSystem.InitializeMap(mapId);
}
}
-internal sealed class ListMapsCommand : LocalizedCommands
+internal sealed class ListMapsCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _map = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "lsmap";
@@ -143,13 +140,15 @@ internal sealed class ListMapsCommand : LocalizedCommands
foreach (var mapId in _map.GetAllMapIds().OrderBy(id => id.Value))
{
- var mapUid = _map.GetMapEntityId(mapId);
+ if (!_mapSystem.TryGetMap(mapId, out var mapUid))
+ continue;
msg.AppendFormat("{0}: {1}, init: {2}, paused: {3}, nent: {4}, grids: {5}\n",
- mapId, _entManager.GetComponent(mapUid).EntityName,
- _map.IsMapInitialized(mapId),
- _map.IsMapPaused(mapId),
- _entManager.GetNetEntity(_map.GetMapEntityId(mapId)),
+ mapId,
+ _entManager.GetComponent(mapUid.Value).EntityName,
+ _mapSystem.IsInitialized(mapUid),
+ _mapSystem.IsPaused(mapId),
+ _entManager.GetNetEntity(mapUid),
string.Join(",", _map.GetAllGrids(mapId).Select(grid => grid.Owner)));
}
@@ -157,9 +156,10 @@ internal sealed class ListMapsCommand : LocalizedCommands
}
}
-internal sealed class ListGridsCommand : LocalizedCommands
+internal sealed class ListGridsCommand : LocalizedEntityCommands
{
- [Dependency] private readonly IEntityManager _ent = default!;
+ [Dependency]
+ private readonly SharedTransformSystem _transformSystem = default!;
public override string Command => "lsgrid";
@@ -169,15 +169,14 @@ internal sealed class ListGridsCommand : LocalizedCommands
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var msg = new StringBuilder();
- var xformSystem = _ent.System();
- var xformQuery = _ent.GetEntityQuery();
- var grids = _ent.AllComponentsList();
+ var xformQuery = EntityManager.GetEntityQuery();
+ var grids = EntityManager.AllComponentsList();
grids.Sort((x, y) => x.Uid.CompareTo(y.Uid));
- foreach (var (uid, grid) in grids)
+ foreach (var (uid, _) in grids)
{
var xform = xformQuery.GetComponent(uid);
- var worldPos = xformSystem.GetWorldPosition(xform);
+ var worldPos = _transformSystem.GetWorldPosition(xform);
msg.AppendFormat("{0}: map: {1}, ent: {2}, pos: {3:0.0},{4:0.0} \n",
uid, xform.MapID, uid, worldPos.X, worldPos.Y);
diff --git a/Robust.Shared/Console/Commands/TeleportCommands.cs b/Robust.Shared/Console/Commands/TeleportCommands.cs
index 24ec31651..f12e0d9fd 100644
--- a/Robust.Shared/Console/Commands/TeleportCommands.cs
+++ b/Robust.Shared/Console/Commands/TeleportCommands.cs
@@ -61,7 +61,7 @@ internal sealed class TeleportCommand : LocalizedEntityCommands
else
{
var mapEnt = _map.GetMapEntityIdOrThrow(mapId);
- _transform.SetWorldPosition(transform, position);
+ _transform.SetWorldPosition((entity, transform), position);
_transform.SetParent(entity, transform, mapEnt);
}
diff --git a/Robust.Shared/Console/IConsoleShell.cs b/Robust.Shared/Console/IConsoleShell.cs
index b8e4768bd..6a5475bb5 100644
--- a/Robust.Shared/Console/IConsoleShell.cs
+++ b/Robust.Shared/Console/IConsoleShell.cs
@@ -59,7 +59,7 @@ namespace Robust.Shared.Console
void WriteMarkup(string markup)
{
- WriteLine(FormattedMessage.FromMarkup(markup));
+ WriteLine(FormattedMessage.FromMarkupPermissive(markup));
}
///
diff --git a/Robust.Shared/Containers/SharedContainerSystem.cs b/Robust.Shared/Containers/SharedContainerSystem.cs
index 0707716ee..88f9e0be1 100644
--- a/Robust.Shared/Containers/SharedContainerSystem.cs
+++ b/Robust.Shared/Containers/SharedContainerSystem.cs
@@ -659,7 +659,9 @@ namespace Robust.Shared.Containers
if (!transform.Comp.ParentUid.IsValid()
|| !TryGetContainingContainer(transform.Comp.ParentUid, out var container)
|| !TryInsertIntoContainer(transform, container))
- transform.Comp.AttachToGridOrMap();
+ {
+ _transform.AttachToGridOrMap(transform, transform.Comp);
+ }
}
private bool TryInsertIntoContainer(Entity transform, BaseContainer container)
diff --git a/Robust.Shared/GameObjects/Components/Transform/TransformComponent.cs b/Robust.Shared/GameObjects/Components/Transform/TransformComponent.cs
index eb14a5754..a53cd6717 100644
--- a/Robust.Shared/GameObjects/Components/Transform/TransformComponent.cs
+++ b/Robust.Shared/GameObjects/Components/Transform/TransformComponent.cs
@@ -660,21 +660,25 @@ namespace Robust.Shared.GameObjects
/// Raised when the Anchor state of the transform is changed.
///
[ByRefEvent]
- public readonly struct AnchorStateChangedEvent
+ public readonly struct AnchorStateChangedEvent(
+ EntityUid entity,
+ TransformComponent transform,
+ bool detaching = false)
{
- public readonly TransformComponent Transform;
- public EntityUid Entity => Transform.Owner;
+ public readonly TransformComponent Transform = transform;
+ public EntityUid Entity { get; } = entity;
public bool Anchored => Transform.Anchored;
///
/// If true, the entity is being detached to null-space
///
- public readonly bool Detaching;
+ public readonly bool Detaching = detaching;
+ [Obsolete("Use constructor that takes in EntityUid")]
public AnchorStateChangedEvent(TransformComponent transform, bool detaching = false)
+ : this(transform.Owner, transform, detaching)
{
- Detaching = detaching;
- Transform = transform;
+
}
}
diff --git a/Robust.Shared/GameObjects/EntitySystem.cs b/Robust.Shared/GameObjects/EntitySystem.cs
index af1f73214..d4e7b875f 100644
--- a/Robust.Shared/GameObjects/EntitySystem.cs
+++ b/Robust.Shared/GameObjects/EntitySystem.cs
@@ -23,7 +23,7 @@ namespace Robust.Shared.GameObjects
[Reflect(false), PublicAPI]
public abstract partial class EntitySystem : IEntitySystem, IPostInjectInit
{
- [Dependency] protected readonly EntityManager EntityManager;
+ [Dependency] protected readonly EntityManager EntityManager = default!;
[Dependency] protected readonly ILogManager LogManager = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;
[Dependency] private readonly IReplayRecordingManager _replayMan = default!;
@@ -65,11 +65,8 @@ namespace Robust.Shared.GameObjects
IEnumerable IEntitySystem.UpdatesAfter => UpdatesAfter;
IEnumerable IEntitySystem.UpdatesBefore => UpdatesBefore;
- protected EntitySystem() : this(default!) { }
-
- protected EntitySystem(IEntityManager entityManager)
+ protected EntitySystem()
{
- EntityManager = (EntityManager)entityManager;
Subs = new Subscriptions(this);
}
diff --git a/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs b/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs
index 2e7ab95f4..cdf3dc80f 100644
--- a/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs
+++ b/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs
@@ -90,7 +90,7 @@ public abstract partial class SharedTransformSystem
if (!wasAnchored && xform.Running)
{
- var ev = new AnchorStateChangedEvent(xform);
+ var ev = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -150,7 +150,7 @@ public abstract partial class SharedTransformSystem
if (!xform.Running)
return;
- var ev = new AnchorStateChangedEvent(xform);
+ var ev = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -249,19 +249,20 @@ public abstract partial class SharedTransformSystem
if (!component._anchored)
return;
- MapGridComponent? grid;
+ Entity? grid = null;
// First try find grid via parent:
if (component.GridUid == component.ParentUid && TryComp(component.ParentUid, out MapGridComponent? gridComp))
{
- grid = gridComp;
+ grid = (component.ParentUid, gridComp);
}
else
{
// Entity may not be directly parented to the grid (e.g., spawned using some relative entity coordinates)
// in that case, we attempt to attach to a grid.
var pos = new MapCoordinates(GetWorldPosition(component), component.MapID);
- _mapManager.TryFindGridAt(pos, out _, out grid);
+ if (_mapManager.TryFindGridAt(pos, out var gridUid, out gridComp))
+ grid = (gridUid, gridComp);
}
if (grid == null)
@@ -270,7 +271,7 @@ public abstract partial class SharedTransformSystem
return;
}
- if (!AnchorEntity(uid, component, grid))
+ if (!AnchorEntity((uid, component), grid))
component._anchored = false;
}
@@ -308,7 +309,7 @@ public abstract partial class SharedTransformSystem
if (xform.Anchored)
{
DebugTools.Assert(xform.ParentUid == xform.GridUid && xform.ParentUid.IsValid());
- var anchorEv = new AnchorStateChangedEvent(xform);
+ var anchorEv = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref anchorEv, true);
}
@@ -746,7 +747,7 @@ public abstract partial class SharedTransformSystem
if (oldAnchored != newState.Anchored && xform.Initialized)
{
- var ev = new AnchorStateChangedEvent(xform);
+ var ev = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -934,7 +935,7 @@ public abstract partial class SharedTransformSystem
// Entity was not actually in the transform hierarchy. This is probably a sign that something is wrong, or that the function is being misused.
Log.Warning($"Target entity ({ToPrettyString(relative)}) not in transform hierarchy while calling {nameof(GetRelativePositionRotation)}.");
var relXform = query.GetComponent(relative);
- pos = Vector2.Transform(pos, relXform.InvWorldMatrix);
+ pos = Vector2.Transform(pos, GetInvWorldMatrix(relXform));
rot = rot - GetWorldRotation(relXform, query);
break;
}
@@ -976,10 +977,11 @@ public abstract partial class SharedTransformSystem
public void SetWorldPosition(EntityUid uid, Vector2 worldPos)
{
var xform = XformQuery.GetComponent(uid);
- SetWorldPosition(xform, worldPos);
+ SetWorldPosition((uid, xform), worldPos);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [Obsolete("Use overload that takes Entity instead")]
public void SetWorldPosition(TransformComponent component, Vector2 worldPos)
{
SetWorldPosition((component.Owner, component), worldPos);
@@ -1313,10 +1315,9 @@ public abstract partial class SharedTransformSystem
{
newParent = gridUid;
}
- else if (_mapManager.GetMapEntityId(xform.MapID) is { Valid: true } mapEnt
- && !TerminatingOrDeleted(mapEnt))
+ else if (_map.TryGetMap(xform.MapID, out var mapEnt) && !TerminatingOrDeleted(mapEnt))
{
- newParent = mapEnt;
+ newParent = mapEnt.Value;
}
else
{
@@ -1446,7 +1447,7 @@ public abstract partial class SharedTransformSystem
var tileIndices = _map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates);
_map.RemoveFromSnapGridCell(xform.GridUid.Value, grid, tileIndices, uid);
xform._anchored = false;
- var anchorStateChangedEvent = new AnchorStateChangedEvent(xform, true);
+ var anchorStateChangedEvent = new AnchorStateChangedEvent(uid, xform, true);
RaiseLocalEvent(uid, ref anchorStateChangedEvent, true);
}
diff --git a/Robust.Shared/Map/CoordinatesExtensions.cs b/Robust.Shared/Map/CoordinatesExtensions.cs
index 6462f678e..120afdf69 100644
--- a/Robust.Shared/Map/CoordinatesExtensions.cs
+++ b/Robust.Shared/Map/CoordinatesExtensions.cs
@@ -12,7 +12,8 @@ namespace Robust.Shared.Map
{
IoCManager.Resolve(ref entityManager, ref mapManager);
- var gridId = coords.GetGridUid(entityManager);
+ var xform = entityManager.System();
+ var gridId = xform.GetGrid(coords);
var mapSystem = entityManager.System();
if (entityManager.TryGetComponent(gridId, out var mapGrid))
@@ -20,8 +21,7 @@ namespace Robust.Shared.Map
return mapSystem.GridTileToLocal(gridId.Value, mapGrid, mapSystem.CoordinatesToTile(gridId.Value, mapGrid, coords));
}
- var transformSystem = entityManager.System();
- var mapCoords = coords.ToMap(entityManager, transformSystem);
+ var mapCoords = xform.ToMapCoordinates(coords);
if (mapManager.TryFindGridAt(mapCoords, out var gridUid, out mapGrid))
{
@@ -49,7 +49,8 @@ namespace Robust.Shared.Map
// TODO: Use CollisionManager to get nearest edge.
// figure out closest intersect
- var gridIntersect = gridSearchBox.Intersect(gridXform.WorldMatrix.TransformBox(grid.Comp.LocalAABB));
+ var worldMatrix = xform.GetWorldMatrix(gridXform);
+ var gridIntersect = gridSearchBox.Intersect(worldMatrix.TransformBox(grid.Comp.LocalAABB));
var gridDist = (gridIntersect.Center - mapCoords.Position).LengthSquared();
if (gridDist >= distance)
diff --git a/Robust.Shared/Map/EntityCoordinates.cs b/Robust.Shared/Map/EntityCoordinates.cs
index f029d8f2c..de887eb6a 100644
--- a/Robust.Shared/Map/EntityCoordinates.cs
+++ b/Robust.Shared/Map/EntityCoordinates.cs
@@ -143,14 +143,14 @@ namespace Robust.Shared.Map
return new Vector2i();
var mapSystem = entityManager.System();
- var gridIdOpt = GetGridUid(entityManager);
+ var gridIdOpt = transformSystem.GetGrid(this);
if (gridIdOpt is { } gridId && gridId.IsValid())
{
var grid = entityManager.GetComponent(gridId);
return mapSystem.GetTileRef(gridId, grid, this).GridIndices;
}
- var vec = ToMapPos(entityManager, transformSystem);
+ var vec = transformSystem.ToMapCoordinates(this);
return new Vector2i((int)MathF.Floor(vec.X), (int)MathF.Floor(vec.Y));
}
@@ -334,8 +334,8 @@ namespace Robust.Shared.Map
return true;
}
- var mapCoordinates = ToMap(entityManager, transformSystem);
- var otherMapCoordinates = otherCoordinates.ToMap(entityManager, transformSystem);
+ var mapCoordinates = transformSystem.ToMapCoordinates(this);
+ var otherMapCoordinates = transformSystem.ToMapCoordinates(otherCoordinates);
if (mapCoordinates.MapId != otherMapCoordinates.MapId)
return false;
diff --git a/Robust.Shared/Network/HappyEyeballsHttp.cs b/Robust.Shared/Network/HappyEyeballsHttp.cs
index 56622fc73..34aef3ab4 100644
--- a/Robust.Shared/Network/HappyEyeballsHttp.cs
+++ b/Robust.Shared/Network/HappyEyeballsHttp.cs
@@ -115,7 +115,7 @@ internal static class HappyEyeballsHttp
await socket.ConnectAsync(new IPEndPoint(address, port), cancel).ConfigureAwait(false);
return socket;
}
- catch (Exception e)
+ catch (Exception)
{
// Log.Verbose(e, "Happy Eyeballs to {Address} [{Index}] failed", address, index);
socket.Dispose();
diff --git a/Robust.Shared/Network/NetEncryption.cs b/Robust.Shared/Network/NetEncryption.cs
index 3c9df6b72..1aef24d60 100644
--- a/Robust.Shared/Network/NetEncryption.cs
+++ b/Robust.Shared/Network/NetEncryption.cs
@@ -1,6 +1,6 @@
using System;
using System.Buffers;
-using System.Runtime.InteropServices;
+using System.Buffers.Binary;
using System.Threading;
using Lidgren.Network;
using SpaceWizards.Sodium;
@@ -60,11 +60,10 @@ internal sealed class NetEncryption
ciphertext = message.Data = new byte[encryptedSize];
}
- // TODO: this is probably broken for big-endian machines.
Span nonceData = stackalloc byte[CryptoAeadXChaCha20Poly1305Ietf.NoncePublicBytes];
nonceData.Fill(0);
- MemoryMarshal.Write(nonceData, ref nonce);
- MemoryMarshal.Write(ciphertext, ref nonce);
+ BinaryPrimitives.WriteUInt64LittleEndian(nonceData, nonce);
+ BinaryPrimitives.WriteUInt64LittleEndian(ciphertext, nonce);
CryptoAeadXChaCha20Poly1305Ietf.Encrypt(
// ciphertext
@@ -93,10 +92,9 @@ internal sealed class NetEncryption
var buffer = ArrayPool.Shared.Rent(cipherText.Length);
cipherText.CopyTo(buffer);
- // TODO: this is probably broken for big-endian machines.
Span nonceData = stackalloc byte[CryptoAeadXChaCha20Poly1305Ietf.NoncePublicBytes];
nonceData.Fill(0);
- MemoryMarshal.Write(nonceData, ref nonce);
+ BinaryPrimitives.WriteUInt64LittleEndian(nonceData, nonce);
var result = CryptoAeadXChaCha20Poly1305Ietf.Decrypt(
// plaintext
diff --git a/Robust.Shared/Physics/Controllers/Gravity2DController.cs b/Robust.Shared/Physics/Controllers/Gravity2DController.cs
index 81bd5cbe9..e7481ec24 100644
--- a/Robust.Shared/Physics/Controllers/Gravity2DController.cs
+++ b/Robust.Shared/Physics/Controllers/Gravity2DController.cs
@@ -17,8 +17,8 @@ namespace Robust.Shared.Physics.Controllers;
public sealed class Gravity2DController : VirtualController
{
- [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
private ISawmill _sawmill = default!;
@@ -72,7 +72,7 @@ public sealed class Gravity2DController : VirtualController
public void SetGravity(MapId mapId, Vector2 value)
{
- var mapUid = _mapManager.GetMapEntityId(mapId);
+ var mapUid = _mapSystem.GetMap(mapId);
var gravity = EnsureComp(mapUid);
if (gravity.Gravity.Equals(value))
diff --git a/Robust.Shared/Physics/Systems/SharedPhysicsSystem.Components.cs b/Robust.Shared/Physics/Systems/SharedPhysicsSystem.Components.cs
index adecf575f..cb2347bf0 100644
--- a/Robust.Shared/Physics/Systems/SharedPhysicsSystem.Components.cs
+++ b/Robust.Shared/Physics/Systems/SharedPhysicsSystem.Components.cs
@@ -53,7 +53,7 @@ public partial class SharedPhysicsSystem
{
if (component.BodyType != BodyType.Static)
{
- SetAwake(uid, component, true);
+ SetAwake((uid, component), true);
}
}
@@ -491,14 +491,14 @@ public partial class SharedPhysicsSystem
if (body.BodyType == BodyType.Static)
{
- SetAwake(uid, body, false);
+ SetAwake((uid, body), false);
body.LinearVelocity = Vector2.Zero;
body.AngularVelocity = 0.0f;
}
// Even if it's dynamic if it can't collide then don't force it awake.
else if (body.CanCollide)
{
- SetAwake(uid, body, true);
+ SetAwake((uid, body), true);
}
body.Force = Vector2.Zero;
@@ -571,7 +571,7 @@ public partial class SharedPhysicsSystem
body.CanCollide = value;
if (!value)
- SetAwake(uid, body, false);
+ SetAwake((uid, body), false);
if (body.Initialized)
{
@@ -655,7 +655,7 @@ public partial class SharedPhysicsSystem
return;
if (!value)
- SetAwake(uid, body, true);
+ SetAwake((uid, body), true);
body.SleepingAllowed = value;
diff --git a/Robust.Shared/Player/Filter.cs b/Robust.Shared/Player/Filter.cs
index ce8d421b1..c96bb0daa 100644
--- a/Robust.Shared/Player/Filter.cs
+++ b/Robust.Shared/Player/Filter.cs
@@ -45,13 +45,15 @@ namespace Robust.Shared.Player
{
IoCManager.Resolve(ref entityManager, ref playerMan, ref cfgMan);
var transform = entityManager.GetComponent(origin);
- return AddPlayersByPvs(transform.MapPosition, rangeMultiplier, entityManager, playerMan, cfgMan);
+ var transformSystem = entityManager.System();
+ return AddPlayersByPvs(transformSystem.GetMapCoordinates(transform), rangeMultiplier, entityManager, playerMan, cfgMan);
}
///
/// Adds all players inside an entity's PVS.
/// The current PVS range will be multiplied by .
///
+ [Obsolete("Use overload that takes in managers")]
public Filter AddPlayersByPvs(TransformComponent origin, float rangeMultiplier = 2f)
{
return AddPlayersByPvs(origin.MapPosition, rangeMultiplier);
@@ -64,7 +66,8 @@ namespace Robust.Shared.Player
public Filter AddPlayersByPvs(EntityCoordinates origin, float rangeMultiplier = 2f, IEntityManager? entityMan = null, ISharedPlayerManager? playerMan = null)
{
IoCManager.Resolve(ref entityMan, ref playerMan);
- return AddPlayersByPvs(origin.ToMap(entityMan, entityMan.System()), rangeMultiplier, entityMan, playerMan);
+ var system = entityMan.System();
+ return AddPlayersByPvs(system.ToMapCoordinates(origin), rangeMultiplier, entityMan, playerMan);
}
///
@@ -168,12 +171,13 @@ namespace Robust.Shared.Player
{
IoCManager.Resolve(ref playerMan, ref entMan);
var xformQuery = entMan.GetEntityQuery();
+ var xformSystem = entMan.System();
return AddWhere(session =>
session.AttachedEntity != null &&
xformQuery.TryGetComponent(session.AttachedEntity.Value, out var xform) &&
xform.MapID == position.MapId &&
- (xform.WorldPosition - position.Position).Length() < range, playerMan);
+ (xformSystem.GetWorldPosition(xform) - position.Position).Length() < range, playerMan);
}
///
@@ -211,7 +215,7 @@ namespace Robust.Shared.Player
///
/// Removes players from the filter.
///
- public Filter RemovePlayers(params ICommonSession[] players) => RemovePlayers(players);
+ public Filter RemovePlayers(params ICommonSession[] players) => RemovePlayers((IEnumerable) players);
///
/// Removes a single player from the filter, specified by the entity to which they are attached.
@@ -232,7 +236,7 @@ namespace Robust.Shared.Player
///
/// Removes players from the filter, specified by the entities to which they are attached.
///
- public Filter RemovePlayersByAttachedEntity(params EntityUid[] uids) => RemovePlayersByAttachedEntity(uids);
+ public Filter RemovePlayersByAttachedEntity(params EntityUid[] uids) => RemovePlayersByAttachedEntity((IEnumerable) uids);
///
/// Removes all players from the filter that match a predicate.
@@ -260,12 +264,13 @@ namespace Robust.Shared.Player
{
IoCManager.Resolve(ref entMan);
var xformQuery = entMan.GetEntityQuery();
+ var xformSystem = entMan.System();
return RemoveWhere(session =>
session.AttachedEntity != null &&
xformQuery.TryGetComponent(session.AttachedEntity.Value, out var xform) &&
xform.MapID == position.MapId &&
- (xform.WorldPosition - position.Position).Length() < range);
+ (xformSystem.GetWorldPosition(xform) - position.Position).Length() < range);
}
///
@@ -370,6 +375,7 @@ namespace Robust.Shared.Player
///
/// A filter with every player whose PVS overlaps this point.
///
+ [Obsolete("Use overload that takes in managers")]
public static Filter Pvs(TransformComponent origin, float rangeMultiplier = 2f)
{
return Empty().AddPlayersByPvs(origin, rangeMultiplier);
diff --git a/Robust.Shared/Serialization/TypeSerializers/Implementations/FormattedMessageSerializer.cs b/Robust.Shared/Serialization/TypeSerializers/Implementations/FormattedMessageSerializer.cs
index 15770f3ba..91375de39 100644
--- a/Robust.Shared/Serialization/TypeSerializers/Implementations/FormattedMessageSerializer.cs
+++ b/Robust.Shared/Serialization/TypeSerializers/Implementations/FormattedMessageSerializer.cs
@@ -18,7 +18,7 @@ namespace Robust.Shared.Serialization.TypeSerializers.Implementations
ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate? instanceProvider = null)
{
- return FormattedMessage.FromMarkup(node.Value);
+ return FormattedMessage.FromMarkupOrThrow(node.Value);
}
public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node,
diff --git a/Robust.Shared/Toolshed/Commands/Misc/BuildInfoCommand.cs b/Robust.Shared/Toolshed/Commands/Misc/BuildInfoCommand.cs
index d31e257c3..b19197100 100644
--- a/Robust.Shared/Toolshed/Commands/Misc/BuildInfoCommand.cs
+++ b/Robust.Shared/Toolshed/Commands/Misc/BuildInfoCommand.cs
@@ -16,12 +16,15 @@ internal sealed class BuildInfoCommand : ToolshedCommand
public void BuildInfo([CommandInvocationContext] IInvocationContext ctx)
{
var game = _cfg.GetCVar(CVars.BuildForkId);
- ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Game:[/color] {game}"));
var buildCommit = _cfg.GetCVar(CVars.BuildHash);
- ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Build commit:[/color] {buildCommit}"));
var buildManifest = _cfg.GetCVar(CVars.BuildManifestHash);
- ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Manifest hash:[/color] {buildManifest}"));
var engine = _cfg.GetCVar(CVars.BuildEngineVersion);
- ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Engine ver:[/color] {engine}"));
+
+ ctx.WriteLine(FormattedMessage.FromMarkupOrThrow($"""
+ [color={Gold}]Game:[/color] {game}
+ [color={Gold}]Build commit:[/color] {buildCommit}
+ [color={Gold}]Manifest hash:[/color] {buildManifest}
+ [color={Gold}]Engine ver:[/color] {engine}
+ """));
}
}
diff --git a/Robust.Shared/Toolshed/Errors/NotForServerConsoleError.cs b/Robust.Shared/Toolshed/Errors/NotForServerConsoleError.cs
index 024d015ed..cdd8ddff1 100644
--- a/Robust.Shared/Toolshed/Errors/NotForServerConsoleError.cs
+++ b/Robust.Shared/Toolshed/Errors/NotForServerConsoleError.cs
@@ -8,7 +8,7 @@ public sealed class NotForServerConsoleError : IConError
{
public FormattedMessage DescribeInner()
{
- return FormattedMessage.FromMarkup(
+ return FormattedMessage.FromMarkupOrThrow(
"You must be logged in with a client to use this, the server console isn't workable.");
}
diff --git a/Robust.Shared/Toolshed/Errors/SessionHasNoEntityError.cs b/Robust.Shared/Toolshed/Errors/SessionHasNoEntityError.cs
index dac873638..3fddf8c78 100644
--- a/Robust.Shared/Toolshed/Errors/SessionHasNoEntityError.cs
+++ b/Robust.Shared/Toolshed/Errors/SessionHasNoEntityError.cs
@@ -9,7 +9,7 @@ public record SessionHasNoEntityError(ICommonSession Session) : IConError
{
public FormattedMessage DescribeInner()
{
- return FormattedMessage.FromMarkup($"The user {Session.Name} has no attached entity.");
+ return FormattedMessage.FromMarkupOrThrow($"The user {Session.Name} has no attached entity.");
}
public string? Expression { get; set; }
diff --git a/Robust.Shared/Toolshed/IInvocationContext.cs b/Robust.Shared/Toolshed/IInvocationContext.cs
index 120762ff1..0fbfa00a6 100644
--- a/Robust.Shared/Toolshed/IInvocationContext.cs
+++ b/Robust.Shared/Toolshed/IInvocationContext.cs
@@ -82,7 +82,7 @@ public interface IInvocationContext
///
public void WriteMarkup(string markup)
{
- WriteLine(FormattedMessage.FromMarkup(markup));
+ WriteLine(FormattedMessage.FromMarkupPermissive(markup));
}
///
diff --git a/Robust.Shared/Toolshed/Syntax/ParserContext.cs b/Robust.Shared/Toolshed/Syntax/ParserContext.cs
index c951d30c4..1b684898d 100644
--- a/Robust.Shared/Toolshed/Syntax/ParserContext.cs
+++ b/Robust.Shared/Toolshed/Syntax/ParserContext.cs
@@ -352,7 +352,7 @@ public record OutOfInputError : IConError
{
public FormattedMessage DescribeInner()
{
- return FormattedMessage.FromMarkup("Ran out of input data when data was expected.");
+ return FormattedMessage.FromMarkupOrThrow("Ran out of input data when data was expected.");
}
public string? Expression { get; set; }
diff --git a/Robust.Shared/Toolshed/Syntax/ValueRef.cs b/Robust.Shared/Toolshed/Syntax/ValueRef.cs
index abca2defe..cb0d5042d 100644
--- a/Robust.Shared/Toolshed/Syntax/ValueRef.cs
+++ b/Robust.Shared/Toolshed/Syntax/ValueRef.cs
@@ -103,7 +103,7 @@ public record BadVarTypeError(Type Got, Type Expected, string VarName) : IConErr
{
public FormattedMessage DescribeInner()
{
- return FormattedMessage.FromMarkup(
+ return FormattedMessage.FromMarkupOrThrow(
$"Got unexpected type {Got.PrettyName()} in {VarName}, expected {Expected.PrettyName()}");
}
diff --git a/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs b/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs
index f967f19f5..f4d4c3b7a 100644
--- a/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs
+++ b/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs
@@ -93,7 +93,7 @@ public record struct StringMustStartWithQuote : IConError
{
public FormattedMessage DescribeInner()
{
- return FormattedMessage.FromMarkup("A string must start with a quote.");
+ return FormattedMessage.FromMarkupOrThrow("A string must start with a quote.");
}
public string? Expression { get; set; }
diff --git a/Robust.Shared/Utility/ZStd.cs b/Robust.Shared/Utility/ZStd.cs
index 3030dcc0f..9444e509f 100644
--- a/Robust.Shared/Utility/ZStd.cs
+++ b/Robust.Shared/Utility/ZStd.cs
@@ -271,30 +271,34 @@ public sealed class ZStdDecompressStream : Stream
return 0;
}
- unsafe
- {
- fixed (byte* inputPtr = _buffer)
- fixed (byte* outputPtr = buffer.Span)
- {
- ZSTD_outBuffer outputBuf = default;
- outputBuf.dst = outputPtr;
- outputBuf.pos = 0;
- outputBuf.size = (nuint)buffer.Length;
- ZSTD_inBuffer inputBuf = default;
- inputBuf.src = inputPtr;
- inputBuf.pos = (nuint)_bufferPos;
- inputBuf.size = (nuint)_bufferSize;
+ var ret = DecompressChunk(this, buffer.Span);
+ if (ret > 0)
+ return (int)ret;
- var ret = ZSTD_decompressStream(_ctx, &outputBuf, &inputBuf);
-
- _bufferPos = (int)inputBuf.pos;
- ZStdException.ThrowIfError(ret);
-
- if (outputBuf.pos > 0)
- return (int)outputBuf.pos;
- }
- }
} while (true);
+
+ static unsafe nuint DecompressChunk(ZStdDecompressStream stream, Span buffer)
+ {
+ fixed (byte* inputPtr = stream._buffer)
+ fixed (byte* outputPtr = buffer)
+ {
+ ZSTD_outBuffer outputBuf = default;
+ outputBuf.dst = outputPtr;
+ outputBuf.pos = 0;
+ outputBuf.size = (nuint)buffer.Length;
+ ZSTD_inBuffer inputBuf = default;
+ inputBuf.src = inputPtr;
+ inputBuf.pos = (nuint)stream._bufferPos;
+ inputBuf.size = (nuint)stream._bufferSize;
+
+ var ret = ZSTD_decompressStream(stream._ctx, &outputBuf, &inputBuf);
+
+ stream._bufferPos = (int)inputBuf.pos;
+ ZStdException.ThrowIfError(ret);
+
+ return outputBuf.pos;
+ }
+ }
}
public override long Seek(long offset, SeekOrigin origin)
diff --git a/Robust.Shared/ViewVariables/ViewVariablesManager.TypeHandlers.cs b/Robust.Shared/ViewVariables/ViewVariablesManager.TypeHandlers.cs
index 01cdd4397..1d91da0a0 100644
--- a/Robust.Shared/ViewVariables/ViewVariablesManager.TypeHandlers.cs
+++ b/Robust.Shared/ViewVariables/ViewVariablesManager.TypeHandlers.cs
@@ -14,7 +14,7 @@ internal abstract partial class ViewVariablesManager
if (_typeHandlers.TryGetValue(typeof(T), out var h))
return (ViewVariablesTypeHandler)h;
- var handler = new ViewVariablesTypeHandler();
+ var handler = new ViewVariablesTypeHandler(Sawmill);
_typeHandlers.Add(typeof(T), handler);
return handler;
}
diff --git a/Robust.Shared/ViewVariables/ViewVariablesTypeHandler.cs b/Robust.Shared/ViewVariables/ViewVariablesTypeHandler.cs
index f7c1d88cd..3532a53a8 100644
--- a/Robust.Shared/ViewVariables/ViewVariablesTypeHandler.cs
+++ b/Robust.Shared/ViewVariables/ViewVariablesTypeHandler.cs
@@ -31,9 +31,11 @@ public sealed class ViewVariablesTypeHandler : ViewVariablesTypeHandler
{
private readonly List _handlers = new();
private readonly Dictionary _paths = new();
+ private readonly ISawmill _sawmill;
- internal ViewVariablesTypeHandler()
+ internal ViewVariablesTypeHandler(ISawmill sawmill)
{
+ _sawmill = sawmill;
}
///
@@ -210,7 +212,9 @@ public sealed class ViewVariablesTypeHandler : ViewVariablesTypeHandler
}
catch (NullReferenceException e)
{
- Logger.ErrorS(nameof(ViewVariablesManager), e,
+ _sawmill.Log(
+ LogLevel.Error,
+ e,
$"NRE caught in setter for path \"{path}\" for type \"{typeof(T).Name}\"...");
}
});
diff --git a/Robust.UnitTesting/RobustUnitTest.cs b/Robust.UnitTesting/RobustUnitTest.cs
index 6d0c02539..6e75f666c 100644
--- a/Robust.UnitTesting/RobustUnitTest.cs
+++ b/Robust.UnitTesting/RobustUnitTest.cs
@@ -8,6 +8,7 @@ using Robust.Server.Debugging;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Server.Physics;
+using Robust.Shared.ComponentTrees;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.ContentPack;
@@ -26,6 +27,7 @@ using Robust.Shared.Threading;
using Robust.Shared.Utility;
using InputSystem = Robust.Server.GameObjects.InputSystem;
using MapSystem = Robust.Server.GameObjects.MapSystem;
+using PointLightComponent = Robust.Client.GameObjects.PointLightComponent;
namespace Robust.UnitTesting
{
@@ -126,8 +128,8 @@ namespace Robust.UnitTesting
if (Project == UnitTestProject.Client)
{
systems.LoadExtraSystemType();
- systems.LoadExtraSystemType();
- systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
systems.LoadExtraSystemType();
systems.LoadExtraSystemType();
systems.LoadExtraSystemType();
@@ -135,6 +137,12 @@ namespace Robust.UnitTesting
systems.LoadExtraSystemType();
systems.LoadExtraSystemType();
systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
+ systems.LoadExtraSystemType();
}
else
{
@@ -171,6 +179,11 @@ namespace Robust.UnitTesting
compFactory.RegisterClass();
compFactory.RegisterClass();
}
+ else
+ {
+ compFactory.RegisterClass();
+ compFactory.RegisterClass();
+ }
deps.Resolve().Initialize();