mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Susser Todd: Robust.Server, Error Pass 2
This commit is contained in:
@@ -56,11 +56,10 @@ namespace Robust.Server.Bql
|
||||
|
||||
if (shell.Player is IPlayerSession player)
|
||||
{
|
||||
if (player.AttachedEntity != null)
|
||||
var ptransform = player.AttachedEntityTransform;
|
||||
if (ptransform != null)
|
||||
{
|
||||
var puid= player.AttachedEntity;
|
||||
var ptransform = entMan.GetComponent<TransformComponent>(puid);
|
||||
ruleString = ruleString.Replace("$PID", ent.ToString());
|
||||
ruleString = ruleString.Replace("$PID", ptransform.Owner.ToString());
|
||||
ruleString = ruleString.Replace("$PWX",
|
||||
ptransform.WorldPosition.X.ToString(CultureInfo.InvariantCulture));
|
||||
ruleString = ruleString.Replace("$PWY",
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Robust.Server.Console.Commands
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entityManager.TryGetEntity(uid, out var entity))
|
||||
if (!entityManager.EntityExists(uid))
|
||||
{
|
||||
shell.WriteLine($"No entity found with id {uid}.");
|
||||
return;
|
||||
@@ -46,17 +46,17 @@ namespace Robust.Server.Console.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent(entity, registration.Type))
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent(uid, registration.Type))
|
||||
{
|
||||
shell.WriteLine($"Entity {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName} already has a {componentName} component.");
|
||||
shell.WriteLine($"Entity {entManager.GetComponent<MetaDataComponent>(uid).EntityName} already has a {componentName} component.");
|
||||
}
|
||||
|
||||
var component = (Component) compFactory.GetComponent(registration.Type);
|
||||
|
||||
component.Owner = entity;
|
||||
entManager.AddComponent(entity, component);
|
||||
component.Owner = uid;
|
||||
entManager.AddComponent(uid, component);
|
||||
|
||||
shell.WriteLine($"Added {componentName} component to entity {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName}.");
|
||||
shell.WriteLine($"Added {componentName} component to entity {entManager.GetComponent<MetaDataComponent>(uid).EntityName}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,11 +232,12 @@ namespace Robust.Server.Console.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
if (player?.AttachedEntity == null)
|
||||
var pt = player?.AttachedEntityTransform;
|
||||
if (pt == null)
|
||||
return;
|
||||
|
||||
var pos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).Coordinates;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var pos = pt.Coordinates;
|
||||
|
||||
shell.WriteLine(
|
||||
$"MapID:{pos.GetMapId(entityManager)} GridID:{pos.GetGridId(entityManager)} X:{pos.X:N2} Y:{pos.Y:N2}");
|
||||
|
||||
@@ -21,7 +21,11 @@ namespace Robust.Server.Console.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
if (player?.Status != SessionStatus.InGame || player.AttachedEntity == null)
|
||||
if (player?.Status != SessionStatus.InGame)
|
||||
return;
|
||||
|
||||
var transform = player.AttachedEntityTransform;
|
||||
if (transform == null)
|
||||
return;
|
||||
|
||||
if (args.Length < 2 || !float.TryParse(args[0], out var posX) || !float.TryParse(args[1], out var posY))
|
||||
@@ -33,11 +37,6 @@ namespace Robust.Server.Console.Commands
|
||||
var mapMgr = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
var position = new Vector2(posX, posY);
|
||||
IEntity? tempQualifier = player.AttachedEntity;
|
||||
var transform = (tempQualifier != null ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier) : null);
|
||||
|
||||
if(transform == null)
|
||||
return;
|
||||
|
||||
transform.AttachToGridOrMap();
|
||||
|
||||
@@ -61,7 +60,7 @@ namespace Robust.Server.Console.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
var mapEnt = mapMgr.GetMapEntity(mapId);
|
||||
var mapEnt = mapMgr.GetMapEntityIdOrThrow(mapId);
|
||||
transform.WorldPosition = position;
|
||||
transform.AttachParent(mapEnt);
|
||||
}
|
||||
@@ -79,7 +78,7 @@ namespace Robust.Server.Console.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
if (player?.Status != SessionStatus.InGame || player.AttachedEntity == null)
|
||||
if (player?.Status != SessionStatus.InGame)
|
||||
return;
|
||||
|
||||
if (args.Length == 0)
|
||||
@@ -88,6 +87,13 @@ namespace Robust.Server.Console.Commands
|
||||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
var playerAE = player.AttachedEntityTransform;
|
||||
if (playerAE == null)
|
||||
{
|
||||
shell.WriteError("You don't have an entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var players = IoCManager.Resolve<IPlayerManager>();
|
||||
|
||||
var username = args[0];
|
||||
@@ -98,13 +104,14 @@ namespace Robust.Server.Console.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerSession.AttachedEntity == null)
|
||||
var targetAE = playerSession.AttachedEntityTransform;
|
||||
if (targetAE == null)
|
||||
{
|
||||
shell.WriteError(username + " does not have an entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(playerSession.AttachedEntity).Coordinates;
|
||||
playerAE.Coordinates = targetAE.Coordinates;
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
@@ -117,12 +124,15 @@ namespace Robust.Server.Console.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetSession.AttachedEntity == null)
|
||||
var targetAE = targetSession.AttachedEntityTransform;
|
||||
if (targetAE == null)
|
||||
{
|
||||
shell.WriteError(target + " does not have an entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var targetCoords = targetAE.Coordinates;
|
||||
|
||||
foreach (var username in args)
|
||||
{
|
||||
if (username == target)
|
||||
@@ -134,13 +144,14 @@ namespace Robust.Server.Console.Commands
|
||||
continue;
|
||||
}
|
||||
|
||||
if (playerSession.AttachedEntity == null)
|
||||
var victimAE = playerSession.AttachedEntityTransform;
|
||||
if (victimAE == null)
|
||||
{
|
||||
shell.WriteError(username + " does not have an entity.");
|
||||
continue;
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(playerSession.AttachedEntity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(targetSession.AttachedEntity).Coordinates;
|
||||
victimAE.Coordinates = targetCoords;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Robust.Server.Console.Commands
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entityManager.TryGetEntity(uid, out var entity))
|
||||
if (!entityManager.EntityExists(uid))
|
||||
{
|
||||
shell.WriteLine($"No entity found with id {uid}.");
|
||||
return;
|
||||
@@ -46,15 +46,15 @@ namespace Robust.Server.Console.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent(entity, registration.Type))
|
||||
if (!entManager.HasComponent(uid, registration.Type))
|
||||
{
|
||||
shell.WriteLine($"No {componentName} component found on entity {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName}.");
|
||||
shell.WriteLine($"No {componentName} component found on entity {entManager.GetComponent<MetaDataComponent>(uid).EntityName}.");
|
||||
return;
|
||||
}
|
||||
|
||||
entManager.RemoveComponent(uid, registration.Type);
|
||||
|
||||
shell.WriteLine($"Removed {componentName} component from entity {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName}.");
|
||||
shell.WriteLine($"Removed {componentName} component from entity {entManager.GetComponent<MetaDataComponent>(uid).EntityName}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,19 +22,21 @@ namespace Robust.Server.Console.Commands
|
||||
shell.WriteError("Incorrect number of arguments. " + Help);
|
||||
}
|
||||
|
||||
if (args.Length == 1 && player != null && player.AttachedEntity != null)
|
||||
var pAE = player == null ? EntityUid.Invalid : player.AttachedEntityUidOrInvalid;
|
||||
|
||||
if (args.Length == 1 && player != null && pAE != EntityUid.Invalid)
|
||||
{
|
||||
ent.SpawnEntity(args[0], ent.GetComponent<TransformComponent>(player.AttachedEntity).Coordinates);
|
||||
ent.SpawnEntity(args[0], ent.GetComponent<TransformComponent>(pAE).Coordinates);
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
var uid = ent.GetEntity(EntityUid.Parse(args[1]));
|
||||
ent.SpawnEntity(args[0], ent.GetComponent<TransformComponent>(uid).Coordinates);
|
||||
}
|
||||
else if (player != null && player.AttachedEntity != null)
|
||||
else if (player != null && pAE != EntityUid.Invalid)
|
||||
{
|
||||
var coords = new MapCoordinates(float.Parse(args[1]),
|
||||
float.Parse(args[2]), ent.GetComponent<TransformComponent>(player.AttachedEntity).MapID);
|
||||
float.Parse(args[2]), ent.GetComponent<TransformComponent>(pAE).MapID);
|
||||
ent.SpawnEntity(args[0], coords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Robust.Server.Console.Commands
|
||||
if (mapId == MapId.Nullspace) return;
|
||||
var pauseManager = IoCManager.Resolve<IPauseManager>();
|
||||
pauseManager.SetMapPaused(mapId, false);
|
||||
var mapUid = IoCManager.Resolve<IMapManager>().GetMapEntity(mapId);
|
||||
var mapUid = IoCManager.Resolve<IMapManager>().GetMapEntityIdOrThrow(mapId);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<SharedPhysicsMapComponent>(mapUid).Gravity = new Vector2(0, -9.8f);
|
||||
|
||||
return;
|
||||
|
||||
@@ -57,9 +57,9 @@ namespace Robust.Server.GameObjects
|
||||
|
||||
private void HandleGridEmpty(EntityUid uid, MapGridComponent component, EmptyGridEvent args)
|
||||
{
|
||||
if (!_deleteEmptyGrids ||
|
||||
!EntityManager.TryGetEntity(uid, out var gridEnt) ||
|
||||
(!IoCManager.Resolve<IEntityManager>().EntityExists(gridEnt) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(gridEnt).EntityLifeStage) >= EntityLifeStage.Terminating) return;
|
||||
if (!_deleteEmptyGrids) return;
|
||||
if (!EntityManager.EntityExists(uid)) return;
|
||||
if (EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating) return;
|
||||
|
||||
MapManager.DeleteGrid(args.GridId);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace Robust.Server.GameObjects
|
||||
{
|
||||
var guid = ev.EntityUid;
|
||||
|
||||
if (!EntityManager.TryGetEntity(guid, out var gridEntity)) return;
|
||||
var collideComp = gridEntity.EnsureComponent<PhysicsComponent>();
|
||||
if (!EntityManager.EntityExists(guid)) return;
|
||||
var collideComp = guid.EnsureComponent<PhysicsComponent>();
|
||||
collideComp.CanCollide = true;
|
||||
collideComp.BodyType = BodyType.Static;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Robust.Server.GameObjects
|
||||
protected override void HandleMapCreated(object? sender, MapEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Map == MapId.Nullspace) return;
|
||||
var mapUid = MapManager.GetMapEntity(eventArgs.Map);
|
||||
var mapUid = MapManager.GetMapEntityIdOrThrow(eventArgs.Map);
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<PhysicsMapComponent>(mapUid);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,21 +88,21 @@ namespace Robust.Server.GameObjects
|
||||
|
||||
foreach (var session in _sessionCache)
|
||||
{
|
||||
var attachedEntity = session.AttachedEntity;
|
||||
var attachedEntityTransform = session.AttachedEntityTransform;
|
||||
|
||||
// The component manages the set of sessions, so this invalid session should be removed soon.
|
||||
if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity))
|
||||
if (attachedEntityTransform == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uiMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).MapID)
|
||||
if (uiMap != attachedEntityTransform.MapID)
|
||||
{
|
||||
ui.Close(session);
|
||||
continue;
|
||||
}
|
||||
|
||||
var distanceSquared = (uiPos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).WorldPosition).LengthSquared;
|
||||
var distanceSquared = (uiPos - attachedEntityTransform.WorldPosition).LengthSquared;
|
||||
if (distanceSquared > MaxWindowRangeSquared)
|
||||
{
|
||||
ui.Close(session);
|
||||
|
||||
@@ -473,24 +473,34 @@ internal partial class PVSSystem : EntitySystem
|
||||
|
||||
foreach (var uid in add)
|
||||
{
|
||||
if (!seenEnts.Add(uid) || !EntityManager.TryGetEntity(uid, out var entity) || (!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
|
||||
if (!seenEnts.Add(uid)) continue;
|
||||
if (!EntityManager.EntityExists(uid)) continue;
|
||||
|
||||
DebugTools.Assert((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Initialized);
|
||||
var md = EntityManager.GetComponent<MetaDataComponent>(uid);
|
||||
var ls = md.EntityLifeStage;
|
||||
if (ls >= EntityLifeStage.Deleted) continue;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLastModifiedTick >= fromTick)
|
||||
stateEntities.Add(GetEntityState(player, entity, GameTick.Zero));
|
||||
DebugTools.Assert(ls >= EntityLifeStage.Initialized);
|
||||
|
||||
if (md.EntityLastModifiedTick >= fromTick)
|
||||
stateEntities.Add(GetEntityState(player, uid, GameTick.Zero));
|
||||
}
|
||||
|
||||
foreach (var uid in dirty)
|
||||
{
|
||||
DebugTools.Assert(!add.Contains(uid));
|
||||
|
||||
if (!seenEnts.Add(uid) || !EntityManager.TryGetEntity(uid, out var entity) || (!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
|
||||
if (!seenEnts.Add(uid)) continue;
|
||||
if (!EntityManager.EntityExists(uid)) continue;
|
||||
|
||||
DebugTools.Assert((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Initialized);
|
||||
var md = EntityManager.GetComponent<MetaDataComponent>(uid);
|
||||
var ls = md.EntityLifeStage;
|
||||
if (ls >= EntityLifeStage.Deleted) continue;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLastModifiedTick >= fromTick)
|
||||
stateEntities.Add(GetEntityState(player, entity, fromTick));
|
||||
DebugTools.Assert(ls >= EntityLifeStage.Initialized);
|
||||
|
||||
if (md.EntityLastModifiedTick >= fromTick)
|
||||
stateEntities.Add(GetEntityState(player, uid, fromTick));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,14 +513,14 @@ internal partial class PVSSystem : EntitySystem
|
||||
|
||||
foreach (var entity in EntityManager.GetEntities())
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!EntityManager.EntityExists(entity)) continue;
|
||||
var md = EntityManager.GetComponent<MetaDataComponent>(entity);
|
||||
var ls = md.EntityLifeStage;
|
||||
if (ls >= EntityLifeStage.Deleted) continue;
|
||||
|
||||
DebugTools.Assert((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Initialized);
|
||||
DebugTools.Assert(ls >= EntityLifeStage.Initialized);
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLastModifiedTick >= fromTick)
|
||||
if (md.EntityLastModifiedTick >= fromTick)
|
||||
stateEntities.Add(GetEntityState(player, entity, fromTick));
|
||||
}
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace Robust.Server.Maps
|
||||
{
|
||||
var gridInternal = (IMapGridInternal) grid;
|
||||
var body = entManager.EnsureComponent<PhysicsComponent>(grid.GridEntityId);
|
||||
var mapUid = _mapManager.GetMapEntity(grid.ParentMapId);
|
||||
var mapUid = _mapManager.GetMapEntityIdOrThrow(grid.ParentMapId);
|
||||
body.Broadphase = IoCManager.Resolve<IEntityManager>().GetComponent<BroadphaseComponent>(mapUid);
|
||||
var fixtures = entManager.EnsureComponent<FixturesComponent>(grid.GridEntityId);
|
||||
gridFixtures.ProcessGrid(gridInternal);
|
||||
@@ -485,17 +485,17 @@ namespace Robust.Server.Maps
|
||||
|
||||
private void AttachMapEntities()
|
||||
{
|
||||
var mapEntity = _mapManager.GetMapEntity(TargetMap);
|
||||
var mapEntity = _mapManager.GetMapEntityIdOrThrow(TargetMap);
|
||||
|
||||
foreach (var grid in Grids)
|
||||
{
|
||||
var entity = _serverEntityManager.GetEntity(grid.GridEntityId);
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Parent != null)
|
||||
var transform = _serverEntityManager.GetComponent<TransformComponent>(grid.GridEntityId);
|
||||
if (transform.Parent != null)
|
||||
continue;
|
||||
|
||||
var mapOffset = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).LocalPosition;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).AttachParent(mapEntity);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition = mapOffset;
|
||||
var mapOffset = transform.LocalPosition;
|
||||
transform.AttachParent(mapEntity);
|
||||
transform.WorldPosition = mapOffset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,7 +810,8 @@ namespace Robust.Server.Maps
|
||||
CurrentWritingComponent = component.Name;
|
||||
var compMapping = serializationManager.WriteValueAs<MappingDataNode>(component.GetType(), component, context: this);
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityPrototype != null && prototypeCompCache[IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityPrototype.ID].TryGetValue(component.Name, out var protMapping))
|
||||
var md = _serverEntityManager.GetComponent<MetaDataComponent>(entity);
|
||||
if (md.EntityPrototype != null && prototypeCompCache[md.EntityPrototype.ID].TryGetValue(component.Name, out var protMapping))
|
||||
{
|
||||
compMapping = compMapping.Except(protMapping);
|
||||
if(compMapping == null) continue;
|
||||
@@ -981,14 +982,14 @@ namespace Robust.Server.Maps
|
||||
{
|
||||
var val = int.Parse(node.Value);
|
||||
|
||||
if (val >= Entities.Count || !UidEntityMap.ContainsKey(val) || !Entities.TryFirstOrDefault(e => e == UidEntityMap[val], out var entity))
|
||||
if (val >= Entities.Count || !UidEntityMap.ContainsKey(val) || !Entities.TryFirstOrNull(e => e == UidEntityMap[val], out var entity))
|
||||
{
|
||||
Logger.ErrorS("map", "Error in map file: found local entity UID '{0}' which does not exist.", val);
|
||||
return null!;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new DeserializedValue<EntityUid>(entity);
|
||||
return new DeserializedValue<EntityUid>(entity!.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Robust.Server.Placement
|
||||
var dirRcv = msg.DirRcv;
|
||||
|
||||
var session = _playerManager.GetSessionByChannel(msg.MsgChannel);
|
||||
var plyEntity = session.AttachedEntity;
|
||||
var plyEntity = session.AttachedEntityTransform;
|
||||
|
||||
// Don't have an entity, don't get to place.
|
||||
if (plyEntity == null)
|
||||
@@ -201,15 +201,15 @@ namespace Robust.Server.Placement
|
||||
private void HandleEntRemoveReq(EntityUid entityUid)
|
||||
{
|
||||
//TODO: Some form of admin check
|
||||
if (_entityManager.TryGetEntity(entityUid, out var entity))
|
||||
_entityManager.DeleteEntity(entity);
|
||||
if (_entityManager.EntityExists(entityUid))
|
||||
_entityManager.DeleteEntity(entityUid);
|
||||
}
|
||||
|
||||
private void HandleRectRemoveReq(MsgPlacement msg)
|
||||
{
|
||||
EntityCoordinates start = msg.EntityCoordinates;
|
||||
Vector2 rectSize = msg.RectSize;
|
||||
foreach (EntityUid entity in IoCManager.Resolve<EntityUidLookup>().GetEntitiesIntersecting(start.GetMapId(_entityManager),
|
||||
foreach (EntityUid entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesIntersecting(start.GetMapId(_entityManager),
|
||||
new Box2(start.Position, start.Position + rectSize)))
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve<IEntityManager>().HasComponent<IMapGridComponent>(entity) || IoCManager.Resolve<IEntityManager>().HasComponent<ActorComponent>(entity))
|
||||
|
||||
@@ -4,6 +4,7 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Robust.Server.Player
|
||||
{
|
||||
@@ -67,5 +68,15 @@ namespace Robust.Server.Player
|
||||
/// Do NOT use this outside of <see cref="ViewSubscriberSystem"/>.
|
||||
/// </summary>
|
||||
internal void RemoveViewSubscription(EntityUid eye);
|
||||
|
||||
/// <summary>
|
||||
/// Porting convenience
|
||||
/// </summary>
|
||||
EntityUid AttachedEntityUidOrInvalid { get => AttachedEntityUid ?? EntityUid.Invalid; }
|
||||
|
||||
/// <summary>
|
||||
/// Porting convenience for admin commands which use such logic as "at the player's feet", etc: the transform component of the attached entity.
|
||||
/// </summary>
|
||||
TransformComponent? AttachedEntityTransform { get => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(AttachedEntityUidOrInvalid); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,12 +140,12 @@ namespace Robust.Server.Player
|
||||
return;
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
if (AttachedEntity!.Deleted)
|
||||
if (!IoCManager.Resolve<IEntityManager>().EntityExists(AttachedEntityUid!.Value))
|
||||
{
|
||||
Logger.Warning($"Player \"{this}\" was attached to an entity that was deleted. THIS SHOULD NEVER HAPPEN, BUT DOES.");
|
||||
// We can't contact ActorSystem because trying to fire an entity event would crash.
|
||||
// Work around it.
|
||||
AttachedEntity = null;
|
||||
AttachedEntityUid = null;
|
||||
UpdatePlayerState();
|
||||
return;
|
||||
}
|
||||
@@ -200,8 +200,7 @@ namespace Robust.Server.Player
|
||||
/// <inheritdoc />
|
||||
void IPlayerSession.SetAttachedEntity(EntityUid? entity)
|
||||
{
|
||||
// TODO: Use EntityUid for this.
|
||||
AttachedEntity = entity;
|
||||
AttachedEntityUid = entity;
|
||||
UpdatePlayerState();
|
||||
}
|
||||
|
||||
@@ -229,10 +228,7 @@ namespace Robust.Server.Player
|
||||
{
|
||||
PlayerState.Status = Status;
|
||||
PlayerState.Name = Name;
|
||||
if (AttachedEntity == null)
|
||||
PlayerState.ControlledEntity = null;
|
||||
else
|
||||
PlayerState.ControlledEntity = AttachedEntity;
|
||||
PlayerState.ControlledEntity = AttachedEntityUid;
|
||||
|
||||
_playerManager.Dirty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user