Lots of manual fixing. More to come.

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 17:01:46 +01:00
parent 5eda1b326d
commit c39f6d09eb
31 changed files with 163 additions and 211 deletions

View File

@@ -33,17 +33,17 @@ namespace Robust.Client.GameObjects
base.Initialize();
}
IEntity IClientEntityManagerInternal.CreateEntity(string? prototypeName, EntityUid? uid)
EntityUid IClientEntityManagerInternal.CreateEntity(string? prototypeName, EntityUid? uid)
{
return base.CreateEntity(prototypeName, uid);
}
void IClientEntityManagerInternal.InitializeEntity(IEntity entity)
void IClientEntityManagerInternal.InitializeEntity(EntityUid entity)
{
base.InitializeEntity(entity);
}
void IClientEntityManagerInternal.StartEntity(IEntity entity)
void IClientEntityManagerInternal.StartEntity(EntityUid entity)
{
base.StartEntity(entity);
}
@@ -107,7 +107,7 @@ namespace Robust.Client.GameObjects
/// <inheritdoc />
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
public void SendComponentNetworkMessage(INetChannel? channel, IEntity entity, IComponent component, ComponentMessage message)
public void SendComponentNetworkMessage(INetChannel? channel, EntityUid entity, IComponent component, ComponentMessage message)
{
var netId = ComponentFactory.GetRegistration(component.GetType()).NetID;

View File

@@ -2076,8 +2076,7 @@ namespace Robust.Client.GameObjects
}
var entityManager = IoCManager.Resolve<IEntityManager>();
IEntity tempQualifier = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace);
var dummy = (EntityUid) tempQualifier;
var dummy = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace);
var spriteComponent = entityManager.EnsureComponent<SpriteComponent>(dummy);
var anyTexture = false;
@@ -2116,8 +2115,7 @@ namespace Robust.Client.GameObjects
}
var entityManager = IoCManager.Resolve<IEntityManager>();
IEntity tempQualifier = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace);
var dummy = (EntityUid) tempQualifier;
var dummy = entityManager.SpawnEntity(prototype.ID, MapCoordinates.Nullspace);
var spriteComponent = entityManager.EnsureComponent<SpriteComponent>(dummy);
var result = spriteComponent.Icon ?? GetFallbackState(resourceCache);
entityManager.DeleteEntity(dummy);

View File

@@ -281,7 +281,7 @@ namespace Robust.Client.GameObjects
/// <param name="entity">The entity "emitting" the audio.</param>
/// <param name="fallbackCoordinates">The map or grid coordinates at which to play the audio when entity is invalid.</param>
/// <param name="audioParams"></param>
private IPlayingAudioStream? Play(string filename, IEntity entity, EntityCoordinates fallbackCoordinates,
private IPlayingAudioStream? Play(string filename, EntityUid entity, EntityCoordinates fallbackCoordinates,
AudioParams? audioParams = null)
{
if (_resourceCache.TryGetResource<AudioResource>(new ResourcePath(filename), out var audio))
@@ -300,7 +300,7 @@ namespace Robust.Client.GameObjects
/// <param name="entity">The entity "emitting" the audio.</param>
/// <param name="fallbackCoordinates">The map or grid coordinates at which to play the audio when entity is invalid.</param>
/// <param name="audioParams"></param>
private IPlayingAudioStream? Play(AudioStream stream, IEntity entity, EntityCoordinates fallbackCoordinates,
private IPlayingAudioStream? Play(AudioStream stream, EntityUid entity, EntityCoordinates fallbackCoordinates,
AudioParams? audioParams = null)
{
var source = _clyde.CreateAudioSource(stream);
@@ -407,7 +407,7 @@ namespace Robust.Client.GameObjects
{
public uint? NetIdentifier;
public IClydeAudioSource Source = default!;
public IEntity TrackingEntity = default!;
public EntityUid TrackingEntity = default!;
public EntityCoordinates? TrackingCoordinates;
public EntityCoordinates? TrackingFallbackCoordinates;
public bool Done;
@@ -450,17 +450,11 @@ namespace Robust.Client.GameObjects
}
/// <inheritdoc />
public IPlayingAudioStream? Play(Filter playerFilter, string filename, IEntity entity, AudioParams? audioParams = null)
public IPlayingAudioStream? Play(Filter playerFilter, string filename, EntityUid entity, AudioParams? audioParams = null)
{
return Play(filename, entity, GetFallbackCoordinates(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapPosition), audioParams);
}
public IPlayingAudioStream? Play(Filter playerFilter, string filename, EntityUid uid, AudioParams? audioParams = null)
{
return EntityManager.TryGetEntity(uid, out var entity)
? Play(filename, entity, GetFallbackCoordinates(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapPosition), audioParams) : null;
}
/// <inheritdoc />
public IPlayingAudioStream? Play(Filter playerFilter, string filename, EntityCoordinates coordinates, AudioParams? audioParams = null)
{

View File

@@ -113,13 +113,13 @@ namespace Robust.Client.GameObjects
/// </summary>
internal sealed class OccluderDirtyEvent : EntityEventArgs
{
public OccluderDirtyEvent(IEntity sender, (GridId grid, Vector2i pos)? lastPosition)
public OccluderDirtyEvent(EntityUid sender, (GridId grid, Vector2i pos)? lastPosition)
{
LastPosition = lastPosition;
Sender = sender;
}
public (GridId grid, Vector2i pos)? LastPosition { get; }
public IEntity Sender { get; }
public EntityUid Sender { get; }
}
}

View File

@@ -183,7 +183,7 @@ namespace Robust.Client.GameObjects
_updateQueue.Clear();
}
private static void UpdateEntityRecursively(IEntity entity)
private static void UpdateEntityRecursively(EntityUid entity)
{
// TODO: Since we are recursing down,
// we could cache ShowContents data here to speed it up for children.
@@ -196,7 +196,7 @@ namespace Robust.Client.GameObjects
}
}
private static void UpdateEntity(IEntity entity)
private static void UpdateEntity(EntityUid entity)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? sprite))
{

View File

@@ -70,14 +70,14 @@ namespace Robust.Client.GameObjects
// TODO: Content should have its own way of handling this. We should have a default behavior that they can overwrite.
IEntity? tempQualifier = _playerManager.LocalPlayer?.ControlledEntity;
EntityUid? tempQualifier = _playerManager.LocalPlayer?.ControlledEntity;
var playerTransform = (tempQualifier != null ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier) : null);
if (playerTransform == null) return;
var gridId = playerTransform.GridID;
IEntity tempQualifier1 = _mapManager.GetMapEntity(playerTransform.MapID);
var tempQualifier1 = _mapManager.GetMapEntity(playerTransform.MapID);
var parent = gridId != GridId.Invalid && EntityManager.TryGetEntity(_mapManager.GetGrid(gridId).GridEntityId, out var gridEnt) ?
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridEnt)
: IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier1);

