Skip to content

Commit

Permalink
EntityTest fixes, SectorService cleanup, welders
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Oct 16, 2024
1 parent 547e196 commit 9b1e017
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
29 changes: 26 additions & 3 deletions Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,21 @@ await server.WaitPost(() =>
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
.Select(p => p.ID)
.ToList();
bool anyException = false;
foreach (var protoId in protoIds)
{
Logger.Info($"Spawning proto {protoId}");
entityMan.SpawnEntity(protoId, map.GridCoords);
try
{
entityMan.SpawnEntity(protoId, map.GridCoords);
}
catch (Exception e)
{
Logger.Info($"Exception while spawning proto {protoId}: \"{e.Message}\" {e.StackTrace}");
anyException = true;
}
}
Assert.That(anyException, Is.EqualTo(false), "One or more exceptions occurred during entity spawn.");
});
await server.WaitRunTicks(15);
await server.WaitPost(() =>
Expand All @@ -121,13 +131,26 @@ await server.WaitPost(() =>
}
}

bool anyException = false;
var entityMetas = Query<MetaDataComponent>(entityMan).ToList();
foreach (var (uid, meta) in entityMetas)
{
if (!meta.EntityDeleted)
entityMan.DeleteEntity(uid);
Logger.Info($"Deleting entity {meta.EntityPrototype?.ID ?? "null"} ({uid})");
try
{
if (!meta.EntityDeleted)
entityMan.DeleteEntity(uid);
}
catch (Exception e)
{
Logger.Info($"Exception while deleting entity {meta.EntityPrototype?.ID ?? "null"} ({uid}): \"{e.Message}\" {e.StackTrace}");
anyException = true;
}
}

Assert.That(anyException, Is.EqualTo(false), "One or more exceptions occurred during entity deletion.");


Assert.That(entityMan.EntityCount, Is.Zero);
});

Expand Down
11 changes: 8 additions & 3 deletions Content.Server/_NF/SectorServices/SectorServiceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ public override void Initialize()

private void OnMapInit(EntityUid uid, StationSectorServiceHostComponent map, ComponentInit args)
{
Log.Debug($"OnMapInit! Entity: {uid} internal: {_entity}");
Log.Debug($"OnMapInit! Entity: {uid.Id} internal: {_entity.Id}");

if (_entity != EntityUid.Invalid)
return;

Spawn();
_entity = Spawn();
if (!_entity.Valid)
{
Log.Error($"OnMapInit! Invalid host returned for Spawn.");
return;
}

foreach (var servicePrototype in _prototypeManager.EnumeratePrototypes<SectorServicePrototype>())
{
Expand All @@ -49,7 +54,7 @@ private void OnMapInit(EntityUid uid, StationSectorServiceHostComponent map, Com

private void OnMapRemove(EntityUid uid, StationSectorServiceHostComponent map, ComponentRemove args)
{
Log.Debug($"OnMapRemove! Entity: {_entity}");
Log.Debug($"OnMapRemove! Entity: {_entity.Id}");
if (_entity != EntityUid.Invalid)
{
Del(_entity);
Expand Down
16 changes: 4 additions & 12 deletions Resources/Prototypes/_NF/Entities/Objects/Tools/welders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
- type: SolutionContainerManager
solutions:
Welder:
reagents:
- ReagentId: WeldingFuel
Quantity: 0
reagents: []
maxVol: 100

- type: entity
Expand All @@ -19,9 +17,7 @@
- type: SolutionContainerManager
solutions:
Welder:
reagents:
- ReagentId: WeldingFuel
Quantity: 0
reagents: []
maxVol: 250

- type: entity
Expand All @@ -32,9 +28,7 @@
- type: SolutionContainerManager
solutions:
Welder:
reagents:
- ReagentId: WeldingFuel
Quantity: 0
reagents: []
maxVol: 250

- type: entity
Expand All @@ -45,7 +39,5 @@
- type: SolutionContainerManager
solutions:
Welder:
reagents:
- ReagentId: WeldingFuel
Quantity: 0
reagents: []
maxVol: 1000
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
components:
- type: ItemPlacer
whitelist:
# Should match crates.
requireAll: true
components:
- CrateGenericSteel
- EntityStorage
- PaperLabel
- ContainerContainer
- type: CrateMachine
- type: Sprite
sprite: _NF/Structures/Machines/crate_machine.rsi
Expand Down

0 comments on commit 9b1e017

Please sign in to comment.