mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 06:42:25 +02:00
Goes in-game now
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Robust.Client.Player
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public EntityUid AttachedEntity { get; set; }
|
||||
public EntityUid? AttachedEntity { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public NetUserId UserId { get; }
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Robust.Server.GameObjects
|
||||
public bool Detach(IPlayerSession player)
|
||||
{
|
||||
var uid = player.AttachedEntity;
|
||||
return uid == default || Detach(uid);
|
||||
return uid == null || Detach(uid.Value);
|
||||
}
|
||||
|
||||
private void OnActorShutdown(EntityUid entity, ActorComponent component, ComponentShutdown args)
|
||||
|
||||
@@ -579,8 +579,8 @@ internal partial class PVSSystem : EntitySystem
|
||||
if (session.Status != SessionStatus.InGame)
|
||||
return viewers;
|
||||
|
||||
if (session.AttachedEntity != EntityUid.Invalid)
|
||||
viewers.Add(session.AttachedEntity);
|
||||
if (session.AttachedEntity != null)
|
||||
viewers.Add(session.AttachedEntity.Value);
|
||||
|
||||
// This is awful, but we're not gonna add the list of view subscriptions to common session.
|
||||
if (session is IPlayerSession playerSession)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Robust.Server.Player
|
||||
[ViewVariables] public INetChannel ConnectedClient { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables] public EntityUid AttachedEntity { get; set; }
|
||||
[ViewVariables] public EntityUid? AttachedEntity { get; set; }
|
||||
|
||||
private SessionStatus _status = SessionStatus.Connecting;
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Robust.Server.Player
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntity))
|
||||
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntity.Value))
|
||||
{
|
||||
Logger.Warning($"Couldn't detach player \"{this}\" from entity \"{AttachedEntity}\"! Is it missing an ActorComponent?");
|
||||
}
|
||||
@@ -177,9 +177,9 @@ namespace Robust.Server.Player
|
||||
|
||||
private void SetAttachedEntityName()
|
||||
{
|
||||
if (Name != null && AttachedEntity != default)
|
||||
if (Name != null && AttachedEntity != null)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(AttachedEntity).EntityName = Name;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(AttachedEntity.Value).EntityName = Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace Robust.Shared.Containers
|
||||
public static bool IsInContainer(this EntityUid entity)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!((!entMan.EntityExists(entity) ? EntityLifeStage.Deleted : entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
DebugTools.Assert(entMan.EntityExists(entity));
|
||||
|
||||
// Notice the recursion starts at the Owner of the passed in entity, this
|
||||
// allows containers inside containers (toolboxes in lockers).
|
||||
@@ -46,8 +45,7 @@ namespace Robust.Shared.Containers
|
||||
public static bool TryGetContainerMan(this EntityUid entity, [NotNullWhen(true)] out IContainerManager? manager)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!((!entMan.EntityExists(entity) ? EntityLifeStage.Deleted : entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
DebugTools.Assert(entMan.EntityExists(entity));
|
||||
|
||||
var parentTransform = entMan.GetComponent<TransformComponent>(entity).Parent;
|
||||
if (parentTransform != null && TryGetManagerComp(parentTransform.Owner, out manager) && manager.ContainsEntity(entity))
|
||||
@@ -66,8 +64,7 @@ namespace Robust.Shared.Containers
|
||||
public static bool TryGetContainer(this EntityUid entity, [NotNullWhen(true)] out IContainer? container)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!((!entMan.EntityExists(entity) ? EntityLifeStage.Deleted : entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
DebugTools.Assert(entMan.EntityExists(entity));
|
||||
|
||||
if (TryGetContainerMan(entity, out var manager))
|
||||
return manager.TryGetContainer(entity, out container);
|
||||
@@ -86,8 +83,7 @@ namespace Robust.Shared.Containers
|
||||
public static bool TryRemoveFromContainer(this EntityUid entity, bool force, out bool wasInContainer)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!((!entMan.EntityExists(entity) ? EntityLifeStage.Deleted : entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
DebugTools.Assert(entMan.EntityExists(entity));
|
||||
|
||||
if (TryGetContainer(entity, out var container))
|
||||
{
|
||||
@@ -175,8 +171,7 @@ namespace Robust.Shared.Containers
|
||||
private static bool TryGetManagerComp(this EntityUid entity, [NotNullWhen(true)] out IContainerManager? manager)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!((!entMan.EntityExists(entity) ? EntityLifeStage.Deleted : entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
DebugTools.Assert(entMan.EntityExists(entity));
|
||||
|
||||
if (entMan.TryGetComponent(entity, out manager))
|
||||
return true;
|
||||
@@ -190,9 +185,6 @@ namespace Robust.Shared.Containers
|
||||
|
||||
public static bool IsInSameOrNoContainer(this EntityUid user, EntityUid other)
|
||||
{
|
||||
DebugTools.AssertNotNull(user);
|
||||
DebugTools.AssertNotNull(other);
|
||||
|
||||
var isUserContained = TryGetContainer(user, out var userContainer);
|
||||
var isOtherContained = TryGetContainer(other, out var otherContainer);
|
||||
|
||||
@@ -208,9 +200,6 @@ namespace Robust.Shared.Containers
|
||||
|
||||
public static bool IsInSameOrParentContainer(this EntityUid user, EntityUid other)
|
||||
{
|
||||
DebugTools.AssertNotNull(user);
|
||||
DebugTools.AssertNotNull(other);
|
||||
|
||||
var isUserContained = TryGetContainer(user, out var userContainer);
|
||||
var isOtherContained = TryGetContainer(other, out var otherContainer);
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace Robust.Shared.Player
|
||||
{
|
||||
return AddWhere(session =>
|
||||
session.AttachedEntity != null &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntity).MapPosition, range), playerMan);
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntity.Value).MapPosition, range), playerMan);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,7 +165,7 @@ namespace Robust.Shared.Player
|
||||
public Filter RemoveByVisibility(uint flag)
|
||||
{
|
||||
return RemoveWhere(session =>
|
||||
session.AttachedEntity == default
|
||||
session.AttachedEntity == null
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(session.AttachedEntity, out SharedEyeComponent? eye)
|
||||
|| (eye.VisibilityMask & flag) == 0);
|
||||
}
|
||||
@@ -204,8 +204,8 @@ namespace Robust.Shared.Player
|
||||
public Filter RemoveInRange(MapCoordinates position, float range)
|
||||
{
|
||||
return RemoveWhere(session =>
|
||||
session.AttachedEntity != default &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntity).MapPosition, range));
|
||||
session.AttachedEntity != null &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntity.Value).MapPosition, range));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Robust.Shared.Players
|
||||
/// <summary>
|
||||
/// Entity UID that this session is represented by in the world, if any.
|
||||
/// </summary>
|
||||
EntityUid AttachedEntity { get; }
|
||||
EntityUid? AttachedEntity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The UID of this session.
|
||||
|
||||
Reference in New Issue
Block a user