View File

@@ -118,7 +118,7 @@ namespace Robust.Client.GameObjects
}
}
private static void SetEntityContextActive(IInputManager inputMan, IEntity entity)
private static void SetEntityContextActive(IInputManager inputMan, EntityUid entity)
{
if(entity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(entity))
throw new ArgumentNullException(nameof(entity));
@@ -163,13 +163,13 @@ namespace Robust.Client.GameObjects
/// <summary>
/// New entity the player is attached to.
/// </summary>
public IEntity? AttachedEntity { get; }
public EntityUid? AttachedEntity { get; }
/// <summary>
/// Creates a new instance of <see cref="PlayerAttachSysMessage"/>.
/// </summary>
/// <param name="attachedEntity">New entity the player is attached to.</param>
public PlayerAttachSysMessage(IEntity? attachedEntity)
public PlayerAttachSysMessage(EntityUid? attachedEntity)
{
AttachedEntity = attachedEntity;
}
@@ -177,21 +177,21 @@ namespace Robust.Client.GameObjects
public class PlayerAttachedEvent : EntityEventArgs
{
public PlayerAttachedEvent(IEntity entity)
public PlayerAttachedEvent(EntityUid entity)
{
Entity = entity;
}
public IEntity Entity { get; }
public EntityUid Entity { get; }
}
public class PlayerDetachedEvent : EntityEventArgs
{
public PlayerDetachedEvent(IEntity entity)
public PlayerDetachedEvent(EntityUid entity)
{
Entity = entity;
}
public IEntity Entity { get; }
public EntityUid Entity { get; }
}
}

View File

@@ -43,11 +43,11 @@ namespace Robust.Client.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
{
IEntity tempQualifier = EntityManager.GetEntity(grid.GridEntityId);
var tempQualifier = grid.GridEntityId;
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier);
}
IEntity tempQualifier1 = _mapManager.GetMapEntity(mapId);
var tempQualifier1 = _mapManager.GetMapEntity(mapId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier1);
}
@@ -57,11 +57,11 @@ namespace Robust.Client.GameObjects
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldAABB))
{
IEntity tempQualifier = EntityManager.GetEntity(grid.GridEntityId);
var tempQualifier = grid.GridEntityId;
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier);
}
IEntity tempQualifier1 = _mapManager.GetMapEntity(mapId);
var tempQualifier1 = _mapManager.GetMapEntity(mapId);
yield return IoCManager.Resolve<IEntityManager>().GetComponent<RenderingTreeComponent>(tempQualifier1);
}
@@ -249,19 +249,20 @@ namespace Robust.Client.GameObjects
EntityManager.GetEntity(_mapManager.GetGrid(gridId).GridEntityId).EnsureComponent<RenderingTreeComponent>();
}
internal static RenderingTreeComponent? GetRenderTree(IEntity entity)
internal static RenderingTreeComponent? GetRenderTree(EntityUid entity)
{
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID == MapId.Nullspace ||
if (!IoCManager.Resolve<IEntityManager>().EntityExists(entity) || IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID == MapId.Nullspace ||
IoCManager.Resolve<IEntityManager>().HasComponent<RenderingTreeComponent>(entity)) return null;
var parent = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Parent?.Owner;
while (true)
{
if (parent == null) break;
if (parent == null)
break;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(parent, out RenderingTreeComponent? comp)) return comp;
parent = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(parent).Parent?.Owner;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(parent.Value, out RenderingTreeComponent? comp)) return comp;
parent = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(parent.Value).Parent?.Owner;
}
return null;

View File

@@ -6,10 +6,10 @@ namespace Robust.Client.GameObjects
{
// These methods are used by the Game State Manager.
IEntity CreateEntity(string? prototypeName, EntityUid? uid = null);
EntityUid CreateEntity(string? prototypeName, EntityUid? uid = null);
void InitializeEntity(IEntity entity);
void InitializeEntity(EntityUid entity);
void StartEntity(IEntity entity);
void StartEntity(EntityUid entity);
}
}

View File

