mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Some fixes for map init. (#2355)
This commit is contained in:
committed by
GitHub
parent
2fd52ef3eb
commit
e94c2f039c
@@ -29,7 +29,11 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var meta = entMan.GetComponent<MetaDataComponent>(entity);
|
||||
DebugTools.Assert(meta.EntityLifeStage == EntityLifeStage.Initialized);
|
||||
|
||||
if (meta.EntityLifeStage == EntityLifeStage.MapInitialized)
|
||||
return; // Already map initialized, do nothing.
|
||||
|
||||
DebugTools.Assert(meta.EntityLifeStage == EntityLifeStage.Initialized, $"Expected entity {entMan.ToPrettyString(entity)} to be initialized, was {meta.EntityLifeStage}");
|
||||
meta.EntityLifeStage = EntityLifeStage.MapInitialized;
|
||||
|
||||
entMan.EventBus.RaiseLocalEvent(entity, MapInit, false);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -49,10 +50,13 @@ namespace Robust.Shared.Timing
|
||||
|
||||
_unInitializedMaps.Remove(mapId);
|
||||
|
||||
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInMap(mapId))
|
||||
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInMap(mapId).ToArray())
|
||||
{
|
||||
entity.RunMapInit();
|
||||
_entityManager.GetComponent<MetaDataComponent>(entity).EntityPaused = false;
|
||||
|
||||
// MapInit could have deleted this entity.
|
||||
if(_entityManager.TryGetComponent(entity, out MetaDataComponent? meta))
|
||||
meta.EntityPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ entities:
|
||||
protoMan.RegisterType(typeof(EntityPrototype));
|
||||
|
||||
protoMan.LoadDirectory(new ResourcePath("/Prototypes"));
|
||||
protoMan.Resync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace Robust.UnitTesting.Shared.Serialization
|
||||
|
||||
prototypeManager.RegisterType(typeof(EntityPrototype));
|
||||
prototypeManager.LoadString(Prototypes);
|
||||
prototypeManager.Resync();
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user