* Wizden PR copy
* sync
* Update DungeonJob.PostGenBiome.cs
* Update DungeonJob.PostGenBiome.cs
* some rebalance
* required exits and enters!
* room fill fix
* snakes nerf
* enable En-US localization for playtest
* guidebook update
* hotfix!!!
* anchoring deletion
* trying fix caves
* Update RoomFillSystem.cs
* disable locations for test
* Update CP14SpawnRandomDemiplaneJob.cs
* Update required_layers.yml
* Revert "Update required_layers.yml"
This reverts commit 2dd33db282.
* finally
* Update ContentLocalizationManager.cs
* Update spawners.yml
* Update test.yml
* fix
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Robust.Shared.Map.Components;
|
|
|
|
namespace Content.Server.Procedural;
|
|
|
|
public sealed class RoomFillSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly DungeonSystem _dungeon = default!;
|
|
[Dependency] private readonly SharedMapSystem _maps = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<RoomFillComponent, MapInitEvent>(OnRoomFillMapInit);
|
|
}
|
|
|
|
private void OnRoomFillMapInit(EntityUid uid, RoomFillComponent component, MapInitEvent args)
|
|
{
|
|
// Just test things.
|
|
if (component.Size == Vector2i.Zero)
|
|
return;
|
|
|
|
var xform = Transform(uid);
|
|
|
|
if (xform.GridUid != null)
|
|
{
|
|
var random = new Random();
|
|
var room = _dungeon.GetRoomPrototype(random, component.RoomWhitelist, component.Size);
|
|
|
|
if (room != null)
|
|
{
|
|
var mapGrid = Comp<MapGridComponent>(xform.GridUid.Value);
|
|
_dungeon.SpawnRoom(
|
|
xform.GridUid.Value,
|
|
mapGrid,
|
|
_maps.LocalToTile(xform.GridUid.Value, mapGrid, xform.Coordinates) - new Vector2i(room.Size.X/2,room.Size.Y/2), //CP14 Offset for halfroom
|
|
room,
|
|
random,
|
|
null,
|
|
clearExisting: component.ClearExisting,
|
|
rotation: component.Rotation);
|
|
}
|
|
else
|
|
{
|
|
Log.Error($"Unable to find matching room prototype for {ToPrettyString(uid)}");
|
|
}
|
|
}
|
|
|
|
// Final cleanup
|
|
QueueDel(uid);
|
|
}
|
|
}
|