@@ -427,22 +427,22 @@ namespace Robust.Client.GameStates
private List<EntityUid> ApplyEntityStates(ReadOnlySpan<EntityState> curEntStates, ReadOnlySpan<EntityUid> deletions,
ReadOnlySpan<EntityState> nextEntStates)
{
var toApply = new Dictionary<IEntity, (EntityState?, EntityState?)>();
var toInitialize = new List<IEntity>();
var toApply = new Dictionary<EntityUid, (EntityState?, EntityState?)>();
var toInitialize = new List<EntityUid>();
var created = new List<EntityUid>();
var toHide = new List<EntityUid>();
var toShow = new List<EntityUid>();
foreach (var es in curEntStates)
{
EntityUid uid;
var uid = es.Uid;
//Known entities
if (_entities.TryGetEntity(es.Uid, out var entity))
if (_entities.EntityExists(uid))
{
// Logger.Debug($"[{IGameTiming.TickStampStatic}] MOD {es.Uid}");
toApply.Add(entity, (es, null));
if(_hiddenEntities.ContainsKey(es.Uid))
toShow.Add(es.Uid);
toApply.Add(uid, (es, null));
if(_hiddenEntities.ContainsKey(uid))
toShow.Add(uid);
uid = es.Uid;
}
else //Unknown entities
@@ -450,10 +450,10 @@ namespace Robust.Client.GameStates
var metaState = (MetaDataComponentState?) es.ComponentChanges.Value?.FirstOrDefault(c => c.NetID == _metaCompNetId).State;
if (metaState == null)
{
throw new InvalidOperationException($"Server sent new entity state for {es.Uid} without metadata component!");
throw new InvalidOperationException($"Server sent new entity state for {uid} without metadata component!");
}
// Logger.Debug($"[{IGameTiming.TickStampStatic}] CREATE {es.Uid} {metaState.PrototypeId}");
var newEntity = _entities.CreateEntity(metaState.PrototypeId, es.Uid);
var newEntity = _entities.CreateEntity(metaState.PrototypeId, uid);
toApply.Add(newEntity, (es, null));
toInitialize.Add(newEntity);
created.Add(newEntity);
@@ -465,15 +465,17 @@ namespace Robust.Client.GameStates
foreach (var es in nextEntStates)
{
if (_entities.TryGetEntity(es.Uid, out var entity))
var uid = es.Uid;
if (_entities.EntityExists(uid))
{
if (toApply.TryGetValue(entity, out var state))
if (toApply.TryGetValue(uid, out var state))
{
toApply[entity] = (state.Item1, es);
toApply[uid] = (state.Item1, es);
}
else
{
toApply[entity] = (null, es);
toApply[uid] = (null, es);
}
}
}
@@ -494,7 +496,7 @@ namespace Robust.Client.GameStates
}
#if EXCEPTION_TOLERANCE
HashSet<Entity> brokenEnts = new HashSet<Entity>();
HashSet<EntityUid> brokenEnts = new HashSet<EntityUid>();
#endif
foreach (var entity in toInitialize)
@@ -508,7 +510,7 @@ namespace Robust.Client.GameStates
}
catch (Exception e)
{
Logger.ErrorS("state", $"Server entity threw in Init: uid={entity.Uid}, proto={entity.Prototype}\n{e}");
Logger.ErrorS("state", $"Server entity threw in Init: ent={_entityManager.ToPrettyString(entity)}\n{e}");
brokenEnts.Add(entity);
}
#endif
@@ -528,7 +530,7 @@ namespace Robust.Client.GameStates
}
catch (Exception e)
{
Logger.ErrorS("state", $"Server entity threw in Start: uid={entity.Uid}, proto={entity.Prototype}\n{e}");
Logger.ErrorS("state", $"Server entity threw in Start: ent={_entityManager.ToPrettyString(entity)}\n{e}");
brokenEnts.Add(entity);
}
#endif
@@ -537,7 +539,7 @@ namespace Robust.Client.GameStates
#if EXCEPTION_TOLERANCE
foreach (var entity in brokenEnts)
{
entity.Delete();
_entityManager.DeleteEntity(entity);
}
#endif
@@ -559,7 +561,7 @@ namespace Robust.Client.GameStates
return created;
}
private void HandleEntityState(IEntity entity, IEventBus bus, EntityState? curState,
private void HandleEntityState(EntityUid entity, IEventBus bus, EntityState? curState,
EntityState? nextState)
{
var compStateWork = new Dictionary<ushort, (ComponentState? curState, ComponentState? nextState)>();

View File

@@ -110,8 +110,8 @@ namespace Robust.Client.GameStates
if(_entityManager.EntityExists(netEnt.Id))
{
//TODO: Whoever is working on PVS remake, change the InPVS detection.
IEntity tempQualifier = _entityManager.GetEntity(netEnt.Id);
var position = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier).MapPosition;
var uid = netEnt.Id;
var position = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(uid).MapPosition;
netEnt.InPVS = !pvsEnabled || (pvsBox.Contains(position.Position) && position.MapId == pvsCenter.MapId);
_netEnts[i] = netEnt; // copy struct back
continue;
@@ -168,8 +168,9 @@ namespace Robust.Client.GameStates
for (int i = 0; i < _netEnts.Count; i++)
{
var netEnt = _netEnts[i];
var uid = netEnt.Id;
if (!_entityManager.TryGetEntity(netEnt.Id, out var ent))
if (!_entityManager.EntityExists(uid))
{
_netEnts.RemoveSwap(i);
i--;
@@ -178,7 +179,7 @@ namespace Robust.Client.GameStates
var xPos = 100;
var yPos = 10 + _lineHeight * i;
var name = $"({netEnt.Id}) {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}";
var name = $"({netEnt.Id}) {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(uid).EntityPrototype?.ID}";
var color = CalcTextColor(ref netEnt);
screenHandle.DrawString(_font, new Vector2(xPos + (TrafficHistorySize + 4), yPos), name, color);
DrawTrafficBox(screenHandle, ref netEnt, xPos, yPos);

View File

@@ -330,8 +330,8 @@ namespace Robust.Client.Graphics.Clyde
var mapId = eye.Position.MapId;
// If this map has lighting disabled, return
IEntity tempQualifier = _mapManager.GetMapEntity(mapId);
if (!IoCManager.Resolve<IEntityManager>().GetComponent<IMapComponent>(tempQualifier).LightingEnabled)
var mapUid = _mapManager.GetMapEntity(mapId);
if (!IoCManager.Resolve<IEntityManager>().GetComponent<IMapComponent>(mapUid).LightingEnabled)
{
return;
}

View File

@@ -123,7 +123,7 @@ namespace Robust.Client.Graphics.Clyde
_clyde.DrawSetScissor(scissorBox);
}
public void DrawEntity(IEntity entity, Vector2 position, Vector2 scale, Direction? overrideDirection)
public void DrawEntity(EntityUid entity, Vector2 position, Vector2 scale, Direction? overrideDirection)
{
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
{
@@ -347,7 +347,7 @@ namespace Robust.Client.Graphics.Clyde
rect.BottomLeft, rect.BottomRight, color, subRegion);
}
public override void DrawEntity(IEntity entity, Vector2 position, Vector2 scale, Direction? overrideDirection)
public override void DrawEntity(EntityUid entity, Vector2 position, Vector2 scale, Direction? overrideDirection)
{
_renderHandle.DrawEntity(entity, position, scale, overrideDirection);
}

View File

@@ -94,6 +94,6 @@ namespace Robust.Client.Graphics
public Vector2 DrawString(Font font, Vector2 pos, string str)
=> DrawString(font, pos, str, Color.White);
public abstract void DrawEntity(IEntity entity, Vector2 position, Vector2 scale, Direction? overrideDirection);
public abstract void DrawEntity(EntityUid entity, Vector2 position, Vector2 scale, Direction? overrideDirection);
}
}

View File

@@ -12,6 +12,6 @@ namespace Robust.Client.Graphics
void RenderInRenderTarget(IRenderTarget target, Action a, Color clearColor=default);
void SetScissor(UIBox2i? scissorBox);
void DrawEntity(IEntity entity, Vector2 position, Vector2 scale, Direction? overrideDirection);
void DrawEntity(EntityUid entity, Vector2 position, Vector2 scale, Direction? overrideDirection);
}
}

