Predict tile-prying (#21167)

This commit is contained in:
metalgearsloth
2023-10-24 00:20:33 +11:00
committed by GitHub
parent 33935c5ce8
commit 46a3076ecb
28 changed files with 154 additions and 102 deletions

View File

@@ -14,6 +14,7 @@ public sealed class BlobFloorPlanBuilderSystem : BaseWorldSystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinition = default!;
[Dependency] private readonly TileSystem _tiles = default!;
/// <inheritdoc />
public override void Initialize()
@@ -30,6 +31,8 @@ public sealed class BlobFloorPlanBuilderSystem : BaseWorldSystem
private void PlaceFloorplanTiles(BlobFloorPlanBuilderComponent comp, MapGridComponent grid)
{
// NO MORE THAN TWO ALLOCATIONS THANK YOU VERY MUCH.
// TODO: Just put these on a field instead then?
// Also the end of the method has a big LINQ which is gonna blow this out the water.
var spawnPoints = new HashSet<Vector2i>(comp.FloorPlacements * 6);
var taken = new Dictionary<Vector2i, Tile>(comp.FloorPlacements * 5);
@@ -56,7 +59,7 @@ public sealed class BlobFloorPlanBuilderSystem : BaseWorldSystem
spawnPoints.Add(west);
var tileDef = _tileDefinition[_random.Pick(comp.FloorTileset)];
taken.Add(point, new Tile(tileDef.TileId, 0, ((ContentTileDefinition)tileDef).PickVariant(_random)));
taken.Add(point, new Tile(tileDef.TileId, 0, _tiles.PickVariant((ContentTileDefinition) tileDef)));
}
PlaceTile(Vector2i.Zero);

View File

@@ -46,7 +46,7 @@ public sealed class DebrisFeaturePlacerSystem : BaseWorldSystem
return; // Redundant logic, prolly needs it's own handler for your custom system.
var placer = Comp<DebrisFeaturePlacerControllerComponent>(component.OwningController);
var xform = Transform(uid);
var xform = args.Component;
var ownerXform = Transform(component.OwningController);
if (xform.MapUid is null || ownerXform.MapUid is null)
return; // not our problem