* derelicts-base * WonderBox update v0.7 * White MapPool * ~45-90 generated, 30 mapped * radio receive sounds * default: * add wonderbox to mappool * added tags to cargo airlocks * MORE MORE MORE MORE
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using Content.Server.Worldgen.Components;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Server.Maps;
|
|
using Robust.Shared.Serialization.Manager;
|
|
|
|
namespace Content.Server.Worldgen.Systems;
|
|
|
|
public sealed class BlueprintPlacerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly MapLoaderSystem _mapLoader = default!;
|
|
[Dependency] private readonly IComponentFactory _componentFactory = default!;
|
|
[Dependency] private readonly ISerializationManager _serialization = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<BlueprintPlacerComponent, MapInitEvent>(OnMapInit);
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, BlueprintPlacerComponent component, MapInitEvent args)
|
|
{
|
|
var xform = Transform(uid);
|
|
var options = new MapLoadOptions()
|
|
{
|
|
LoadMap = false,
|
|
Offset = xform.WorldPosition,
|
|
Rotation = xform.LocalRotation,
|
|
};
|
|
|
|
_mapLoader.TryLoad(xform.MapID, component.Blueprint.ToString(), out var root, options);
|
|
|
|
if (root is null)
|
|
return;
|
|
|
|
component.Apply(root[0], _serialization, EntityManager, _componentFactory);
|
|
}
|
|
}
|