View File

@@ -35,8 +35,8 @@ namespace Robust.Client.Physics
protected override void HandleMapCreated(object? sender, MapEventArgs eventArgs)
{
if (eventArgs.Map == MapId.Nullspace) return;
IEntity tempQualifier = MapManager.GetMapEntity(eventArgs.Map);
IoCManager.Resolve<IEntityManager>().AddComponent<PhysicsMapComponent>(tempQualifier);
var mapUid = MapManager.GetMapEntity(eventArgs.Map);
IoCManager.Resolve<IEntityManager>().AddComponent<PhysicsMapComponent>(mapUid);
}
}
}

View File

@@ -18,7 +18,7 @@ namespace Robust.Client.Placement
return false;
}
public virtual bool HijackDeletion(IEntity entity)
public virtual bool HijackDeletion(EntityUid entity)
{
return false;
}

View File

@@ -414,7 +414,7 @@ namespace Robust.Client.Placement
return false;
}
public void HandleDeletion(IEntity entity)
public void HandleDeletion(EntityUid entity)
{
if (!IsActive || !Eraser) return;
if (Hijack != null && Hijack.HijackDeletion(entity)) return;

View File

@@ -28,10 +28,7 @@ namespace Robust.Client.Player
/// Game entity that the local player is controlling. If this is null, the player is not attached to any
/// entity at all.
/// </summary>
[ViewVariables] public IEntity? ControlledEntity { get; private set; }
[ViewVariables] public EntityUid? ControlledEntityUid => ControlledEntity;
[ViewVariables] public EntityUid? ControlledEntity { get; private set; }
[ViewVariables] public NetUserId UserId { get; set; }
@@ -58,7 +55,7 @@ namespace Robust.Client.Player
/// Attaches a client to an entity.
/// </summary>
/// <param name="entity">Entity to attach the client to.</param>
public void AttachEntity(IEntity entity)
public void AttachEntity(EntityUid entity)
{
// Detach and cleanup first
DetachEntity();
@@ -66,17 +63,20 @@ namespace Robust.Client.Player
ControlledEntity = entity;
InternalSession.AttachedEntity = entity;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<EyeComponent?>(ControlledEntity, out var eye))
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent<EyeComponent?>(entity, out var eye))
{
eye = IoCManager.Resolve<IEntityManager>().AddComponent<EyeComponent>(ControlledEntity);
eye = entMan.AddComponent<EyeComponent>(entity);
}
eye.Current = true;
EntityAttached?.Invoke(new EntityAttachedEventArgs(entity));
// notify ECS Systems
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new PlayerAttachSysMessage(ControlledEntity));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(ControlledEntity, new PlayerAttachedEvent(ControlledEntity));
var eventBus = entMan.EventBus;
eventBus.RaiseEvent(EventSource.Local, new PlayerAttachSysMessage(entity));
eventBus.RaiseLocalEvent(entity, new PlayerAttachedEvent(entity));
}
/// <summary>
@@ -84,21 +84,22 @@ namespace Robust.Client.Player
/// </summary>
public void DetachEntity()
{
var entMan = IoCManager.Resolve<IEntityManager>();
var previous = ControlledEntity;
if (previous is {((!IoCManager.Resolve<IEntityManager>().EntityExists(Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Uid).EntityLifeStage) >= EntityLifeStage.Initialized): true, ((!IoCManager.Resolve<IEntityManager>().EntityExists(Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Uid).EntityLifeStage) >= EntityLifeStage.Deleted): false})
if (previous != null && entMan.EntityExists(previous.Value))
{
IoCManager.Resolve<IEntityManager>().GetComponent<EyeComponent>(previous).Current = false;
IoCManager.Resolve<IEntityManager>().GetComponent<EyeComponent>(previous.Value).Current = false;
// notify ECS Systems
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new PlayerAttachSysMessage(null));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(previous, new PlayerDetachedEvent(previous));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(previous.Value, new PlayerDetachedEvent(previous.Value));
}
ControlledEntity = null;
if (previous != null)
{
EntityDetached?.Invoke(new EntityDetachedEventArgs(previous));
EntityDetached?.Invoke(new EntityDetachedEventArgs(previous.Value));
}
}
@@ -148,21 +149,21 @@ namespace Robust.Client.Player
public class EntityDetachedEventArgs : EventArgs
{
public EntityDetachedEventArgs(IEntity oldEntity)
public EntityDetachedEventArgs(EntityUid oldEntity)
{
OldEntity = oldEntity;
}
public IEntity OldEntity { get; }
public EntityUid OldEntity { get; }
}
public class EntityAttachedEventArgs : EventArgs
{
public EntityAttachedEventArgs(IEntity newEntity)
public EntityAttachedEventArgs(EntityUid newEntity)
{
NewEntity = newEntity;
}
public IEntity NewEntity { get; }
public EntityUid NewEntity { get; }
}
}

