Salvage expeditions (#12745)
This commit is contained in:
@@ -125,7 +125,10 @@ public sealed partial class DungeonJob
|
||||
}
|
||||
|
||||
var tiles = new List<(Vector2i, Tile)>();
|
||||
var dungeon = new Dungeon();
|
||||
var dungeon = new Dungeon()
|
||||
{
|
||||
Position = _position
|
||||
};
|
||||
var availablePacks = new List<DungeonRoomPackPrototype>();
|
||||
var chosenPacks = new DungeonRoomPackPrototype?[gen.RoomPacks.Count];
|
||||
var packTransforms = new Matrix3[gen.RoomPacks.Count];
|
||||
@@ -424,6 +427,16 @@ public sealed partial class DungeonJob
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate center
|
||||
var dungeonCenter = Vector2.Zero;
|
||||
|
||||
foreach (var room in dungeon.Rooms)
|
||||
{
|
||||
dungeonCenter += room.Center;
|
||||
}
|
||||
|
||||
dungeon.Center = (Vector2i) (dungeonCenter / dungeon.Rooms.Count);
|
||||
|
||||
return dungeon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,13 +110,11 @@ public sealed partial class DungeonJob
|
||||
var rooms = new List<DungeonRoom>(dungeon.Rooms);
|
||||
var roomTiles = new List<Vector2i>();
|
||||
var tileData = new Tile(_tileDefManager[gen.Tile].TileId);
|
||||
var count = gen.Count;
|
||||
|
||||
while (count > 0 && rooms.Count > 0)
|
||||
for (var i = 0; i < gen.Count; i++)
|
||||
{
|
||||
var roomIndex = random.Next(rooms.Count);
|
||||
var room = rooms[roomIndex];
|
||||
rooms.RemoveAt(roomIndex);
|
||||
|
||||
// Move out 3 tiles in a direction away from center of the room
|
||||
// If none of those intersect another tile it's probably external
|
||||
@@ -126,12 +124,6 @@ public sealed partial class DungeonJob
|
||||
|
||||
foreach (var tile in roomTiles)
|
||||
{
|
||||
// Check the interior node is at least accessible?
|
||||
// Can't do anchored because it might be a locker or something.
|
||||
// TODO: Better collision mask check
|
||||
if (_lookup.GetEntitiesIntersecting(gridUid, tile, LookupFlags.Dynamic | LookupFlags.Static).Any())
|
||||
continue;
|
||||
|
||||
var direction = (tile - room.Center).ToAngle().GetCardinalDir().ToAngle().ToVec();
|
||||
var isValid = true;
|
||||
|
||||
@@ -163,8 +155,6 @@ public sealed partial class DungeonJob
|
||||
_entManager.SpawnEntity(ent, gridCoords);
|
||||
}
|
||||
|
||||
count--;
|
||||
|
||||
// Clear out any biome tiles nearby to avoid blocking it
|
||||
foreach (var nearTile in grid.GetTilesIntersecting(new Circle(gridCoords.Position, 1.5f), false))
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed partial class DungeonJob : Job<Dungeon>
|
||||
|
||||
private readonly DungeonConfigPrototype _gen;
|
||||
private readonly int _seed;
|
||||
private readonly Vector2 _position;
|
||||
private readonly Vector2i _position;
|
||||
|
||||
private readonly MapGridComponent _grid;
|
||||
private readonly EntityUid _gridUid;
|
||||
@@ -51,7 +51,7 @@ public sealed partial class DungeonJob : Job<Dungeon>
|
||||
MapGridComponent grid,
|
||||
EntityUid gridUid,
|
||||
int seed,
|
||||
Vector2 position,
|
||||
Vector2i position,
|
||||
CancellationToken cancellation = default) : base(maxTime, cancellation)
|
||||
{
|
||||
_sawmill = sawmill;
|
||||
|
||||
@@ -43,7 +43,7 @@ public sealed partial class DungeonSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var position = new Vector2(posX, posY);
|
||||
var position = new Vector2i(posX, posY);
|
||||
var dungeonUid = _mapManager.GetMapEntityId(mapId);
|
||||
|
||||
if (!TryComp<MapGridComponent>(dungeonUid, out var dungeonGrid))
|
||||
|
||||
@@ -161,7 +161,7 @@ public sealed partial class DungeonSystem : EntitySystem
|
||||
public void GenerateDungeon(DungeonConfigPrototype gen,
|
||||
EntityUid gridUid,
|
||||
MapGridComponent grid,
|
||||
Vector2 position,
|
||||
Vector2i position,
|
||||
int seed)
|
||||
{
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
@@ -193,7 +193,7 @@ public sealed partial class DungeonSystem : EntitySystem
|
||||
DungeonConfigPrototype gen,
|
||||
EntityUid gridUid,
|
||||
MapGridComponent grid,
|
||||
Vector2 position,
|
||||
Vector2i position,
|
||||
int seed)
|
||||
{
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
|
||||
Reference in New Issue
Block a user