Content update for NetEntities (#18935)
This commit is contained in:
@@ -189,7 +189,7 @@ namespace Content.Server.Ghost
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} entity ||
|
||||
!EntityManager.HasComponent<GhostComponent>(entity))
|
||||
{
|
||||
Logger.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
||||
Log.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Content.Server.Ghost
|
||||
!ghost.CanReturnToBody ||
|
||||
!EntityManager.TryGetComponent(attached, out ActorComponent? actor))
|
||||
{
|
||||
Logger.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}");
|
||||
Log.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -216,25 +216,27 @@ namespace Content.Server.Ghost
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} attached ||
|
||||
!EntityManager.TryGetComponent(attached, out GhostComponent? ghost))
|
||||
{
|
||||
Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
||||
Log.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityManager.EntityExists(msg.Target))
|
||||
var target = GetEntity(msg.Target);
|
||||
|
||||
if (!EntityManager.EntityExists(target))
|
||||
{
|
||||
Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid entity id: {msg.Target}");
|
||||
Log.Warning($"User {args.SenderSession.Name} tried to warp to an invalid entity id: {msg.Target}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryComp(msg.Target, out WarpPointComponent? warp) && warp.Follow
|
||||
|| HasComp<MobStateComponent>(msg.Target))
|
||||
if (TryComp(target, out WarpPointComponent? warp) && warp.Follow
|
||||
|| HasComp<MobStateComponent>(target))
|
||||
{
|
||||
_followerSystem.StartFollowingEntity(ghost.Owner, msg.Target);
|
||||
_followerSystem.StartFollowingEntity(attached, target);
|
||||
return;
|
||||
}
|
||||
|
||||
var xform = Transform(ghost.Owner);
|
||||
xform.Coordinates = Transform(msg.Target).Coordinates;
|
||||
var xform = Transform(attached);
|
||||
xform.Coordinates = Transform(target).Coordinates;
|
||||
xform.AttachToGridOrMap();
|
||||
if (TryComp(attached, out PhysicsComponent? physics))
|
||||
_physics.SetLinearVelocity(attached, Vector2.Zero, body: physics);
|
||||
@@ -250,11 +252,13 @@ namespace Content.Server.Ghost
|
||||
|
||||
private IEnumerable<GhostWarp> GetLocationWarps()
|
||||
{
|
||||
foreach (var warp in EntityManager.EntityQuery<WarpPointComponent>(true))
|
||||
var allQuery = AllEntityQuery<WarpPointComponent>();
|
||||
|
||||
while (allQuery.MoveNext(out var uid, out var warp))
|
||||
{
|
||||
if (warp.Location != null)
|
||||
{
|
||||
yield return new GhostWarp(warp.Owner, warp.Location, true);
|
||||
yield return new GhostWarp(GetNetEntity(uid), warp.Location, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +277,7 @@ namespace Content.Server.Ghost
|
||||
var playerInfo = $"{EntityManager.GetComponent<MetaDataComponent>(attached).EntityName} ({jobName})";
|
||||
|
||||
if (_mobState.IsAlive(attached) || _mobState.IsCritical(attached))
|
||||
yield return new GhostWarp(attached, playerInfo, false);
|
||||
yield return new GhostWarp(GetNetEntity(attached), playerInfo, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Content.Server.Ghost.Roles
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class MakeGhostRoleCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public string Command => "makeghostrole";
|
||||
public string Description => "Turns an entity into a ghost role.";
|
||||
public string Help => $"Usage: {Command} <entity uid> <name> <description> [<rules>]";
|
||||
@@ -21,21 +23,19 @@ namespace Content.Server.Ghost.Roles
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid entity uid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(uid, out MetaDataComponent? metaData))
|
||||
if (!_entManager.TryGetComponent(uid, out MetaDataComponent? metaData))
|
||||
{
|
||||
shell.WriteLine($"No entity found with uid {uid}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out MindContainerComponent? mind) &&
|
||||
if (_entManager.TryGetComponent(uid, out MindContainerComponent? mind) &&
|
||||
mind.HasMind)
|
||||
{
|
||||
shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a mind.");
|
||||
@@ -46,20 +46,20 @@ namespace Content.Server.Ghost.Roles
|
||||
var description = args[2];
|
||||
var rules = args.Length >= 4 ? args[3] : Loc.GetString("ghost-role-component-default-rules");
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole))
|
||||
if (_entManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole))
|
||||
{
|
||||
shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a {nameof(GhostRoleComponent)}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (entityManager.TryGetComponent(uid, out GhostTakeoverAvailableComponent? takeOver))
|
||||
if (_entManager.HasComponent<GhostTakeoverAvailableComponent>(uid))
|
||||
{
|
||||
shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a {nameof(GhostTakeoverAvailableComponent)}");
|
||||
return;
|
||||
}
|
||||
|
||||
ghostRole = entityManager.AddComponent<GhostRoleComponent>(uid);
|
||||
entityManager.AddComponent<GhostTakeoverAvailableComponent>(uid);
|
||||
ghostRole = _entManager.AddComponent<GhostRoleComponent>(uid.Value);
|
||||
_entManager.AddComponent<GhostTakeoverAvailableComponent>(uid.Value);
|
||||
ghostRole.RoleName = name;
|
||||
ghostRole.RoleDescription = description;
|
||||
ghostRole.RoleRules = rules;
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Content.Server.Ghost.Roles.UI
|
||||
{
|
||||
public sealed class MakeGhostRoleEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
public MakeGhostRoleEui(EntityUid entityUid)
|
||||
{
|
||||
EntityUid = entityUid;
|
||||
@@ -15,14 +17,14 @@ namespace Content.Server.Ghost.Roles.UI
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
return new MakeGhostRoleEuiState(EntityUid);
|
||||
return new MakeGhostRoleEuiState(_entManager.GetNetEntity(EntityUid));
|
||||
}
|
||||
|
||||
public override void Closed()
|
||||
{
|
||||
base.Closed();
|
||||
|
||||
EntitySystem.Get<GhostRoleSystem>().CloseMakeGhostRoleEui(Player);
|
||||
_entManager.System<GhostRoleSystem>().CloseMakeGhostRoleEui(Player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user