Inline UID
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Content.Server.Mind.Commands
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedComponent?.Owner?.Uid);
|
||||
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedComponent?.Owner);
|
||||
foreach (var role in mind.AllRoles)
|
||||
{
|
||||
builder.AppendFormat("{0} ", role.Name);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Content.Server.Mind.Components
|
||||
public void InternalEjectMind()
|
||||
{
|
||||
if (!Deleted)
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new MindRemovedMessage());
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new MindRemovedMessage());
|
||||
Mind = null;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Content.Server.Mind.Components
|
||||
public void InternalAssignMind(Mind value)
|
||||
{
|
||||
Mind = value;
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner.Uid, new MindAddedMessage());
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new MindAddedMessage());
|
||||
}
|
||||
|
||||
protected override void Shutdown()
|
||||
@@ -87,16 +87,16 @@ namespace Content.Server.Mind.Components
|
||||
var visiting = Mind?.VisitingEntity;
|
||||
if (visiting != null)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(visiting.Uid, out GhostComponent? ghost))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(visiting, out GhostComponent? ghost))
|
||||
{
|
||||
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghost, false);
|
||||
}
|
||||
|
||||
Mind!.TransferTo(visiting.Uid);
|
||||
Mind!.TransferTo(visiting);
|
||||
}
|
||||
else if (GhostOnShutdown)
|
||||
{
|
||||
var spawnPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates;
|
||||
var spawnPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
// Use a regular timer here because the entity has probably been deleted.
|
||||
Timer.Spawn(0, () =>
|
||||
{
|
||||
@@ -110,14 +110,14 @@ namespace Content.Server.Mind.Components
|
||||
}
|
||||
|
||||
var ghost = IoCManager.Resolve<IEntityManager>().SpawnEntity("MobObserver", spawnPosition);
|
||||
var ghostComponent = IoCManager.Resolve<IEntityManager>().GetComponent<GhostComponent>(ghost.Uid);
|
||||
var ghostComponent = IoCManager.Resolve<IEntityManager>().GetComponent<GhostComponent>(ghost);
|
||||
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghostComponent, false);
|
||||
|
||||
if (Mind != null)
|
||||
{
|
||||
string? val = Mind.CharacterName ?? string.Empty;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ghost.Uid).EntityName = val;
|
||||
Mind.TransferTo(ghost.Uid);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(ghost).EntityName = val;
|
||||
Mind.TransferTo(ghost);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace Content.Server.Mind.Components
|
||||
}
|
||||
|
||||
var dead =
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(Owner.Uid, out var state) &&
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(Owner, out var state) &&
|
||||
state.IsDead();
|
||||
|
||||
if (!HasMind)
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Content.Server.Mind
|
||||
// This can be null if they're deleted (spike / brain nom)
|
||||
if (OwnedEntity == null)
|
||||
return true;
|
||||
var targetMobState = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity.Uid);
|
||||
var targetMobState = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MobStateComponent>(OwnedEntity);
|
||||
// This can be null if it's a brain (this happens very often)
|
||||
// Brains are the result of gibbing so should definitely count as dead
|
||||
if (targetMobState == null)
|
||||
@@ -185,7 +185,7 @@ namespace Content.Server.Mind
|
||||
|
||||
var message = new RoleAddedEvent(role);
|
||||
IEntity? tempQualifier = OwnedEntity;
|
||||
(tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null).EventBus.RaiseLocalEvent(OwnedEntity.Uid, message);
|
||||
(tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null).EventBus.RaiseLocalEvent(OwnedEntity, message);
|
||||
|
||||
return role;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace Content.Server.Mind
|
||||
|
||||
var message = new RoleRemovedEvent(role);
|
||||
IEntity? tempQualifier = OwnedEntity;
|
||||
(tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null).EventBus.RaiseLocalEvent(OwnedEntity.Uid, message);
|
||||
(tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null).EventBus.RaiseLocalEvent(OwnedEntity, message);
|
||||
}
|
||||
|
||||
public bool HasRole<T>() where T : Role
|
||||
@@ -296,7 +296,7 @@ namespace Content.Server.Mind
|
||||
|
||||
if (IsVisitingEntity
|
||||
&& (ghostCheckOverride // to force mind transfer, for example from ControlMobVerb
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(VisitingEntity!.Uid, out GhostComponent? ghostComponent) // visiting entity is not a Ghost
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(VisitingEntity!, out GhostComponent? ghostComponent) // visiting entity is not a Ghost
|
||||
|| !ghostComponent.CanReturnToBody)) // it is a ghost, but cannot return to body anyway, so it's okay
|
||||
{
|
||||
VisitingEntity = null;
|
||||
@@ -377,12 +377,12 @@ namespace Content.Server.Mind
|
||||
|
||||
DebugTools.AssertNotNull(oldVisitingEnt);
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<VisitingMindComponent>(oldVisitingEnt!.Uid))
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<VisitingMindComponent>(oldVisitingEnt!))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().RemoveComponent<VisitingMindComponent>(oldVisitingEnt.Uid);
|
||||
IoCManager.Resolve<IEntityManager>().RemoveComponent<VisitingMindComponent>(oldVisitingEnt);
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(oldVisitingEnt.Uid, new MindUnvisitedMessage());
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage());
|
||||
}
|
||||
|
||||
public bool TryGetSession([NotNullWhen(true)] out IPlayerSession? session)
|
||||
|
||||
Reference in New Issue
Block a user