View File

@@ -40,7 +40,7 @@ namespace Robust.Client.ViewVariables.Instances
private const int TabServerComponents = 3;
private TabContainer _tabs = default!;
private IEntity _entity = default!;
private EntityUid _entity = default!;
private ViewVariablesAddWindow? _addComponentWindow;
private bool _addComponentServer;

View File

@@ -213,7 +213,7 @@ namespace Robust.Client.ViewVariables
{
// TODO: more flexibility in allowing custom instances here.
ViewVariablesInstance instance;
if (obj is IEntity entity && !((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted))
if (obj is EntityUid entity && _entityManager.EntityExists(entity))
{
instance = new ViewVariablesInstanceEntity(this, _entityManager, _robustSerializer);
}
@@ -258,7 +258,7 @@ namespace Robust.Client.ViewVariables
var type = Type.GetType(blob.ObjectType);
// TODO: more flexibility in allowing custom instances here.
ViewVariablesInstance instance;
if (type != null && typeof(IEntity).IsAssignableFrom(type))
if (type != null && typeof(EntityUid).IsAssignableFrom(type))
{
instance = new ViewVariablesInstanceEntity(this, _entityManager, _robustSerializer);
}

View File

@@ -36,19 +36,23 @@ namespace Robust.Server.Bql
}
// This will be refactored out soon.
private static string SubstituteEntityDetails(IConsoleShell shell, IEntity ent, string ruleString)
private static string SubstituteEntityDetails(IConsoleShell shell, EntityUid ent, string ruleString)
{
var entMan = IoCManager.Resolve<IEntityManager>();
var transform = entMan.GetComponent<TransformComponent>(ent);
var metadata = entMan.GetComponent<MetaDataComponent>(ent);
// gross, is there a better way to do this?
ruleString = ruleString.Replace("$ID", ent.ToString());
ruleString = ruleString.Replace("$WX",
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent).WorldPosition.X.ToString(CultureInfo.InvariantCulture));
transform.WorldPosition.X.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$WY",
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent).WorldPosition.Y.ToString(CultureInfo.InvariantCulture));
transform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$LX",
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent).LocalPosition.X.ToString(CultureInfo.InvariantCulture));
transform.LocalPosition.X.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$LY",
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent).LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$NAME", IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ent).EntityName);
transform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$NAME", metadata.EntityName);
if (shell.Player is IPlayerSession player)
{

View File

@@ -15,7 +15,7 @@ namespace Robust.Shared.Containers
{
/// <inheritdoc />
[ViewVariables]
public abstract IReadOnlyList<IEntity> ContainedEntities { get; }
public abstract IReadOnlyList<EntityUid> ContainedEntities { get; }
[ViewVariables]
public abstract List<EntityUid> ExpectedEntities { get; }
@@ -41,7 +41,7 @@ namespace Robust.Shared.Containers
/// <inheritdoc />
[ViewVariables]
public IEntity Owner => Manager.Owner;
public EntityUid Owner => Manager.Owner;
/// <inheritdoc />
[ViewVariables(VVAccess.ReadWrite)]
@@ -55,7 +55,7 @@ namespace Robust.Shared.Containers
protected BaseContainer() { }
/// <inheritdoc />
public bool Insert(IEntity toinsert)
public bool Insert(EntityUid toinsert)
{
DebugTools.Assert(!Deleted);
@@ -85,7 +85,7 @@ namespace Robust.Shared.Containers
}
/// <inheritdoc />
public virtual bool CanInsert(IEntity toinsert)
public virtual bool CanInsert(EntityUid toinsert)
{
DebugTools.Assert(!Deleted);
@@ -104,7 +104,7 @@ namespace Robust.Shared.Containers
}
/// <inheritdoc />
public bool Remove(IEntity toremove)
public bool Remove(EntityUid toremove)
{
DebugTools.Assert(!Deleted);
DebugTools.AssertNotNull(Manager);
@@ -119,7 +119,7 @@ namespace Robust.Shared.Containers
}
/// <inheritdoc />
public void ForceRemove(IEntity toRemove)
public void ForceRemove(EntityUid toRemove)
{
DebugTools.Assert(!Deleted);
DebugTools.AssertNotNull(Manager);
@@ -130,14 +130,14 @@ namespace Robust.Shared.Containers
}
/// <inheritdoc />
public virtual bool CanRemove(IEntity toremove)
public virtual bool CanRemove(EntityUid toremove)
{
DebugTools.Assert(!Deleted);
return Contains(toremove);
}
/// <inheritdoc />
public abstract bool Contains(IEntity contained);
public abstract bool Contains(EntityUid contained);
/// <inheritdoc />
public virtual void Shutdown()
@@ -150,7 +150,7 @@ namespace Robust.Shared.Containers
/// Implement to store the reference in whatever form you want
/// </summary>
/// <param name="toinsert"></param>
protected virtual void InternalInsert(IEntity toinsert)
protected virtual void InternalInsert(EntityUid toinsert)
{
DebugTools.Assert(!Deleted);
@@ -163,15 +163,17 @@ namespace Robust.Shared.Containers
/// Implement to remove the reference you used to store the entity
/// </summary>
/// <param name="toremove"></param>
protected virtual void InternalRemove(IEntity toremove)
protected virtual void InternalRemove(EntityUid toremove)
{
DebugTools.Assert(!Deleted);
DebugTools.AssertNotNull(Manager);
DebugTools.AssertNotNull(toremove);
DebugTools.Assert(IoCManager.Resolve<IEntityManager>().EntityExists(toremove));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new EntRemovedFromContainerMessage(toremove, this));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new UpdateContainerOcclusionMessage(toremove));
var entMan = IoCManager.Resolve<IEntityManager>();
entMan.EventBus.RaiseLocalEvent(Owner, new EntRemovedFromContainerMessage(toremove, this));
entMan.EventBus.RaiseEvent(EventSource.Local, new UpdateContainerOcclusionMessage(toremove));
Manager.Dirty();
}
}

