Skip to content

Commit

Permalink
Merge pull request Simple-Station#18 from VMSolidus/Hotfix-again
Browse files Browse the repository at this point in the history
Fixes the last upstream merge blunder, also the test fail is a false negative. Mob mimic test is safe to ignore.
  • Loading branch information
VMSolidus authored Jun 3, 2024
2 parents 904b3b7 + d536841 commit 9e603bb
Show file tree
Hide file tree
Showing 377 changed files with 1,762 additions and 731 deletions.
8 changes: 7 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"recommendations": [
"ms-dotnettools.csharp",
"editorconfig.editorconfig"
"editorconfig.editorconfig",
"aaron-bond.better-comments",
"tamasfe.even-better-toml",
"slava0135.robust-yaml",
"slevesque.shader",
"macabeus.vscode-fluent",
"redhat.vscode-yaml"
]
}
5 changes: 3 additions & 2 deletions Content.Client/CardboardBox/CardboardBoxSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Content.Shared.CardboardBox;
using Content.Shared.CardboardBox.Components;
using Content.Shared.Examine;
Expand All @@ -11,6 +11,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -55,7 +56,7 @@ private void OnBoxEffect(PlayBoxEffectMessage msg)
foreach (var mob in mobMoverEntities)
{
var mapPos = _transform.GetMapCoordinates(mob);
if (!ExamineSystemShared.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
if (!_examine.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
continue;

var ent = Spawn(box.Effect, mapPos);
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void PopulateProducts()
if (search.Length == 0 && _category == null ||
search.Length != 0 && prototype.Name.ToLowerInvariant().Contains(search) ||
search.Length != 0 && prototype.Description.ToLowerInvariant().Contains(search) ||
search.Length == 0 && _category != null && prototype.Category.Equals(_category))
search.Length == 0 && _category != null && Loc.GetString(prototype.Category).Equals(_category))
{
var button = new CargoProductRow
{
Expand Down Expand Up @@ -122,7 +122,7 @@ public void PopulateCategories()

foreach (var prototype in ProductPrototypes)
{
if (!_categoryStrings.Contains(prototype.Category))
if (!_categoryStrings.Contains(Loc.GetString(prototype.Category)))
{
_categoryStrings.Add(Loc.GetString(prototype.Category));
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Construction/ConstructionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public sealed class ConstructionSystem : SharedConstructionSystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;

private readonly Dictionary<int, EntityUid> _ghosts = new();
Expand Down Expand Up @@ -195,7 +196,7 @@ public bool TrySpawnGhost(
return false;

// This InRangeUnobstructed should probably be replaced with "is there something blocking us in that tile?"
var predicate = GetPredicate(prototype.CanBuildInImpassable, loc.ToMap(EntityManager));
var predicate = GetPredicate(prototype.CanBuildInImpassable, loc.ToMap(EntityManager, _transformSystem));
if (!_interactionSystem.InRangeUnobstructed(user, loc, 20f, predicate: predicate))
return false;

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/ContextMenu/UI/EntityMenuUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private bool HandleOpenEntityMenu(in PointerInputCmdHandler.PointerInputCmdArgs
if (_combatMode.IsInCombatMode(args.Session?.AttachedEntity))
return false;

var coords = args.Coordinates.ToMap(_entityManager);
var coords = args.Coordinates.ToMap(_entityManager, _xform);

if (_verbSystem.TryGetEntityMenuEntities(coords, out var entities))
OpenRootMenu(entities);
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Gameplay/GameplayStateBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private bool HandleInspect(ICommonSession? session, EntityCoordinates coords, En

public IEnumerable<EntityUid> GetClickableEntities(EntityCoordinates coordinates)
{
return GetClickableEntities(coordinates.ToMap(_entityManager));
return GetClickableEntities(coordinates.ToMap(_entityManager, _entitySystemManager.GetEntitySystem<SharedTransformSystem>()));
}

public IEnumerable<EntityUid> GetClickableEntities(MapCoordinates coordinates)
Expand Down
10 changes: 7 additions & 3 deletions Content.Client/NPC/PathfindingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public sealed class PathfindingSystem : SharedPathfindingSystem
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly NPCSteeringSystem _steering = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;

public PathfindingDebugMode Modes
{
Expand All @@ -39,7 +40,7 @@ public PathfindingDebugMode Modes
}
else if (!overlayManager.HasOverlay<PathfindingOverlay>())
{
overlayManager.AddOverlay(new PathfindingOverlay(EntityManager, _eyeManager, _inputManager, _mapManager, _cache, this, _mapSystem));
overlayManager.AddOverlay(new PathfindingOverlay(EntityManager, _eyeManager, _inputManager, _mapManager, _cache, this, _mapSystem, _transformSystem));
}

if ((value & PathfindingDebugMode.Steering) != 0x0)
Expand Down Expand Up @@ -140,6 +141,7 @@ public sealed class PathfindingOverlay : Overlay
private readonly IMapManager _mapManager;
private readonly PathfindingSystem _system;
private readonly MapSystem _mapSystem;
private readonly SharedTransformSystem _transformSystem;

public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace;

Expand All @@ -153,14 +155,16 @@ public PathfindingOverlay(
IMapManager mapManager,
IResourceCache cache,
PathfindingSystem system,
MapSystem mapSystem)
MapSystem mapSystem,
SharedTransformSystem transformSystem)
{
_entManager = entManager;
_eyeManager = eyeManager;
_inputManager = inputManager;
_mapManager = mapManager;
_system = system;
_mapSystem = mapSystem;
_transformSystem = transformSystem;
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
}

Expand Down Expand Up @@ -480,7 +484,7 @@ private void DrawWorld(OverlayDrawArgs args, DrawingHandleWorld worldHandle)
if (neighborPoly.NetEntity != poly.GraphUid)
{
color = Color.Green;
var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager);
var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager, _transformSystem);

if (neighborMap.MapId != args.MapId)
continue;
Expand Down
11 changes: 8 additions & 3 deletions Content.Client/Popups/PopupOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public sealed class PopupOverlay : Overlay
private readonly IUserInterfaceManager _uiManager;
private readonly PopupSystem _popup;
private readonly PopupUIController _controller;

private readonly ExamineSystemShared _examine;
private readonly SharedTransformSystem _transform;
private readonly ShaderInstance _shader;

public override OverlaySpace Space => OverlaySpace.ScreenSpace;
Expand All @@ -33,12 +34,16 @@ public PopupOverlay(
IPrototypeManager protoManager,
IUserInterfaceManager uiManager,
PopupUIController controller,
ExamineSystemShared examine,
SharedTransformSystem transform,
PopupSystem popup)
{
_configManager = configManager;
_entManager = entManager;
_playerMgr = playerMgr;
_uiManager = uiManager;
_examine = examine;
_transform = transform;
_popup = popup;
_controller = controller;

Expand Down Expand Up @@ -73,15 +78,15 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl

foreach (var popup in _popup.WorldLabels)
{
var mapPos = popup.InitialPos.ToMap(_entManager);
var mapPos = popup.InitialPos.ToMap(_entManager, _transform);

if (mapPos.MapId != args.MapId)
continue;

var distance = (mapPos.Position - args.WorldBounds.Center).Length();

// Should handle fade here too wyci.
if (!args.WorldBounds.Contains(mapPos.Position) || !ExamineSystemShared.InRangeUnOccluded(viewPos, mapPos, distance,
if (!args.WorldBounds.Contains(mapPos.Position) || !_examine.InRangeUnOccluded(viewPos, mapPos, distance,
e => e == popup.InitialPos.EntityId || e == ourEntity, entMan: _entManager))
continue;

Expand Down
5 changes: 5 additions & 0 deletions Content.Client/Popups/PopupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared.Examine;
using Content.Shared.GameTicking;
using Content.Shared.Popups;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -26,6 +27,8 @@ public sealed class PopupSystem : SharedPopupSystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

public IReadOnlyList<WorldPopupLabel> WorldLabels => _aliveWorldLabels;
public IReadOnlyList<CursorPopupLabel> CursorLabels => _aliveCursorLabels;
Expand All @@ -51,6 +54,8 @@ public override void Initialize()
_prototype,
_uiManager,
_uiManager.GetUIController<PopupUIController>(),
_examine,
_transform,
this));
}

Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ private void RadiationQuery(IEye? currentEye)

private bool PulseQualifies(EntityUid pulseEntity, MapCoordinates currentEyeLoc)
{
return _entityManager.GetComponent<TransformComponent>(pulseEntity).MapID == currentEyeLoc.MapId && _entityManager.GetComponent<TransformComponent>(pulseEntity).Coordinates.InRange(_entityManager, EntityCoordinates.FromMap(_entityManager, _entityManager.GetComponent<TransformComponent>(pulseEntity).ParentUid, currentEyeLoc), MaxDist);
var transformComponent = _entityManager.GetComponent<TransformComponent>(pulseEntity);
var transformSystem = _entityManager.System<SharedTransformSystem>();
return transformComponent.MapID == currentEyeLoc.MapId
&& transformComponent.Coordinates.InRange(_entityManager, transformSystem, EntityCoordinates.FromMap(transformComponent.ParentUid, currentEyeLoc, transformSystem, _entityManager), MaxDist);
}

private sealed record RadiationShaderInstance(MapCoordinates CurrentMapCoords, float Range, TimeSpan Start, float Duration)
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Sandbox/SandboxSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public sealed class SandboxSystem : SharedSandboxSystem
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IPlacementManager _placement = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

private bool _sandboxEnabled;
public bool SandboxAllowed { get; private set; }
Expand Down Expand Up @@ -108,7 +109,7 @@ public bool Copy(ICommonSession? session, EntityCoordinates coords, EntityUid ui
}

// Try copy tile.
if (!_map.TryFindGridAt(coords.ToMap(EntityManager), out _, out var grid) || !grid.TryGetTileRef(coords, out var tileRef))
if (!_map.TryFindGridAt(coords.ToMap(EntityManager, _transform), out _, out var grid) || !grid.TryGetTileRef(coords, out var tileRef))
return false;

if (_placement.Eraser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ private void UpdateQueuedSpeechBubbles(FrameEventArgs delta)

var otherPos = EntityManager.GetComponent<TransformComponent>(ent).MapPosition;

if (occluded && !ExamineSystemShared.InRangeUnOccluded(
if (occluded && !_examine.InRangeUnOccluded(
playerPos,
otherPos, 0f,
(ent, player), predicate))
Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Verbs/VerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Content.Client.Verbs
public sealed class VerbSystem : SharedVerbSystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ExamineSystem _examineSystem = default!;
[Dependency] private readonly ExamineSystem _examine = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
Expand Down Expand Up @@ -77,7 +77,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
bool Predicate(EntityUid e) => e == player || entitiesUnderMouse.Contains(e);

// first check the general location.
if (!_examineSystem.CanExamine(player.Value, targetPos, Predicate))
if (!_examine.CanExamine(player.Value, targetPos, Predicate))
return false;

TryComp(player.Value, out ExaminerComponent? examiner);
Expand All @@ -86,7 +86,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
entities = new();
foreach (var ent in _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize))
{
if (_examineSystem.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
if (_examine.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
entities.Add(ent);
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
{
var entity = entities[i];

if (!ExamineSystemShared.InRangeUnOccluded(
if (!_examine.InRangeUnOccluded(
playerPos,
xformQuery.GetComponent(entity).MapPosition,
ExamineSystemShared.ExamineRange,
Expand Down
103 changes: 103 additions & 0 deletions Content.IntegrationTests/Tests/Wires/WireLayoutTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using Content.Server.Doors;
using Content.Server.Power;
using Content.Server.Wires;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;

namespace Content.IntegrationTests.Tests.Wires;

[TestFixture]
[Parallelizable(ParallelScope.All)]
[TestOf(typeof(WiresSystem))]
public sealed class WireLayoutTest
{
[TestPrototypes]
public const string Prototypes = """
- type: wireLayout
id: WireLayoutTest
dummyWires: 2
wires:
- !type:PowerWireAction
- !type:DoorBoltWireAction

- type: wireLayout
id: WireLayoutTest2
parent: WireLayoutTest
wires:
- !type:PowerWireAction

- type: wireLayout
id: WireLayoutTest3
parent: WireLayoutTest

- type: entity
id: WireLayoutTest
components:
- type: Wires
layoutId: WireLayoutTest

- type: entity
id: WireLayoutTest2
components:
- type: Wires
layoutId: WireLayoutTest2

- type: entity
id: WireLayoutTest3
components:
- type: Wires
layoutId: WireLayoutTest3
""";

[Test]
public async Task TestLayoutInheritance()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var testMap = await pair.CreateTestMap();

await server.WaitAssertion(() =>
{
var wires = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<WiresSystem>();
// Need to spawn these entities to make sure the wire layouts are initialized.
var ent1 = SpawnWithComp<WiresComponent>(server.EntMan, "WireLayoutTest", testMap.MapCoords);
var ent2 = SpawnWithComp<WiresComponent>(server.EntMan, "WireLayoutTest2", testMap.MapCoords);
var ent3 = SpawnWithComp<WiresComponent>(server.EntMan, "WireLayoutTest3", testMap.MapCoords);
// Assert.That(wires.TryGetLayout("WireLayoutTest", out var layout1));
// Assert.That(wires.TryGetLayout("WireLayoutTest2", out var layout2));
// Assert.That(wires.TryGetLayout("WireLayoutTest3", out var layout3));
Assert.Multiple(() =>
{
// Entity 1.
Assert.That(ent1.Comp.WiresList, Has.Count.EqualTo(4));
Assert.That(ent1.Comp.WiresList, Has.Exactly(2).With.Property("Action").Null, "2 dummy wires");
Assert.That(ent1.Comp.WiresList, Has.One.With.Property("Action").InstanceOf<PowerWireAction>(), "1 power wire");
Assert.That(ent1.Comp.WiresList, Has.One.With.Property("Action").InstanceOf<DoorBoltWireAction>(), "1 door bolt wire");
Assert.That(ent2.Comp.WiresList, Has.Count.EqualTo(5));
Assert.That(ent2.Comp.WiresList, Has.Exactly(2).With.Property("Action").Null, "2 dummy wires");
Assert.That(ent2.Comp.WiresList, Has.Exactly(2).With.Property("Action").InstanceOf<PowerWireAction>(), "2 power wire");
Assert.That(ent2.Comp.WiresList, Has.One.With.Property("Action").InstanceOf<DoorBoltWireAction>(), "1 door bolt wire");
Assert.That(ent3.Comp.WiresList, Has.Count.EqualTo(4));
Assert.That(ent3.Comp.WiresList, Has.Exactly(2).With.Property("Action").Null, "2 dummy wires");
Assert.That(ent3.Comp.WiresList, Has.One.With.Property("Action").InstanceOf<PowerWireAction>(), "1 power wire");
Assert.That(ent3.Comp.WiresList, Has.One.With.Property("Action").InstanceOf<DoorBoltWireAction>(), "1 door bolt wire");
});
});

await pair.CleanReturnAsync();
}

private static Entity<T> SpawnWithComp<T>(IEntityManager entityManager, string prototype, MapCoordinates coords)
where T : IComponent, new()
{
var ent = entityManager.Spawn(prototype, coords);
var comp = entityManager.EnsureComponent<T>(ent);
return new Entity<T>(ent, comp);
}
}
Loading

0 comments on commit 9e603bb

Please sign in to comment.