mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Shared.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Defines a component that has "map initialization" behavior.
|
|
/// Basically irreversible behavior that moves the map from "map editor" to playable,
|
|
/// like spawning preset objects.
|
|
/// </summary>
|
|
public interface IMapInit
|
|
{
|
|
void MapInit();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised directed on an entity when the map is initialized.
|
|
/// </summary>
|
|
public class MapInitEvent : EntityEventArgs
|
|
{
|
|
}
|
|
|
|
public static class MapInitExt
|
|
{
|
|
private static readonly MapInitEvent MapInit = new MapInitEvent();
|
|
|
|
public static void RunMapInit(this IEntity entity)
|
|
{
|
|
DebugTools.Assert(entity.LifeStage == EntityLifeStage.Initialized);
|
|
entity.LifeStage = EntityLifeStage.MapInitialized;
|
|
|
|
entity.EntityManager.EventBus.RaiseLocalEvent(entity.Uid, MapInit, false);
|
|
foreach (var init in entity.GetAllComponents<IMapInit>())
|
|
{
|
|
init.MapInit();
|
|
}
|
|
}
|
|
}
|
|
}
|