View File

@@ -9,6 +9,6 @@ namespace Robust.Shared.Containers
[PublicAPI]
public sealed class EntRemovedFromContainerMessage : ContainerModifiedMessage
{
public EntRemovedFromContainerMessage(IEntity entity, IContainer container) : base(entity, container) { }
public EntRemovedFromContainerMessage(EntityUid entity, IContainer container) : base(entity, container) { }
}
}

View File

@@ -32,7 +32,7 @@ namespace Robust.Shared.Containers
/// <summary>
/// Readonly collection of all the entities contained within this specific container
/// </summary>
IReadOnlyList<IEntity> ContainedEntities { get; }
IReadOnlyList<EntityUid> ContainedEntities { get; }
List<EntityUid> ExpectedEntities { get; }
@@ -64,7 +64,7 @@ namespace Robust.Shared.Containers
/// <summary>
/// The entity owning this container.
/// </summary>
IEntity Owner { get; }
EntityUid Owner { get; }
/// <summary>
/// Should the contents of this container be shown? False for closed containers like lockers, true for
@@ -77,7 +77,7 @@ namespace Robust.Shared.Containers
/// </summary>
/// <param name="toinsert">The entity to attempt to insert.</param>
/// <returns>True if the entity can be inserted, false otherwise.</returns>
bool CanInsert(IEntity toinsert);
bool CanInsert(EntityUid toinsert);
/// <summary>
/// Attempts to insert the entity into this container.
@@ -92,28 +92,28 @@ namespace Robust.Shared.Containers
/// Thrown if this container is a child of the entity,
/// which would cause infinite loops.
/// </exception>
bool Insert(IEntity toinsert);
bool Insert(EntityUid toinsert);
/// <summary>
/// Checks if the entity can be removed from this container.
/// </summary>
/// <param name="toremove">The entity to check.</param>
/// <returns>True if the entity can be removed, false otherwise.</returns>
bool CanRemove(IEntity toremove);
bool CanRemove(EntityUid toremove);
/// <summary>
/// Attempts to remove the entity from this container.
/// </summary>
/// <param name="toremove">The entity to attempt to remove.</param>
/// <returns>True if the entity was removed, false otherwise.</returns>
bool Remove(IEntity toremove);
bool Remove(EntityUid toremove);
/// <summary>
/// Forcefully removes an entity from the container. Normally you would want to use <see cref="Remove" />,
/// this function should be avoided.
/// </summary>
/// <param name="toRemove">The entity to attempt to remove.</param>
void ForceRemove(IEntity toRemove);
void ForceRemove(EntityUid toRemove);
/// <summary>
/// Checks if the entity is contained in this container.
@@ -121,7 +121,7 @@ namespace Robust.Shared.Containers
/// </summary>
/// <param name="contained">The entity to check.</param>
/// <returns>True if the entity is immediately contained in this container, false otherwise.</returns>
bool Contains(IEntity contained);
bool Contains(EntityUid contained);
/// <summary>
/// Clears the container and marks it as deleted.

View File

