mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Remove every ITransformComponent usage.
This commit is contained in:
@@ -25,8 +25,8 @@ namespace Robust.Client.GameObjects
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
private ITransformComponent? _lastParent;
|
||||
private ITransformComponent? _lerpTo;
|
||||
private TransformComponent? _lastParent;
|
||||
private TransformComponent? _lerpTo;
|
||||
private Angle LerpStartRotation;
|
||||
private float _accumulator;
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Robust.Client.GameObjects
|
||||
AnythingMovedSubHandler(args.Sender.Transform);
|
||||
}
|
||||
|
||||
private void AnythingMovedSubHandler(ITransformComponent sender)
|
||||
private void AnythingMovedSubHandler(TransformComponent sender)
|
||||
{
|
||||
// To avoid doing redundant updates (and we don't need to update a grid's children ever)
|
||||
if (!_checkedChildren.Add(sender.Owner.Uid) ||
|
||||
@@ -125,7 +125,7 @@ namespace Robust.Client.GameObjects
|
||||
if (sender.Owner.TryGetComponent(out PointLightComponent? light))
|
||||
QueueLightUpdate(light);
|
||||
|
||||
foreach (ITransformComponent child in sender.Children)
|
||||
foreach (TransformComponent child in sender.Children)
|
||||
{
|
||||
AnythingMovedSubHandler(child);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
continue;
|
||||
}
|
||||
|
||||
var transform = _entityManager.GetComponent<ITransformComponent>(grid.GridEntityId);
|
||||
var transform = _entityManager.GetComponent<TransformComponent>(grid.GridEntityId);
|
||||
gridProgram.SetUniform(UniIModelMatrix, transform.WorldMatrix);
|
||||
grid.GetMapChunks(worldBounds, out var enumerator);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Robust.Server.Bql
|
||||
public override IEnumerable<EntityUid> DoSelection(IEnumerable<EntityUid> input, IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
var uid = (EntityUid) arguments[0];
|
||||
return input.Where(e => (entityManager.TryGetComponent<ITransformComponent>(e, out var transform) &&
|
||||
return input.Where(e => (entityManager.TryGetComponent<TransformComponent>(e, out var transform) &&
|
||||
transform.Parent?.OwnerUid == uid) ^ isInverted);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace Robust.Server.Bql
|
||||
var uid = (EntityUid) arguments[0];
|
||||
return input.Where(e =>
|
||||
{
|
||||
if (!entityManager.TryGetComponent<ITransformComponent>(e, out var transform))
|
||||
if (!entityManager.TryGetComponent<TransformComponent>(e, out var transform))
|
||||
return isInverted;
|
||||
var cur = transform;
|
||||
while (cur.ParentUid != EntityUid.Invalid)
|
||||
@@ -107,7 +107,7 @@ namespace Robust.Server.Bql
|
||||
{
|
||||
return input.SelectMany(e =>
|
||||
{
|
||||
return entityManager.TryGetComponent<ITransformComponent>(e, out var transform)
|
||||
return entityManager.TryGetComponent<TransformComponent>(e, out var transform)
|
||||
? transform.Children.Select(y => y.OwnerUid)
|
||||
: new List<EntityUid>();
|
||||
});
|
||||
@@ -129,7 +129,7 @@ namespace Robust.Server.Bql
|
||||
|
||||
while (true)
|
||||
{
|
||||
var doing = toSearch.Where(entityManager.HasComponent<ITransformComponent>).Select(entityManager.GetComponent<ITransformComponent>).ToArray();
|
||||
var doing = toSearch.Where(entityManager.HasComponent<TransformComponent>).Select(entityManager.GetComponent<TransformComponent>).ToArray();
|
||||
var search = doing.SelectMany(x => x.Children.Select(y => y.Owner));
|
||||
if (!search.Any())
|
||||
break;
|
||||
@@ -150,14 +150,14 @@ namespace Robust.Server.Bql
|
||||
|
||||
public override IEnumerable<EntityUid> DoSelection(IEnumerable<EntityUid> input, IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
return input.Where(entityManager.HasComponent<ITransformComponent>)
|
||||
.Select(e => entityManager.GetComponent<ITransformComponent>(e).OwnerUid)
|
||||
return input.Where(entityManager.HasComponent<TransformComponent>)
|
||||
.Select(e => entityManager.GetComponent<TransformComponent>(e).OwnerUid)
|
||||
.Distinct();
|
||||
}
|
||||
|
||||
public override IEnumerable<EntityUid> DoInitialSelection(IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
return DoSelection(entityManager.EntityQuery<ITransformComponent>().Select(x => x.OwnerUid), arguments,
|
||||
return DoSelection(entityManager.EntityQuery<TransformComponent>().Select(x => x.OwnerUid), arguments,
|
||||
isInverted, entityManager);
|
||||
}
|
||||
}
|
||||
@@ -177,13 +177,13 @@ namespace Robust.Server.Bql
|
||||
var map = IoCManager.Resolve<IMapManager>();
|
||||
if (tileTy.TileId == 0)
|
||||
{
|
||||
return input.Where(e => entityManager.TryGetComponent<ITransformComponent>(e, out var transform) && (transform.Coordinates.GetGridId(entity) == GridId.Invalid) ^ isInverted);
|
||||
return input.Where(e => entityManager.TryGetComponent<TransformComponent>(e, out var transform) && (transform.Coordinates.GetGridId(entity) == GridId.Invalid) ^ isInverted);
|
||||
}
|
||||
else
|
||||
{
|
||||
return input.Where(e =>
|
||||
{
|
||||
if (!entityManager.TryGetComponent<ITransformComponent>(e, out var transform)) return isInverted;
|
||||
if (!entityManager.TryGetComponent<TransformComponent>(e, out var transform)) return isInverted;
|
||||
|
||||
var gridId = transform.Coordinates.GetGridId(entity);
|
||||
if (gridId == GridId.Invalid)
|
||||
@@ -208,7 +208,7 @@ namespace Robust.Server.Bql
|
||||
public override IEnumerable<EntityUid> DoSelection(IEnumerable<EntityUid> input, IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
var grid = new GridId((int) arguments[0]);
|
||||
return input.Where(e => (entityManager.TryGetComponent<ITransformComponent>(e, out var transform) && transform.GridID == grid) ^ isInverted);
|
||||
return input.Where(e => (entityManager.TryGetComponent<TransformComponent>(e, out var transform) && transform.GridID == grid) ^ isInverted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace Robust.Server.Bql
|
||||
public override IEnumerable<EntityUid> DoSelection(IEnumerable<EntityUid> input, IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
var map = new MapId((int) arguments[0]);
|
||||
return input.Where(e => (entityManager.TryGetComponent<ITransformComponent>(e, out var transform) && transform.MapID == map) ^ isInverted);
|
||||
return input.Where(e => (entityManager.TryGetComponent<TransformComponent>(e, out var transform) && transform.MapID == map) ^ isInverted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,9 +304,9 @@ namespace Robust.Server.Bql
|
||||
var entityLookup = IoCManager.Resolve<IEntityLookup>();
|
||||
|
||||
//BUG: GetEntitiesInRange effectively uses manhattan distance. This is not intended, near is supposed to be circular.
|
||||
return input.Where(entityManager.HasComponent<ITransformComponent>)
|
||||
return input.Where(entityManager.HasComponent<TransformComponent>)
|
||||
.SelectMany(e =>
|
||||
entityLookup.GetEntitiesInRange(entityManager.GetComponent<ITransformComponent>(e).Coordinates,
|
||||
entityLookup.GetEntitiesInRange(entityManager.GetComponent<TransformComponent>(e).Coordinates,
|
||||
radius))
|
||||
.Select(x => x.Uid) // Sloth's fault.
|
||||
.Distinct();
|
||||
@@ -323,7 +323,7 @@ namespace Robust.Server.Bql
|
||||
|
||||
public override IEnumerable<EntityUid> DoSelection(IEnumerable<EntityUid> input, IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
return input.Where(e => (entityManager.TryGetComponent<ITransformComponent>(e, out var transform) && transform.Anchored) ^ isInverted);
|
||||
return input.Where(e => (entityManager.TryGetComponent<TransformComponent>(e, out var transform) && transform.Anchored) ^ isInverted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Robust.Server.GameObjects
|
||||
//TODO: Calculate this from PAS
|
||||
var range = audioParams is null || audioParams.Value.MaxDistance <= 0 ? AudioDistanceRange : audioParams.Value.MaxDistance;
|
||||
|
||||
if(!EntityManager.TryGetComponent<ITransformComponent>(uid, out var transform))
|
||||
if(!EntityManager.TryGetComponent<TransformComponent>(uid, out var transform))
|
||||
return null;
|
||||
|
||||
var id = CacheIdentifier();
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Robust.Shared.Containers
|
||||
}
|
||||
}
|
||||
|
||||
public static void AttachParentToContainerOrGrid(this ITransformComponent transform)
|
||||
public static void AttachParentToContainerOrGrid(this TransformComponent transform)
|
||||
{
|
||||
if (transform.Parent == null
|
||||
|| !TryGetContainer(transform.Parent.Owner, out var container)
|
||||
@@ -153,7 +153,7 @@ namespace Robust.Shared.Containers
|
||||
transform.AttachToGridOrMap();
|
||||
}
|
||||
|
||||
private static bool TryInsertIntoContainer(this ITransformComponent transform, IContainer container)
|
||||
private static bool TryInsertIntoContainer(this TransformComponent transform, IContainer container)
|
||||
{
|
||||
if (container.Insert(transform.Owner)) return true;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Robust.Shared.Containers
|
||||
|
||||
#region Container Helpers
|
||||
|
||||
public bool TryGetContainingContainer(EntityUid uid, [NotNullWhen(true)] out IContainer? container, ITransformComponent? transform = null)
|
||||
public bool TryGetContainingContainer(EntityUid uid, [NotNullWhen(true)] out IContainer? container, TransformComponent? transform = null)
|
||||
{
|
||||
container = null;
|
||||
if (!Resolve(uid, ref transform, false))
|
||||
@@ -117,7 +117,7 @@ namespace Robust.Shared.Containers
|
||||
return TryGetContainingContainer(transform.ParentUid, uid, out container);
|
||||
}
|
||||
|
||||
public bool IsEntityInContainer(EntityUid uid, ITransformComponent? transform = null)
|
||||
public bool IsEntityInContainer(EntityUid uid, TransformComponent? transform = null)
|
||||
{
|
||||
return TryGetContainingContainer(uid, out _, transform);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Robust.Shared.GameObjects
|
||||
IMapGrid Grid { get; }
|
||||
void ClearGridId();
|
||||
|
||||
bool AnchorEntity(ITransformComponent transform);
|
||||
void UnanchorEntity(ITransformComponent transform);
|
||||
void AnchoredEntityDirty(ITransformComponent transform);
|
||||
bool AnchorEntity(TransformComponent transform);
|
||||
void UnanchorEntity(TransformComponent transform);
|
||||
void AnchoredEntityDirty(TransformComponent transform);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IMapGridComponent"/>
|
||||
@@ -68,7 +68,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool AnchorEntity(ITransformComponent transform)
|
||||
public bool AnchorEntity(TransformComponent transform)
|
||||
{
|
||||
var xform = (TransformComponent) transform;
|
||||
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
|
||||
@@ -93,7 +93,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void UnanchorEntity(ITransformComponent transform)
|
||||
public void UnanchorEntity(TransformComponent transform)
|
||||
{
|
||||
//HACK: Client grid pivot causes this.
|
||||
//TODO: make grid components the actual grid
|
||||
@@ -111,7 +111,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AnchoredEntityDirty(ITransformComponent transform)
|
||||
public void AnchoredEntityDirty(TransformComponent transform)
|
||||
{
|
||||
if (!transform.Anchored)
|
||||
return;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Robust.Shared.GameObjects
|
||||
var components = EntityManager.GetComponents(Uid)
|
||||
.OrderBy(x => x switch
|
||||
{
|
||||
ITransformComponent _ => 0,
|
||||
TransformComponent _ => 0,
|
||||
IPhysBody _ => 1,
|
||||
_ => int.MaxValue
|
||||
});
|
||||
@@ -156,7 +156,7 @@ namespace Robust.Shared.GameObjects
|
||||
var comps = EntityManager.GetComponents(Uid)
|
||||
.OrderBy(x => x switch
|
||||
{
|
||||
ITransformComponent _ => 0,
|
||||
TransformComponent _ => 0,
|
||||
IPhysBody _ => 1,
|
||||
_ => int.MaxValue
|
||||
});
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Robust.Shared.GameObjects
|
||||
$"Component reference type {type} already occupied by {duplicate}");
|
||||
|
||||
// these two components are required on all entities and cannot be overwritten.
|
||||
if (duplicate is ITransformComponent || duplicate is MetaDataComponent)
|
||||
if (duplicate is TransformComponent || duplicate is MetaDataComponent)
|
||||
throw new InvalidOperationException("Tried to overwrite a protected component.");
|
||||
|
||||
RemoveComponentImmediate(duplicate, uid, false);
|
||||
@@ -228,7 +228,7 @@ namespace Robust.Shared.GameObjects
|
||||
=> x switch
|
||||
{
|
||||
MetaDataComponent _ => 0,
|
||||
ITransformComponent _ => 1,
|
||||
TransformComponent _ => 1,
|
||||
IPhysBody _ => 2,
|
||||
_ => int.MaxValue
|
||||
};
|
||||
@@ -271,7 +271,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
#endif
|
||||
// these two components are required on all entities and cannot be removed normally.
|
||||
if (!removeProtected && component is ITransformComponent or MetaDataComponent)
|
||||
if (!removeProtected && component is TransformComponent or MetaDataComponent)
|
||||
{
|
||||
DebugTools.Assert("Tried to remove a protected component.");
|
||||
return;
|
||||
@@ -311,7 +311,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (!component.Deleted)
|
||||
{
|
||||
// these two components are required on all entities and cannot be removed.
|
||||
if (!removeProtected && component is ITransformComponent or MetaDataComponent)
|
||||
if (!removeProtected && component is TransformComponent or MetaDataComponent)
|
||||
{
|
||||
DebugTools.Assert("Tried to remove a protected component.");
|
||||
return;
|
||||
|
||||
@@ -512,7 +512,7 @@ namespace Robust.Shared.GameObjects
|
||||
public IEnumerable<IEntity> GetEntitiesIntersecting(IEntity entity, float enlarged = 0f, LookupFlags flags = LookupFlags.IncludeAnchored)
|
||||
{
|
||||
var worldAABB = GetWorldAabbFromEntity(entity);
|
||||
var xform = _entityManager.GetComponent<ITransformComponent>(entity.Uid);
|
||||
var xform = _entityManager.GetComponent<TransformComponent>(entity.Uid);
|
||||
var worldPos = xform.WorldPosition;
|
||||
var worldRot = xform.WorldRotation;
|
||||
|
||||
|
||||
@@ -485,7 +485,7 @@ stored in a single array since multiple arrays lead to multiple misses.
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdateBodies(List<(ITransformComponent Transform, PhysicsComponent Body)> deferredUpdates)
|
||||
internal void UpdateBodies(List<(TransformComponent Transform, PhysicsComponent Body)> deferredUpdates)
|
||||
{
|
||||
foreach (var (joint, error) in _brokenJoints)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
|
||||
// TODO: Given physics bodies are a common thing to be listening for on moveevents it's probably beneficial to have 2 versions; one that includes the entity
|
||||
// and one that includes the body
|
||||
private List<(ITransformComponent Transform, PhysicsComponent Body)> _deferredUpdates = new();
|
||||
private List<(TransformComponent Transform, PhysicsComponent Body)> _deferredUpdates = new();
|
||||
|
||||
/// <summary>
|
||||
/// All bodies present on this map.
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Robust.Shared.Physics
|
||||
{
|
||||
Vector2 result = new Vector2();
|
||||
|
||||
for (ITransformComponent transform = entity.Transform; transform.Parent != null; transform = transform.Parent)
|
||||
for (TransformComponent transform = entity.Transform; transform.Parent != null; transform = transform.Parent)
|
||||
{
|
||||
if (transform.Owner.TryGetComponent(out PhysicsComponent? physicsComponent))
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Robust.Shared.Player
|
||||
public Filter AddPlayersByPvs(EntityUid origin, float rangeMultiplier = 2f, IEntityManager? entityManager = null)
|
||||
{
|
||||
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
||||
var transform = entityManager.GetComponent<ITransformComponent>(origin);
|
||||
var transform = entityManager.GetComponent<TransformComponent>(origin);
|
||||
return AddPlayersByPvs(transform.MapPosition, rangeMultiplier);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Robust.Shared.Player
|
||||
/// Adds all players inside an entity's PVS.
|
||||
/// The current PVS range will be multiplied by <see cref="rangeMultiplier"/>.
|
||||
/// </summary>
|
||||
public Filter AddPlayersByPvs(ITransformComponent origin, float rangeMultiplier = 2f)
|
||||
public Filter AddPlayersByPvs(TransformComponent origin, float rangeMultiplier = 2f)
|
||||
{
|
||||
return AddPlayersByPvs(origin.MapPosition, rangeMultiplier);
|
||||
}
|
||||
@@ -346,7 +346,7 @@ namespace Robust.Shared.Player
|
||||
/// <summary>
|
||||
/// A filter with every player who's PVS overlaps this point.
|
||||
/// </summary>
|
||||
public static Filter Pvs(ITransformComponent origin, float rangeMultiplier = 2f)
|
||||
public static Filter Pvs(TransformComponent origin, float rangeMultiplier = 2f)
|
||||
{
|
||||
return Empty().AddPlayersByPvs(origin, rangeMultiplier);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
// Move item into PVS so it gets sent to the client
|
||||
entMan.GetComponent<ITransformComponent>(itemUid).LocalPosition = (0, 0);
|
||||
entMan.GetComponent<TransformComponent>(itemUid).LocalPosition = (0, 0);
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
|
||||
// An entity is anchored to the tile it is over on the target grid.
|
||||
// An entity is anchored by setting the flag on the transform.
|
||||
// An anchored entity is defined as an entity with the ITransformComponent.Anchored flag set.
|
||||
// An anchored entity is defined as an entity with the TransformComponent.Anchored flag set.
|
||||
// The Anchored field is used for serialization of anchored state.
|
||||
|
||||
// TODO: The grid SnapGrid functions are internal, expose the query functions to content.
|
||||
@@ -318,7 +318,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adding a physics component should poll ITransformComponent.Anchored for the correct body type.
|
||||
/// Adding a physics component should poll TransformComponent.Anchored for the correct body type.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void Anchored_AddPhysComp_IsStaticBody()
|
||||
|
||||
Reference in New Issue
Block a user