Revert "Remove most usages of obsolete TransformComponent methods (#1… (#19714)

This commit is contained in:
metalgearsloth
2023-09-01 12:30:29 +10:00
committed by GitHub
parent 37222930d9
commit 4cfc578011
91 changed files with 227 additions and 315 deletions

View File

@@ -28,7 +28,6 @@ namespace Content.Client.Tabletop
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
// Time in seconds to wait until sending the location of a dragged entity to the server again
private const float Delay = 1f / 10; // 10 Hz
@@ -77,8 +76,7 @@ namespace Content.Client.Tabletop
}
// If no entity is being dragged or no viewport is clicked, return
if (_draggedEntity == null || _viewport == null)
return;
if (_draggedEntity == null || _viewport == null) return;
if (!CanDrag(playerEntity, _draggedEntity.Value, out var draggableComponent))
{
@@ -100,11 +98,10 @@ namespace Content.Client.Tabletop
// Clamp coordinates to viewport
var clampedCoords = ClampPositionToViewport(coords, _viewport);
if (clampedCoords.Equals(MapCoordinates.Nullspace))
return;
if (clampedCoords.Equals(MapCoordinates.Nullspace)) return;
// Move the entity locally every update
_transform.SetWorldPosition(_draggedEntity.Value, clampedCoords.Position);
EntityManager.GetComponent<TransformComponent>(_draggedEntity.Value).WorldPosition = clampedCoords.Position;
// Increment total time passed
_timePassed += frameTime;
@@ -185,11 +182,10 @@ namespace Content.Client.Tabletop
{
if (_draggedEntity != null && _table != null)
{
RaiseNetworkEvent(new TabletopRequestTakeOut
{
Entity = _draggedEntity.Value,
TableUid = _table.Value,
});
var ev = new TabletopRequestTakeOut();
ev.Entity = _draggedEntity.Value;
ev.TableUid = _table.Value;
RaiseNetworkEvent(ev);
}
return false;
}
@@ -282,12 +278,10 @@ namespace Content.Client.Tabletop
/// <returns>Coordinates clamped to the viewport.</returns>
private static MapCoordinates ClampPositionToViewport(MapCoordinates coordinates, ScalingViewport viewport)
{
if (coordinates == MapCoordinates.Nullspace)
return MapCoordinates.Nullspace;
if (coordinates == MapCoordinates.Nullspace) return MapCoordinates.Nullspace;
var eye = viewport.Eye;
if (eye == null)
return MapCoordinates.Nullspace;
if (eye == null) return MapCoordinates.Nullspace;
var size = (Vector2) viewport.ViewportSize / EyeManager.PixelsPerMeter; // Convert to tiles instead of pixels
var eyePosition = eye.Position.Position;