diff --git a/Content.Server/Coordinates/SpawnRandomOffsetComponent.cs b/Content.Server/Coordinates/SpawnRandomOffsetComponent.cs new file mode 100644 index 0000000000..6ae9b927ab --- /dev/null +++ b/Content.Server/Coordinates/SpawnRandomOffsetComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server.Coordinates; + +[RegisterComponent] +public sealed class SpawnRandomOffsetComponent : Component +{ + [ViewVariables(VVAccess.ReadWrite)] + [DataField("offset")] public float Offset = 0.5f; +} diff --git a/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs b/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs new file mode 100644 index 0000000000..f664ec1225 --- /dev/null +++ b/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs @@ -0,0 +1,20 @@ +using Content.Shared.Random.Helpers; + +namespace Content.Server.Coordinates; + +public sealed class SpawnRandomOffsetSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(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); + } +}