Fixes admin logs and tests to not depend on IEntity caching (#5657)

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
Vera Aguilera Puerto
2021-12-03 10:25:07 +01:00
committed by GitHub
parent c4c139041c
commit 3f8f4c818e
14 changed files with 58 additions and 40 deletions

View File

@@ -91,14 +91,15 @@ namespace Content.Server.AI.EntitySystems
foreach (var npc in _awakeAi)
{
if (npc.Paused) continue;
if (npc.Deleted)
{
toRemove.Add(npc);
continue;
}
if (npc.Paused)
continue;
if (count >= maxUpdates)
{
break;

View File

@@ -68,8 +68,8 @@ public partial class AdminLogSystem
continue;
}
var entityName = _entityManager.TryGetEntity(uid, out var resolvedEntity)
? resolvedEntity.Name
var entityName = _entityManager.TryGetComponent(uid, out MetaDataComponent? metadata)
? metadata.EntityName
: null;
if (entities.Any(e => e.id == (int) uid)) continue;

View File

@@ -16,9 +16,9 @@ public class EntityUidConverter : AdminLogConverter<EntityUid>
writer.WriteNumber("id", (int) value);
if (entities.TryGetEntity(value, out var entity))
if (entities.TryGetComponent(value, out MetaDataComponent metaData))
{
writer.WriteString("name", entity.Name);
writer.WriteString("name", metaData.EntityName);
}
if (entities.TryGetComponent(value, out ActorComponent? actor))

View File

@@ -347,7 +347,7 @@ namespace Content.Server.Atmos.EntitySystems
{
var atmosphere = _currentRunAtmosphere[_currentRunAtmosphereIndex];
if (atmosphere.Paused || !atmosphere.Simulated || atmosphere.LifeStage >= ComponentLifeStage.Stopping)
if (atmosphere.LifeStage >= ComponentLifeStage.Stopping || atmosphere.Paused || !atmosphere.Simulated)
continue;
atmosphere.Timer += frameTime;

View File

@@ -262,6 +262,9 @@ namespace Content.Server.Disposal.Unit.EntitySystems
private void HandlePowerChange(EntityUid uid, DisposalUnitComponent component, PowerChangedEvent args)
{
if (!component.Running)
return;
// TODO: Need to check the other stuff.
if (!args.Powered)
{

View File

@@ -30,7 +30,12 @@ public class SpreaderSystem : EntitySystem
public override void Initialize()
{
SubscribeLocalEvent<SpreaderComponent, ComponentAdd>(SpreaderAddHandler);
SubscribeLocalEvent<AirtightChanged>(e => UpdateNearbySpreaders(e.Airtight.OwnerUid, e.Airtight));
SubscribeLocalEvent<AirtightChanged>(OnAirtightChanged);
}
private void OnAirtightChanged(AirtightChanged e)
{
UpdateNearbySpreaders(e.Airtight.OwnerUid, e.Airtight);
}
private void SpreaderAddHandler(EntityUid uid, SpreaderComponent component, ComponentAdd args)

View File

@@ -240,9 +240,12 @@ namespace Content.Server.Light.EntitySystems
ApcPowerReceiverComponent? powerReceiver = null,
AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref light, ref powerReceiver, ref appearance))
if (!Resolve(uid, ref light, ref powerReceiver))
return;
// Optional component.
Resolve(uid, ref appearance, false);
// check if light has bulb
var bulbUid = GetBulb(uid, light);
if (bulbUid == null || !EntityManager.TryGetComponent(bulbUid.Value, out LightBulbComponent? lightBulb))