@@ -4,9 +4,9 @@ namespace Robust.Shared.Containers
{
public readonly struct UpdateContainerOcclusionMessage
{
public IEntity Entity { get; }
public EntityUid Entity { get; }
public UpdateContainerOcclusionMessage(IEntity entity)
public UpdateContainerOcclusionMessage(EntityUid entity)
{
Entity = entity;
}

View File

@@ -42,7 +42,7 @@ namespace Robust.Shared.GameObjects
/// <summary>
/// All entities currently stored in the manager.
/// </summary>
protected readonly Dictionary<EntityUid, MetaDataComponent> Entities = new();
protected readonly Dictionary<EntityUid, EntityUid> Entities = new();
private EntityEventBus _eventBus = null!;
@@ -146,19 +146,19 @@ namespace Robust.Shared.GameObjects
#region Entity Management
public IEntity CreateEntityUninitialized(string? prototypeName, EntityUid? euid)
public EntityUid CreateEntityUninitialized(string? prototypeName, EntityUid? euid)
{
return CreateEntity(prototypeName, euid);
}
/// <inheritdoc />
public virtual IEntity CreateEntityUninitialized(string? prototypeName)
public virtual EntityUid CreateEntityUninitialized(string? prototypeName)
{
return CreateEntity(prototypeName);
}
/// <inheritdoc />
public virtual IEntity CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates)
public virtual EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates)
{
var newEntity = CreateEntity(prototypeName);
@@ -171,7 +171,7 @@ namespace Robust.Shared.GameObjects
}
/// <inheritdoc />
public virtual IEntity CreateEntityUninitialized(string? prototypeName, MapCoordinates coordinates)
public virtual EntityUid CreateEntityUninitialized(string? prototypeName, MapCoordinates coordinates)
{
var newEntity = CreateEntity(prototypeName);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(newEntity).AttachParent(_mapManager.GetMapEntity(coordinates.MapId));
@@ -185,7 +185,7 @@ namespace Robust.Shared.GameObjects
}
/// <inheritdoc />
public virtual IEntity SpawnEntity(string? protoName, EntityCoordinates coordinates)
public virtual EntityUid SpawnEntity(string? protoName, EntityCoordinates coordinates)
{
if (!coordinates.IsValid(this))
throw new InvalidOperationException($"Tried to spawn entity {protoName} on invalid coordinates {coordinates}.");
@@ -196,7 +196,7 @@ namespace Robust.Shared.GameObjects
}
/// <inheritdoc />
public virtual IEntity SpawnEntity(string? protoName, MapCoordinates coordinates)
public virtual EntityUid SpawnEntity(string? protoName, MapCoordinates coordinates)
{
var entity = CreateEntityUninitialized(protoName, coordinates);
InitializeAndStartEntity(entity, coordinates.MapId);
@@ -208,7 +208,7 @@ namespace Robust.Shared.GameObjects
/// </summary>
/// <param name="uid"></param>
/// <returns>Entity or throws if the entity doesn't exist</returns>
public IEntity GetEntity(EntityUid uid)
public EntityUid GetEntity(EntityUid uid)
{
return Entities[uid];
}
@@ -219,7 +219,7 @@ namespace Robust.Shared.GameObjects
/// <param name="uid"></param>
/// <param name="entity">The requested entity or null if the entity couldn't be found.</param>
/// <returns>True if a value was returned, false otherwise.</returns>
public bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out IEntity? entity)
public bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out EntityUid? entity)
{
if (Entities.TryGetValue(uid, out var cEntity) && !((!IoCManager.Resolve<IEntityManager>().EntityExists(cEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(cEntity).EntityLifeStage) >= EntityLifeStage.Deleted))
{
@@ -237,7 +237,7 @@ namespace Robust.Shared.GameObjects
public int EntityCount => Entities.Count;
/// <inheritdoc />
public IEnumerable<IEntity> GetEntities() => Entities.Values;
public IEnumerable<EntityUid> GetEntities() => Entities.Values;
public IEnumerable<EntityUid> GetEntityUids() => Entities.Keys;
@@ -269,7 +269,7 @@ namespace Robust.Shared.GameObjects
/// Shuts-down and removes given Entity. This is also broadcast to all clients.
/// </summary>
/// <param name="e">Entity to remove</param>
public virtual void DeleteEntity(IEntity e)
public virtual void DeleteEntity(EntityUid e)
{
// Networking blindly spams entities at this function, they can already be
// deleted from being a child of a previously deleted entity
@@ -287,7 +287,7 @@ namespace Robust.Shared.GameObjects
RecursiveDeleteEntity(e);
}
private void RecursiveDeleteEntity(IEntity entity)
private void RecursiveDeleteEntity(EntityUid entity)
{
if((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) //TODO: Why was this still a child if it was already deleted?
return;
@@ -328,25 +328,12 @@ namespace Robust.Shared.GameObjects
Entities.Remove(entity);
}
public void QueueDeleteEntity(IEntity entity)
{
QueueDeleteEntity((EntityUid) entity);
}
public void QueueDeleteEntity(EntityUid uid)
{
if(QueuedDeletionsSet.Add(uid))
QueuedDeletions.Enqueue(uid);
}
public void DeleteEntity(EntityUid uid)
{
if (TryGetEntity(uid, out var entity))
{
DeleteEntity(entity);
}
}
public bool EntityExists(EntityUid uid)
{
return _entTraitDict[typeof(MetaDataComponent)].ContainsKey(uid);
@@ -366,7 +353,7 @@ namespace Robust.Shared.GameObjects
/// <summary>
/// Allocates an entity and stores it but does not load components or do initialization.
/// </summary>
private protected IEntity AllocEntity(string? prototypeName, EntityUid? uid = null)
private protected EntityUid AllocEntity(string? prototypeName, EntityUid? uid = null)
{
EntityPrototype? prototype = null;
if (!string.IsNullOrWhiteSpace(prototypeName))
@@ -385,7 +372,7 @@ namespace Robust.Shared.GameObjects
/// <summary>
/// Allocates an entity and stores it but does not load components or do initialization.
/// </summary>
private protected IEntity AllocEntity(EntityUid? uid = null)
private protected EntityUid AllocEntity(EntityUid? uid = null)
{
if (uid == null)
{
@@ -397,31 +384,26 @@ namespace Robust.Shared.GameObjects
throw new InvalidOperationException($"UID already taken: {uid}");
}
var entity = new IEntity(uid.Value);
// we want this called before adding components
EntityAdded?.Invoke(this, entity);
// We do this after the event, so if the event throws we have not committed
Entities[entity] = entity;
EntityAdded?.Invoke(this, uid.Value);
// Create the MetaDataComponent and set it directly on the Entity to avoid a stack overflow in DEBUG.
var metadata = new MetaDataComponent() { Owner = entity };
var metadata = new MetaDataComponent() { Owner = uid.Value };
// add the required MetaDataComponent directly.
AddComponentInternal(uid.Value, metadata);
// allocate the required TransformComponent
AddComponent<TransformComponent>(entity);
AddComponent<TransformComponent>(uid.Value);
return entity;
return uid.Value;
}
/// <summary>
/// Allocates an entity and loads components but does not do initialization.
/// </summary>
private protected virtual IEntity CreateEntity(string? prototypeName, EntityUid? uid = null)
private protected virtual EntityUid CreateEntity(string? prototypeName, EntityUid? uid = null)
{
if (prototypeName == null)
return AllocEntity(uid);
@@ -441,12 +423,12 @@ namespace Robust.Shared.GameObjects
}
}
private protected void LoadEntity(IEntity entity, IEntityLoadContext? context)
private protected void LoadEntity(EntityUid entity, IEntityLoadContext? context)
{
EntityPrototype.LoadEntity(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityPrototype, entity, ComponentFactory, context);
}
private void InitializeAndStartEntity(IEntity entity, MapId mapId)
private void InitializeAndStartEntity(EntityUid entity, MapId mapId)
{
try
{
@@ -464,13 +446,13 @@ namespace Robust.Shared.GameObjects
}
}
protected void InitializeEntity(IEntity entity)
protected void InitializeEntity(EntityUid entity)
{
InitializeComponents(entity);
EntityInitialized?.Invoke(this, entity);
}
protected void StartEntity(IEntity entity)
protected void StartEntity(EntityUid entity)
{
StartComponents(entity);
EntityStarted?.Invoke(this, entity);

View File

@@ -2,9 +2,9 @@ namespace Robust.Shared.GameObjects
{
public sealed class EntityDeletedMessage : EntityEventArgs
{
public IEntity Entity { get; }
public EntityDeletedMessage(IEntity entity)
public EntityUid Entity { get; }
public EntityDeletedMessage(EntityUid entity)
{
Entity = entity;
}

View File

@@ -34,14 +34,6 @@ namespace Robust.Shared.GameObjects
/// </summary>
void StartComponents(EntityUid uid);
/// <summary>
/// Adds a Component type to an entity. If the entity is already Initialized, the component will
/// automatically be Initialized and Started.
/// </summary>
/// <typeparam name="T">Concrete component type to add.</typeparam>
/// <returns>The newly added component.</returns>
T AddComponent<T>(IEntity entity) where T : Component, new();
/// <summary>
/// Adds a Component type to an entity. If the entity is already Initialized, the component will
/// automatically be Initialized and Started.
@@ -50,15 +42,6 @@ namespace Robust.Shared.GameObjects
/// <returns>The newly added component.</returns>
T AddComponent<T>(EntityUid uid) where T : Component, new();
/// <summary>
/// Adds a Component to an entity. If the entity is already Initialized, the component will
/// automatically be Initialized and Started.
/// </summary>
/// <param name="entity">Entity being modified.</param>
/// <param name="component">Component to add.</param>
/// <param name="overwrite">Should it overwrite existing components?</param>
void AddComponent<T>(IEntity entity, T component, bool overwrite = false) where T : Component;
/// <summary>
/// Adds a Component to an entity. If the entity is already Initialized, the component will
/// automatically be Initialized and Started.
@@ -136,14 +119,6 @@ namespace Robust.Shared.GameObjects
/// <returns>True if the entity has a component with the given network ID, otherwise false.</returns>
bool HasComponent(EntityUid uid, ushort netId);
/// <summary>
/// This method will always return a component for a certain entity, adding it if it's not there already.
/// </summary>
/// <param name="entity">Entity to modify.</param>
/// <typeparam name="T">Component to add.</typeparam>
/// <returns>The component in question</returns>
T EnsureComponent<T>(IEntity entity) where T : Component, new();
/// <summary>
/// This method will always return a component for a certain entity, adding it if it's not there already.
/// </summary>

View File

@@ -46,13 +46,13 @@ namespace Robust.Shared.GameObjects
event EventHandler<EntityUid>? EntityStarted;
event EventHandler<EntityUid>? EntityDeleted;
IEntity CreateEntityUninitialized(string? prototypeName, EntityUid? euid);
EntityUid CreateEntityUninitialized(string? prototypeName, EntityUid? euid);
IEntity CreateEntityUninitialized(string? prototypeName);
EntityUid CreateEntityUninitialized(string? prototypeName);
IEntity CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates);
EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates);
IEntity CreateEntityUninitialized(string? prototypeName, MapCoordinates coordinates);
EntityUid CreateEntityUninitialized(string? prototypeName, MapCoordinates coordinates);
/// <summary>
/// Spawns an initialized entity at the default location, using the given prototype.
@@ -60,7 +60,7 @@ namespace Robust.Shared.GameObjects
/// <param name="protoName">The prototype to clone. If this is null, the entity won't have a prototype.</param>
/// <param name="coordinates"></param>
/// <returns>Newly created entity.</returns>
IEntity SpawnEntity(string? protoName, EntityCoordinates coordinates);
EntityUid SpawnEntity(string? protoName, EntityCoordinates coordinates);
/// <summary>
/// Spawns an entity at a specific position
@@ -68,14 +68,14 @@ namespace Robust.Shared.GameObjects
/// <param name="protoName"></param>
/// <param name="coordinates"></param>
/// <returns></returns>
IEntity SpawnEntity(string? protoName, MapCoordinates coordinates);
EntityUid SpawnEntity(string? protoName, MapCoordinates coordinates);
/// <summary>
/// Returns an entity by id
/// </summary>
/// <param name="uid"></param>
/// <returns>Entity or throws if entity id doesn't exist</returns>
IEntity GetEntity(EntityUid uid);
EntityUid GetEntity(EntityUid uid);
/// <summary>
/// Attempt to get an entity, returning whether or not an entity was gotten.
@@ -83,7 +83,7 @@ namespace Robust.Shared.GameObjects
/// <param name="uid"></param>
/// <param name="entity">The requested entity or null if the entity couldn't be found.</param>
/// <returns>True if a value was returned, false otherwise.</returns>
bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out IEntity? entity);
bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out EntityUid? entity);
/// <summary>
/// How many entities are currently active.
@@ -94,7 +94,7 @@ namespace Robust.Shared.GameObjects
/// Returns all entities
/// </summary>
/// <returns></returns>
IEnumerable<IEntity> GetEntities();
IEnumerable<EntityUid> GetEntities();
/// <summary>
/// Returns all entities by uid
@@ -104,16 +104,8 @@ namespace Robust.Shared.GameObjects
public void DirtyEntity(EntityUid uid);
public void QueueDeleteEntity(IEntity entity);
public void QueueDeleteEntity(EntityUid uid);
/// <summary>
/// Shuts-down and removes given <see cref="Robust.Shared.GameObjects.EntityUid"/>. This is also broadcast to all clients.
/// </summary>
/// <param name="e">Entity to remove</param>
void DeleteEntity(IEntity e);
/// <summary>
/// Shuts-down and removes the entity with the given <see cref="Robust.Shared.GameObjects.EntityUid"/>. This is also broadcast to all clients.
/// </summary>

View File

@@ -35,7 +35,7 @@ namespace Robust.Shared.GameObjects
/// <param name="component">Component that sent the message.</param>
/// <param name="message">Message to send.</param>
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
void SendComponentNetworkMessage(INetChannel? channel, IEntity entity, IComponent component,
void SendComponentNetworkMessage(INetChannel? channel, EntityUid entity, IComponent component,
ComponentMessage message);
/// <summary>