mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 14:52:35 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Robust.Shared.IoC;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Shared.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Raised directed on an entity when the map is initialized.
|
|
/// </summary>
|
|
public sealed class MapInitEvent : EntityEventArgs
|
|
{
|
|
}
|
|
|
|
public static class MapInitExt
|
|
{
|
|
private static readonly MapInitEvent MapInit = new MapInitEvent();
|
|
|
|
public static void RunMapInit(this EntityUid entity, IEntityManager? entMan = null)
|
|
{
|
|
// Temporary until a bit more ECS
|
|
IoCManager.Resolve(ref entMan);
|
|
var meta = entMan.GetComponent<MetaDataComponent>(entity);
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|