Files
tbd-station-14/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs
Vera Aguilera Puerto 3d693c20c8 Spawn with Random Offset component (#10969)
Adds SpawnRandomOffsetComponent, which can be used to randomly move a component on map init

Co-authored-by: wrexbe <wrexbe@protonmail.com>
2022-09-16 13:01:31 -07:00

21 lines
574 B
C#

using Content.Shared.Random.Helpers;
namespace Content.Server.Coordinates;
public sealed class SpawnRandomOffsetSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SpawnRandomOffsetComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, SpawnRandomOffsetComponent component, MapInitEvent args)
{
// TODO: Kill this extension with fire, thanks
uid.RandomOffset(component.Offset);
EntityManager.RemoveComponentDeferred(uid, component);
}
}