mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Inline OwnerUid
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Robust.Client.Animations
|
||||
throw new InvalidOperationException("Must set parameters to non-null values.");
|
||||
}
|
||||
|
||||
var entity = (IEntity) context;
|
||||
var entity = (EntityUid) context;
|
||||
var component = IoCManager.Resolve<IEntityManager>().GetComponent(entity, ComponentType);
|
||||
|
||||
if (component is IAnimationProperties properties)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Robust.Client.Animations
|
||||
public override (int KeyFrameIndex, float FramePlayingTime)
|
||||
AdvancePlayback(object context, int prevKeyFrameIndex, float prevPlayingTime, float frameTime)
|
||||
{
|
||||
var entity = (IEntity) context;
|
||||
var entity = (EntityUid) context;
|
||||
|
||||
var playingTime = prevPlayingTime + frameTime;
|
||||
var keyFrameIndex = prevKeyFrameIndex;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Robust.Client.Animations
|
||||
{
|
||||
DebugTools.AssertNotNull(LayerKey);
|
||||
|
||||
var entity = (IEntity) context;
|
||||
var entity = (EntityUid) context;
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
|
||||
var playingTime = prevPlayingTime + frameTime;
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Robust.Client.Audio.Midi
|
||||
}
|
||||
else if (renderer.TrackingEntity != null)
|
||||
{
|
||||
mapPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(renderer.TrackingEntity).MapPosition;
|
||||
mapPos = _entityManager.GetComponent<TransformComponent>(renderer.TrackingEntity.Value).MapPosition;
|
||||
}
|
||||
|
||||
if (mapPos != null)
|
||||
@@ -322,7 +322,7 @@ namespace Robust.Client.Audio.Midi
|
||||
sourceRelative.Normalized,
|
||||
OcclusionCollisionMask),
|
||||
sourceRelative.Length,
|
||||
renderer.TrackingEntity);
|
||||
renderer.TrackingEntity.Value);
|
||||
}
|
||||
|
||||
renderer.Source.SetOcclusion(occlusion);
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Robust.Client.Audio.Midi
|
||||
/// The entity whose position will be used for positional audio.
|
||||
/// This is only used if <see cref="Mono"/> is set to True.
|
||||
/// </summary>
|
||||
IEntity? TrackingEntity { get; set; }
|
||||
EntityUid? TrackingEntity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position that will be used for positional audio.
|
||||
@@ -306,7 +306,7 @@ namespace Robust.Client.Audio.Midi
|
||||
public bool VolumeBoost { get; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public IEntity? TrackingEntity { get; set; } = null;
|
||||
public EntityUid? TrackingEntity { get; set; } = null;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public EntityCoordinates? TrackingCoordinates { get; set; } = null;
|
||||
|
||||
@@ -14,7 +14,7 @@ public abstract class AppearanceVisualizer
|
||||
/// Initializes an entity to be managed by this appearance controller.
|
||||
/// DO NOT assume this is your only entity. Visualizers are shared.
|
||||
/// </summary>
|
||||
public virtual void InitializeEntity(IEntity entity)
|
||||
public virtual void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ public abstract class AppearanceVisualizer
|
||||
public virtual void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Robust.Client.GameObjects
|
||||
if (_visible == value) return;
|
||||
_visible = value;
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
if (_containerOccluded == value) return;
|
||||
_containerOccluded = value;
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1505,7 +1505,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
// Look this was an easy way to get bounds checks for layer updates.
|
||||
// If you really want it optimal you'll need to comb through all 2k lines of spritecomponent.
|
||||
IEntity tempQualifier = Owner;
|
||||
EntityUid tempQualifier = Owner;
|
||||
if ((tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null)?.EventBus != null)
|
||||
UpdateBounds();
|
||||
|
||||
@@ -1515,7 +1515,7 @@ namespace Robust.Client.GameObjects
|
||||
_inertUpdateQueued = true;
|
||||
// Yes that null check is valid because of that stupid fucking dummy IEntity.
|
||||
// Who thought that was a good idea.
|
||||
IEntity tempQualifier1 = Owner;
|
||||
EntityUid tempQualifier1 = Owner;
|
||||
(tempQualifier1 != null ? IoCManager.Resolve<IEntityManager>() : null)?.EventBus?.RaiseEvent(EventSource.Local, new SpriteUpdateInertEvent {Sprite = this});
|
||||
}
|
||||
|
||||
@@ -1657,7 +1657,7 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
internal void UpdateBounds()
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Robust.Server.Bql
|
||||
}
|
||||
|
||||
return entityManager.GetAllComponents((Type) arguments[0])
|
||||
.Select(x => x.OwnerUid);
|
||||
.Select(x => x.Owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +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<TransformComponent>(e, out var transform) &&
|
||||
transform.Parent?.OwnerUid == uid) ^ isInverted);
|
||||
return input.Where(e => (entityManager.TryGetComponent<TransformComponent>(e, out var transform) && transform.Parent?.Owner == uid) ^ isInverted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ namespace Robust.Server.Bql
|
||||
return input.SelectMany(e =>
|
||||
{
|
||||
return entityManager.TryGetComponent<TransformComponent>(e, out var transform)
|
||||
? transform.Children.Select(y => y.OwnerUid)
|
||||
? transform.Children.Select(y => ((IComponent) y).Owner)
|
||||
: new List<EntityUid>();
|
||||
});
|
||||
}
|
||||
@@ -133,8 +132,8 @@ namespace Robust.Server.Bql
|
||||
var search = doing.SelectMany(x => x.Children.Select(y => y.Owner));
|
||||
if (!search.Any())
|
||||
break;
|
||||
toSearch = doing.SelectMany(x => x.Children.Select(y => y.OwnerUid)).Where(x => x != EntityUid.Invalid);
|
||||
children.Add(doing.SelectMany(x => x.Children.Select(y => y.OwnerUid)).Where(x => x != EntityUid.Invalid));
|
||||
toSearch = doing.SelectMany(x => x.Children.Select(y => ((IComponent) y).Owner)).Where(x => x != EntityUid.Invalid);
|
||||
children.Add(doing.SelectMany(x => x.Children.Select(y => ((IComponent) y).Owner)).Where(x => x != EntityUid.Invalid));
|
||||
}
|
||||
|
||||
return children.SelectMany(x => x);
|
||||
@@ -151,13 +150,13 @@ namespace Robust.Server.Bql
|
||||
public override IEnumerable<EntityUid> DoSelection(IEnumerable<EntityUid> input, IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
return input.Where(entityManager.HasComponent<TransformComponent>)
|
||||
.Select(e => entityManager.GetComponent<TransformComponent>(e).OwnerUid)
|
||||
.Select(e => { return ((IComponent) entityManager.GetComponent<TransformComponent>(e)).Owner; })
|
||||
.Distinct();
|
||||
}
|
||||
|
||||
public override IEnumerable<EntityUid> DoInitialSelection(IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
return DoSelection(entityManager.EntityQuery<TransformComponent>().Select(x => x.OwnerUid), arguments,
|
||||
return DoSelection(entityManager.EntityQuery<TransformComponent>().Select(x => ((IComponent) x).Owner), arguments,
|
||||
isInverted, entityManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,7 +757,7 @@ namespace Robust.Server.Maps
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityUidMap.Add(mapIdComp.OwnerUid, uid);
|
||||
EntityUidMap.Add(((IComponent) mapIdComp).Owner, uid);
|
||||
takenIds.Add(uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public IEntity Owner { get; set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public EntityUid OwnerUid => Owner;
|
||||
public EntityUid Owner { get; set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
@@ -248,7 +244,7 @@ namespace Robust.Shared.GameObjects
|
||||
return;
|
||||
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
entManager.DirtyEntity(OwnerUid);
|
||||
entManager.DirtyEntity(Owner);
|
||||
LastModifiedTick = entManager.CurrentTick;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace Robust.Shared.GameObjects
|
||||
// TODO: Placeholder; look it's disgusting but my main concern is stopping fixtures being serialized every tick
|
||||
// on physics bodies for massive shuttle perf savings.
|
||||
[Obsolete("Use FixturesComponent instead.")]
|
||||
public IReadOnlyList<Fixture> Fixtures => IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(OwnerUid).Fixtures.Values.ToList();
|
||||
public IReadOnlyList<Fixture> Fixtures => IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) this).Owner).Fixtures.Values.ToList();
|
||||
|
||||
public int FixtureCount => IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(OwnerUid).Fixtures.Count;
|
||||
public int FixtureCount => IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) this).Owner).Fixtures.Count;
|
||||
|
||||
[ViewVariables]
|
||||
public int ContactCount
|
||||
@@ -152,7 +152,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
EntitySystem.Get<SharedBroadphaseSystem>().RegenerateContacts(this);
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new PhysicsBodyTypeChangedEvent(_bodyType, oldType), false);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new PhysicsBodyTypeChangedEvent(_bodyType, oldType), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,11 +195,11 @@ namespace Robust.Shared.GameObjects
|
||||
if (value)
|
||||
{
|
||||
_sleepTime = 0.0f;
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new PhysicsWakeMessage(this));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new PhysicsWakeMessage(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new PhysicsSleepMessage(this));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new PhysicsSleepMessage(this));
|
||||
ResetDynamics();
|
||||
_sleepTime = 0.0f;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ namespace Robust.Shared.GameObjects
|
||||
return;
|
||||
|
||||
_canCollide = value;
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new CollisionChangeMessage(this, OwnerUid, _canCollide));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new CollisionChangeMessage(this, ((IComponent) this).Owner, _canCollide));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new PhysicsUpdateMessage(this));
|
||||
Dirty();
|
||||
}
|
||||
@@ -758,7 +758,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
public Vector2 GetLocalVector2(Vector2 worldVector)
|
||||
{
|
||||
return Transform.MulT(new Quaternion2D((float) IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(OwnerUid).WorldRotation.Theta), worldVector);
|
||||
return Transform.MulT(new Quaternion2D((float) IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(((IComponent) this).Owner).WorldRotation.Theta), worldVector);
|
||||
}
|
||||
|
||||
public Transform GetTransform()
|
||||
@@ -869,8 +869,8 @@ namespace Robust.Shared.GameObjects
|
||||
else
|
||||
{
|
||||
// TODO: Probably a bad idea but ehh future sloth's problem; namely that we have to duplicate code between here and CanCollide.
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new CollisionChangeMessage(this, Owner, _canCollide));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new PhysicsUpdateMessage(this));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new CollisionChangeMessage(this, Owner, _canCollide));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new PhysicsUpdateMessage(this));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var xform = (TransformComponent) transform;
|
||||
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
|
||||
var result = Grid.AddToSnapGridCell(tileIndices, transform.OwnerUid);
|
||||
var result = Grid.AddToSnapGridCell(tileIndices, ((IComponent) transform).Owner);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
var xform = (TransformComponent)transform;
|
||||
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
|
||||
Grid.RemoveFromSnapGridCell(tileIndices, transform.OwnerUid);
|
||||
Grid.RemoveFromSnapGridCell(tileIndices, ((IComponent) transform).Owner);
|
||||
xform.SetAnchored(false);
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(xform.Owner, out var physicsComponent))
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
RebuildMatrices();
|
||||
var rotateEvent = new RotateEvent(Owner, oldRotation, _localRotation);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref rotateEvent);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref rotateEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -179,19 +179,18 @@ namespace Robust.Shared.GameObjects
|
||||
get => !_parent.IsValid() ? null : IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_parent);
|
||||
internal set
|
||||
{
|
||||
if (_anchored && value?.OwnerUid != _parent)
|
||||
if (value == null)
|
||||
{
|
||||
AttachToGridOrMap();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_anchored && ((IComponent) value).Owner != _parent)
|
||||
{
|
||||
Anchored = false;
|
||||
}
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
AttachParent(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
AttachToGridOrMap();
|
||||
}
|
||||
AttachParent(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +290,7 @@ namespace Robust.Shared.GameObjects
|
||||
get
|
||||
{
|
||||
var valid = _parent.IsValid();
|
||||
return new EntityCoordinates(valid ? _parent : OwnerUid, valid ? LocalPosition : Vector2.Zero);
|
||||
return new EntityCoordinates(valid ? _parent : ((IComponent) this).Owner, valid ? LocalPosition : Vector2.Zero);
|
||||
}
|
||||
// NOTE: This setter must be callable from before initialize (inheriting from AttachParent's note)
|
||||
set
|
||||
@@ -324,7 +323,7 @@ namespace Robust.Shared.GameObjects
|
||||
// That's already our parent, don't bother attaching again.
|
||||
|
||||
var oldParent = Parent;
|
||||
var uid = OwnerUid;
|
||||
var uid = ((IComponent) this).Owner;
|
||||
oldParent?._children.Remove(uid);
|
||||
newParent._children.Add(uid);
|
||||
|
||||
@@ -336,7 +335,7 @@ namespace Robust.Shared.GameObjects
|
||||
GridID = GetGridIndex();
|
||||
|
||||
var entParentChangedMessage = new EntParentChangedMessage(Owner, oldParent?.Owner);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref entParentChangedMessage);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref entParentChangedMessage);
|
||||
}
|
||||
|
||||
// These conditions roughly emulate the effects of the code before I changed things,
|
||||
@@ -354,7 +353,7 @@ namespace Robust.Shared.GameObjects
|
||||
if(!oldPosition.Position.Equals(Coordinates.Position))
|
||||
{
|
||||
var moveEvent = new MoveEvent(Owner, oldPosition, Coordinates, this);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref moveEvent);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref moveEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +399,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
RebuildMatrices();
|
||||
var moveEvent = new MoveEvent(Owner, oldGridPos, Coordinates, this);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref moveEvent);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref moveEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -542,7 +541,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
// Note that _children is a SortedSet<EntityUid>,
|
||||
// so duplicate additions (which will happen) don't matter.
|
||||
((TransformComponent) Parent!)._children.Add(OwnerUid);
|
||||
((TransformComponent) Parent!)._children.Add(((IComponent) this).Owner);
|
||||
}
|
||||
|
||||
GridID = GetGridIndex();
|
||||
@@ -598,14 +597,14 @@ namespace Robust.Shared.GameObjects
|
||||
if (_oldCoords != null)
|
||||
{
|
||||
var moveEvent = new MoveEvent(Owner, _oldCoords.Value, Coordinates, this, worldAABB);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref moveEvent);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref moveEvent);
|
||||
_oldCoords = null;
|
||||
}
|
||||
|
||||
if (_oldLocalRotation != null)
|
||||
{
|
||||
var rotateEvent = new RotateEvent(Owner, _oldLocalRotation.Value, _localRotation, worldAABB);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref rotateEvent);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref rotateEvent);
|
||||
_oldLocalRotation = null;
|
||||
}
|
||||
}
|
||||
@@ -667,12 +666,12 @@ namespace Robust.Shared.GameObjects
|
||||
Anchored = false;
|
||||
|
||||
var oldConcrete = (TransformComponent) oldParent;
|
||||
var uid = OwnerUid;
|
||||
var uid = ((IComponent) this).Owner;
|
||||
oldConcrete._children.Remove(uid);
|
||||
|
||||
_parent = EntityUid.Invalid;
|
||||
var entParentChangedMessage = new EntParentChangedMessage(Owner, oldParent?.Owner);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref entParentChangedMessage);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref entParentChangedMessage);
|
||||
var oldMapId = MapID;
|
||||
MapID = MapId.Nullspace;
|
||||
|
||||
@@ -691,14 +690,14 @@ namespace Robust.Shared.GameObjects
|
||||
//NOTE: This function must be callable from before initialize
|
||||
|
||||
// don't attach to something we're already attached to
|
||||
if (ParentUid == newParent.OwnerUid)
|
||||
if (ParentUid == ((IComponent) newParent).Owner)
|
||||
return;
|
||||
|
||||
DebugTools.Assert(newParent != this,
|
||||
$"Can't parent a {nameof(TransformComponent)} to itself.");
|
||||
|
||||
// offset position from world to parent, and set
|
||||
Coordinates = new EntityCoordinates(newParent.OwnerUid, newParent.InvWorldMatrix.Transform(WorldPosition));
|
||||
Coordinates = new EntityCoordinates(((IComponent) newParent).Owner, newParent.InvWorldMatrix.Transform(WorldPosition));
|
||||
}
|
||||
|
||||
internal void ChangeMapId(MapId newMapId)
|
||||
@@ -732,7 +731,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void MapIdChanged(MapId oldId)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new EntMapIdChangedMessage(Owner, oldId));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new EntMapIdChangedMessage(Owner, oldId));
|
||||
}
|
||||
|
||||
public void AttachParent(IEntity parent)
|
||||
@@ -855,7 +854,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
var newParentId = newState.ParentID;
|
||||
var rebuildMatrices = false;
|
||||
if (Parent?.OwnerUid != newParentId)
|
||||
if (Parent?.Owner != newParentId)
|
||||
{
|
||||
if (newParentId != _parent)
|
||||
{
|
||||
@@ -984,7 +983,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
ActivelyLerping = true;
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, new TransformStartLerpMessage(this));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new TransformStartLerpMessage(this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1041,7 +1040,7 @@ namespace Robust.Shared.GameObjects
|
||||
Dirty();
|
||||
|
||||
var anchorStateChangedEvent = new AnchorStateChangedEvent(Owner, value);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(OwnerUid, ref anchorStateChangedEvent);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, ref anchorStateChangedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
ref var unitRef = ref Unsafe.As<TEvent, Unit>(ref args);
|
||||
|
||||
_eventTables.DispatchComponent<TEvent>(component.OwnerUid, component, ref unitRef, false);
|
||||
_eventTables.DispatchComponent<TEvent>(component.Owner, component, ref unitRef, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -109,7 +109,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
ref var unitRef = ref Unsafe.As<TEvent, Unit>(ref args);
|
||||
|
||||
_eventTables.DispatchComponent<TEvent>(component.OwnerUid, component, ref unitRef, true);
|
||||
_eventTables.DispatchComponent<TEvent>(component.Owner, component, ref unitRef, true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
if (component == null) throw new ArgumentNullException(nameof(component));
|
||||
|
||||
if (component.OwnerUid != uid) throw new InvalidOperationException("Component is not owned by entity.");
|
||||
if (((IComponent) component).Owner != uid) throw new InvalidOperationException("Component is not owned by entity.");
|
||||
|
||||
AddComponentInternal(uid, component, overwrite);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
if (component == null) throw new ArgumentNullException(nameof(component));
|
||||
|
||||
if (component.Owner == null || component.OwnerUid != uid)
|
||||
if (component.Owner == null || component.Owner != uid)
|
||||
throw new InvalidOperationException("Component is not owned by entity.");
|
||||
|
||||
RemoveComponentImmediate((Component)component, uid, false);
|
||||
@@ -415,7 +415,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var reg = _componentFactory.GetRegistration(component.GetType());
|
||||
|
||||
var entityUid = component.OwnerUid;
|
||||
var entityUid = ((IComponent) component).Owner;
|
||||
|
||||
// ReSharper disable once InvertIf
|
||||
if (reg.NetID != null)
|
||||
|
||||
@@ -10,8 +10,6 @@ using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
public delegate void EntityQueryCallback(IEntity entity);
|
||||
|
||||
public delegate void EntityUidQueryCallback(EntityUid uid);
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -44,7 +42,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// All entities currently stored in the manager.
|
||||
/// </summary>
|
||||
protected readonly Dictionary<EntityUid, IEntity> Entities = new();
|
||||
protected readonly Dictionary<EntityUid, MetaDataComponent> Entities = new();
|
||||
|
||||
private EntityEventBus _eventBus = null!;
|
||||
|
||||
|
||||
@@ -42,12 +42,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Entity that this component is attached to.
|
||||
/// </summary>
|
||||
IEntity Owner { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity Uid that this component is attached to.
|
||||
/// </summary>
|
||||
EntityUid OwnerUid => Owner;
|
||||
EntityUid Owner { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Component has been properly initialized.
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Robust.Shared.Map
|
||||
if (GridExists(gridIndex))
|
||||
{
|
||||
Logger.DebugS("map",
|
||||
$"Entity {comp.OwnerUid} removed grid component, removing bound grid {gridIndex}");
|
||||
$"Entity {((IComponent) comp).Owner} removed grid component, removing bound grid {gridIndex}");
|
||||
DeleteGrid(gridIndex);
|
||||
}
|
||||
}
|
||||
@@ -267,8 +267,8 @@ namespace Robust.Shared.Map
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
_mapEntities.Add(actualID, result.OwnerUid);
|
||||
Logger.DebugS("map", $"Rebinding map {actualID} to entity {result.OwnerUid}");
|
||||
_mapEntities.Add(actualID, result.Owner);
|
||||
Logger.DebugS("map", $"Rebinding map {actualID} to entity {result.Owner}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -383,8 +383,8 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
var bodyA = contact.FixtureA!.Body;
|
||||
var bodyB = contact.FixtureB!.Body;
|
||||
|
||||
_physicsManager.EnsureTransform(bodyA.OwnerUid);
|
||||
_physicsManager.EnsureTransform(bodyB.OwnerUid);
|
||||
_physicsManager.EnsureTransform(((IComponent) bodyA).Owner);
|
||||
_physicsManager.EnsureTransform(((IComponent) bodyB).Owner);
|
||||
}
|
||||
|
||||
// Update contacts all at once.
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
if (MathHelper.CloseToPercent(value, _friction)) return;
|
||||
|
||||
_friction = value;
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(Body.OwnerUid), Body);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) Body).Owner), Body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
if (MathHelper.CloseTo(value, _restitution)) return;
|
||||
|
||||
_restitution = value;
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(Body.OwnerUid), Body);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) Body).Owner), Body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
|
||||
_hard = value;
|
||||
Body.Awake = true;
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(Body.OwnerUid), Body);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) Body).Owner), Body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
if (MathHelper.CloseToPercent(value, _mass)) return;
|
||||
|
||||
_mass = MathF.Max(0f, value);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(Body.OwnerUid), Body);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) Body).Owner), Body);
|
||||
Body.ResetMassData();
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
return;
|
||||
|
||||
_collisionLayer = value;
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(Body.OwnerUid), Body);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) Body).Owner), Body);
|
||||
EntitySystem.Get<SharedBroadphaseSystem>().Refilter(this);
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
return;
|
||||
|
||||
_collisionMask = value;
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(Body.OwnerUid), Body);
|
||||
EntitySystem.Get<FixtureSystem>().FixtureUpdate(IoCManager.Resolve<IEntityManager>().GetComponent<FixturesComponent>(((IComponent) Body).Owner), Body);
|
||||
EntitySystem.Get<SharedBroadphaseSystem>().Refilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
other.Island = true;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(body.OwnerUid, out JointComponent? jointComponent)) continue;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(((IComponent) body).Owner, out JointComponent? jointComponent)) continue;
|
||||
|
||||
foreach (var (_, joint) in jointComponent.Joints)
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Robust.Shared.Physics
|
||||
|
||||
public void CreateFixture(PhysicsComponent body, Fixture fixture, bool updates = true, FixturesComponent? manager = null, TransformComponent? xform = null)
|
||||
{
|
||||
if (!Resolve(body.OwnerUid, ref manager, ref xform))
|
||||
if (!Resolve(((IComponent) body).Owner, ref manager, ref xform))
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
return;
|
||||
@@ -145,7 +145,7 @@ namespace Robust.Shared.Physics
|
||||
/// </summary>
|
||||
public Fixture? GetFixtureOrNull(PhysicsComponent body, string id, FixturesComponent? manager = null)
|
||||
{
|
||||
if (!Resolve(body.OwnerUid, ref manager))
|
||||
if (!Resolve(((IComponent) body).Owner, ref manager))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace Robust.Shared.Physics
|
||||
/// <param name="updates">Whether to update mass etc. Set false if you're doing a bulk operation</param>
|
||||
public void DestroyFixture(PhysicsComponent body, Fixture fixture, bool updates = true, FixturesComponent? manager = null)
|
||||
{
|
||||
if (!Resolve(body.OwnerUid, ref manager))
|
||||
if (!Resolve(((IComponent) body).Owner, ref manager))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -366,7 +366,7 @@ namespace Robust.Shared.Physics
|
||||
/// </summary>
|
||||
public void FixtureUpdate(FixturesComponent component, PhysicsComponent? body = null)
|
||||
{
|
||||
if (!Resolve(component.OwnerUid, ref body))
|
||||
if (!Resolve(((IComponent) component).Owner, ref body))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Robust.Shared.Physics
|
||||
|
||||
public Transform EnsureTransform(PhysicsComponent body)
|
||||
{
|
||||
return EnsureTransform(body.OwnerUid);
|
||||
return EnsureTransform(((IComponent) body).Owner);
|
||||
}
|
||||
|
||||
public Transform EnsureTransform(EntityUid uid)
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Robust.Shared.Physics
|
||||
AddBody(update.Component);
|
||||
}
|
||||
|
||||
_handledThisTick.Add(update.Component.OwnerUid);
|
||||
_handledThisTick.Add(((IComponent) update.Component).Owner);
|
||||
}
|
||||
|
||||
// Body update may not necessarily handle this (unless the thing's deleted) so we'll still do this work regardless.
|
||||
@@ -137,7 +137,7 @@ namespace Robust.Shared.Physics
|
||||
!body.CanCollide) continue;
|
||||
|
||||
UpdateBroadphase(body);
|
||||
_handledThisTick.Add(body.OwnerUid);
|
||||
_handledThisTick.Add(((IComponent) body).Owner);
|
||||
}
|
||||
|
||||
while (_queuedMoves.TryDequeue(out var move))
|
||||
@@ -185,7 +185,7 @@ namespace Robust.Shared.Physics
|
||||
|
||||
internal void UpdateBroadphaseCache(BroadphaseComponent broadphase)
|
||||
{
|
||||
var uid = broadphase.OwnerUid;
|
||||
var uid = ((IComponent) broadphase).Owner;
|
||||
|
||||
var xformComp = EntityManager.GetComponent<TransformComponent>(uid);
|
||||
|
||||
@@ -293,13 +293,13 @@ namespace Robust.Shared.Physics
|
||||
foreach (var (broadphase, _) in _broadphaseTransforms)
|
||||
{
|
||||
// Broadphase can't intersect with entities on itself so skip.
|
||||
if (proxyBody.OwnerUid == broadphase.OwnerUid ||
|
||||
if (((IComponent) proxyBody).Owner == ((IComponent) broadphase).Owner ||
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(broadphase.Owner).MapID != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(proxyBody.Owner).MapID) continue;
|
||||
|
||||
var enlargedAABB = worldAABB.Enlarged(_broadphaseExpand);
|
||||
|
||||
// If we're a map / our BB intersects then we'll do the work
|
||||
if (_broadphaseBounding.TryGetValue(broadphase.OwnerUid, out var broadphaseAABB) &&
|
||||
if (_broadphaseBounding.TryGetValue(((IComponent) broadphase).Owner, out var broadphaseAABB) &&
|
||||
!broadphaseAABB.Intersects(enlargedAABB)) continue;
|
||||
|
||||
// Logger.DebugS("physics", $"Checking proxy for {proxy.Fixture.Body.Owner} on {broadphase.Owner}");
|
||||
@@ -313,7 +313,7 @@ namespace Robust.Shared.Physics
|
||||
}
|
||||
else
|
||||
{
|
||||
aabb = _broadphaseInvMatrices[broadphase.OwnerUid].TransformBox(worldAABB);
|
||||
aabb = _broadphaseInvMatrices[((IComponent) broadphase).Owner].TransformBox(worldAABB);
|
||||
}
|
||||
|
||||
foreach (var other in broadphase.Tree.QueryAabb(_queryBuffer, aabb))
|
||||
@@ -412,7 +412,7 @@ namespace Robust.Shared.Physics
|
||||
/// </summary>
|
||||
private void DestroyProxies(PhysicsComponent body, FixturesComponent? manager = null)
|
||||
{
|
||||
if (!Resolve(body.OwnerUid, ref manager)) return;
|
||||
if (!Resolve(((IComponent) body).Owner, ref manager)) return;
|
||||
|
||||
var broadphase = body.Broadphase;
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Robust.Shared.Physics
|
||||
internal void RemoveBody(PhysicsComponent body, FixturesComponent? manager = null)
|
||||
{
|
||||
// TODO: Would reaaalllyy like for this to not be false in future
|
||||
if (!Resolve(body.OwnerUid, ref manager, false))
|
||||
if (!Resolve(((IComponent) body).Owner, ref manager, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -599,7 +599,7 @@ namespace Robust.Shared.Physics
|
||||
}
|
||||
|
||||
// Ensure cache remains up to date if the broadphase is moving.
|
||||
var uid = body.OwnerUid;
|
||||
var uid = ((IComponent) body).Owner;
|
||||
|
||||
if (EntityManager.TryGetComponent(uid, out BroadphaseComponent? broadphase))
|
||||
{
|
||||
@@ -617,7 +617,7 @@ namespace Robust.Shared.Physics
|
||||
var proxyCount = fixture.ProxyCount;
|
||||
|
||||
var broadphaseMapId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(broadphase.Owner).MapID;
|
||||
var broadphaseInvMatrix = _broadphaseInvMatrices[broadphase.OwnerUid];
|
||||
var broadphaseInvMatrix = _broadphaseInvMatrices[((IComponent) broadphase).Owner];
|
||||
var broadphaseXform = _broadphaseTransforms[broadphase];
|
||||
|
||||
var relativePos1 = new Transform(
|
||||
@@ -687,7 +687,7 @@ namespace Robust.Shared.Physics
|
||||
}
|
||||
|
||||
// Ensure cache remains up to date if the broadphase is moving.
|
||||
var uid = body.OwnerUid;
|
||||
var uid = ((IComponent) body).Owner;
|
||||
|
||||
if (EntityManager.TryGetComponent(uid, out BroadphaseComponent? broadphaseComp))
|
||||
{
|
||||
@@ -727,11 +727,11 @@ namespace Robust.Shared.Physics
|
||||
|
||||
Matrix3 broadphaseInvMatrix;
|
||||
(Vector2 Position, float Rotation) broadphaseTransform;
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(broadphase.OwnerUid);
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(((IComponent) broadphase).Owner);
|
||||
|
||||
if (useCache)
|
||||
{
|
||||
broadphaseInvMatrix = _broadphaseInvMatrices[broadphase.OwnerUid];
|
||||
broadphaseInvMatrix = _broadphaseInvMatrices[((IComponent) broadphase).Owner];
|
||||
broadphaseTransform = _broadphaseTransforms[broadphase];
|
||||
}
|
||||
else
|
||||
@@ -894,7 +894,7 @@ namespace Robust.Shared.Physics
|
||||
{
|
||||
if (xform.MapID != mapId) continue;
|
||||
|
||||
if (!EntityManager.TryGetComponent(broadphase.OwnerUid, out IMapGridComponent? mapGrid))
|
||||
if (!EntityManager.TryGetComponent(((IComponent) broadphase).Owner, out IMapGridComponent? mapGrid))
|
||||
{
|
||||
yield return broadphase;
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user