mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
* Fix warnings in SharedJointSystem * Fix reference to EC TransformComponent method Replaces call to TransformComponent.GetMapUid with SharedTransformSystem.GetMap * Fix obsolete calls in SharedPhysicsSystem.Contacts.cs Fixes a couple calls to obsolete varients of SetAwake and an obsolete call to RegenerateContacts by converting them to their Entity<T> varients * Fix obsolete call in SharedPhysicsSystem.Components.cs Adds one set of parenthesis to convert a 'uid, comp, comp, comp' call to an 'Entity<T, T, T> call. * Removes unused local var Removes an unused list of broadphases that was being allocated in TryCollideRect * One-line fixes in SharedPhysicsSystem.Islands.cs Fixes all of the easy warnings regarding physics island processing, the rest require more complicated changes than a simple argument rearrangement * Fix obsolete method call in SharedMapSystem * Fix a few obsolete ToMap calls in EntityLookup.Queries * Fix calls to obsolete EntityCoordinate methods in SharedMapSystem.Grids * Fix calls to obsolete EntityCoordinate methods in SharedLookupSystem.ComponentQueries * Fix a few obsolete method calls in entity spawning * Fix obsolete method calls in MapLoaderSystem * Fix obsolete method call in GridFixtureSystem * Fix obsolete IsMapInitialized call in SaveMap command * Fix obsolete MapPosition reference in Client.EyeSystem * Fix obsolete EntitySystem.Get<TSystem> references in DebugLightTreeSystem * Fix obsolete EntitySystem.Get<TSystem> reference in DebugEntityLookup command * Fix obsolete method calls in SpriteBoundsOverlay Slightly more complicated than the rest, but it's really just changing an unused dependency over to use SharedTransformSystem * Remove unused IClyde references from controls LineEdit and TextEdit never use their IClyde dependencies and it generates a warning so yeet * Remove use of EntitySystem.Get from lightbb command * Fix DebugDrawingSystem Removes a bunch of unused private IEntityManager vars Also removes an obsolete use of TransformComponent.GetWorldPositionRotation * Removes duplicate position set when splitting grids There's nothing saying why this is this way and the blame looks like it was an oversight when replacing a bit where they set position and then rotation Please, oh Chesterton's Fence, spare me your wrath * Fix obsolete method use in PlacementMode * Fix obsolete method use in Placement Modes * Removes unused local var in gamestate management * Fix unreachable code warnings in gamestate management Use #else sections to make sure they don't complain about being on the wrong side of a throw * Fix obsolete ToMap use in EyeManager * Make InputManager use a sawmill to log * Fix obsolete ContainerManagerComponent method calls in ContainerSystem * Make ClientPrototypeManager use a sawmill for logging * poke tests * Use LocalizedEntityCommands for SpriteBoundsOverlay toggle * Use LocalizedEntityCommands for system toggles --------- Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using JetBrains.Annotations;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.Shared.GameObjects;
|
|
|
|
public abstract partial class SharedMapSystem
|
|
{
|
|
/// <summary>
|
|
/// If the supplied coordinates intersects a grid will align with the tile center, otherwise returns the coordinates.
|
|
/// </summary>
|
|
/// <param name="coordinates"></param>
|
|
/// <returns></returns>
|
|
[Pure]
|
|
public EntityCoordinates AlignToGrid(EntityCoordinates coordinates)
|
|
{
|
|
// Check if the parent is already a grid.
|
|
if (_gridQuery.TryGetComponent(coordinates.EntityId, out var gridComponent))
|
|
{
|
|
var tile = CoordinatesToTile(coordinates.EntityId, gridComponent, coordinates);
|
|
return ToCenterCoordinates(coordinates.EntityId, tile, gridComponent);
|
|
}
|
|
|
|
// Check if mappos intersects a grid.
|
|
var mapPos = _transform.ToMapCoordinates(coordinates);
|
|
|
|
if (_mapInternal.TryFindGridAt(mapPos, out var gridUid, out gridComponent))
|
|
{
|
|
var tile = CoordinatesToTile(gridUid, gridComponent, coordinates);
|
|
return ToCenterCoordinates(gridUid, tile, gridComponent);
|
|
}
|
|
|
|
// No grid so just return it.
|
|
return coordinates;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a tileRef to EntityCoordinates.
|
|
/// </summary>
|
|
[Pure]
|
|
public EntityCoordinates ToCoordinates(TileRef tileRef, MapGridComponent? gridComponent = null)
|
|
{
|
|
return ToCoordinates(tileRef.GridUid, tileRef.GridIndices, gridComponent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a tileRef to EntityCoordinates.
|
|
/// </summary>
|
|
[Pure]
|
|
public EntityCoordinates ToCoordinates(EntityUid gridUid, Vector2i tile, MapGridComponent? gridComponent = null)
|
|
{
|
|
if (!_gridQuery.Resolve(gridUid, ref gridComponent))
|
|
{
|
|
return EntityCoordinates.Invalid;
|
|
}
|
|
|
|
return new EntityCoordinates(gridUid, tile * gridComponent.TileSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a tileRef to EntityCoordinates for the center of the tile.
|
|
/// </summary>
|
|
[Pure]
|
|
public EntityCoordinates ToCenterCoordinates(TileRef tileRef, MapGridComponent? gridComponent = null)
|
|
{
|
|
return ToCenterCoordinates(tileRef.GridUid, tileRef.GridIndices, gridComponent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a tileRef to EntityCoordinates for the center of the tile.
|
|
/// </summary>
|
|
[Pure]
|
|
public EntityCoordinates ToCenterCoordinates(EntityUid gridUid, Vector2i tile, MapGridComponent? gridComponent = null)
|
|
{
|
|
if (!_gridQuery.Resolve(gridUid, ref gridComponent))
|
|
{
|
|
return EntityCoordinates.Invalid;
|
|
}
|
|
|
|
return new EntityCoordinates(gridUid, tile * gridComponent.TileSize + gridComponent.TileSizeHalfVector);
|
|
}
|
|
}
|