var sb = new StringBuilder();
var nodePos = _maps.WorldToTile(mapUid, grid, mousePos.Position);
- if (_biomes.TryGetEntity(nodePos, biomeComp, grid, out var ent))
+ if (_biomes.TryGetEntity(nodePos, biomeComp, (mapUid, grid), out var ent))
{
var text = $"Entity: {ent}";
sb.AppendLine(text);
}
- if (_biomes.TryGetDecals(nodePos, biomeComp.Layers, biomeComp.Seed, grid, out var decals))
+ if (_biomes.TryGetDecals(nodePos, biomeComp.Layers, biomeComp.Seed, (mapUid, grid), out var decals))
{
var text = $"Decals: {decals.Count}";
sb.AppendLine(text);
}
}
- if (_biomes.TryGetBiomeTile(nodePos, biomeComp.Layers, biomeComp.Seed, grid, out var tile))
+ if (_biomes.TryGetBiomeTile(nodePos, biomeComp.Layers, biomeComp.Seed, (mapUid, grid), out var tile))
{
var tileText = $"Tile: {_tileDefManager[tile.Value.TypeId].ID}";
sb.AppendLine(tileText);
if (biome.Template == null || !reloads.Modified.TryGetValue(biome.Template, out var proto))
continue;
- SetTemplate(uid, biome, (BiomeTemplatePrototype) proto);
+ SetTemplate(uid, biome, (BiomeTemplatePrototype)proto);
}
}
private void OnFTLStarted(ref FTLStartedEvent ev)
{
var targetMap = _transform.ToMapCoordinates(ev.TargetCoordinates);
- var targetMapUid = _mapManager.GetMapEntityId(targetMap.MapId);
+ var targetMapUid = _mapSystem.GetMapOrInvalid(targetMap.MapId);
if (!TryComp<BiomeComponent>(targetMapUid, out var biome))
return;
{
for (var y = Math.Floor(aabb.Bottom); y <= Math.Ceiling(aabb.Top); y++)
{
- var index = new Vector2i((int) x, (int) y);
+ var index = new Vector2i((int)x, (int)y);
var chunk = SharedMapSystem.GetChunkIndices(index, ChunkSize);
var mod = biome.ModifiedTiles.GetOrNew(chunk * ChunkSize);
- if (!mod.Add(index) || !TryGetBiomeTile(index, biome.Layers, biome.Seed, grid, out var tile))
+ if (!mod.Add(index) || !TryGetBiomeTile(index, biome.Layers, biome.Seed, (ev.MapUid, grid), out var tile))
continue;
// If we flag it as modified then the tile is never set so need to do it ourselves.
var layerProto = ProtoManager.Index<BiomeMarkerLayerPrototype>(layer);
var markerSeed = seed + chunk.X * ChunkSize + chunk.Y + localIdx;
var rand = new Random(markerSeed);
- var buffer = (int) (layerProto.Radius / 2f);
+ var buffer = (int)(layerProto.Radius / 2f);
var bounds = new Box2i(chunk + buffer, chunk + layerProto.Size - buffer);
- var count = (int) (bounds.Area / (layerProto.Radius * layerProto.Radius));
+ var count = (int)(bounds.Area / (layerProto.Radius * layerProto.Radius));
count = Math.Min(count, layerProto.MaxCount);
GetMarkerNodes(gridUid, component, grid, layerProto, forced, bounds, count, rand,
continue;
// Check if mask matches // anything blocking.
- TryGetEntity(node, biome, grid, out var proto);
+ TryGetEntity(node, biome, (gridUid, grid), out var proto);
// If there's an existing entity and it doesn't match the mask then skip.
if (layerProto.EntityMask.Count > 0 &&
continue;
// Need to ensure the tile under it has loaded for anchoring.
- if (TryGetBiomeTile(node, component.Layers, seed, grid, out var tile))
+ if (TryGetBiomeTile(node, component.Layers, seed, (gridUid, grid), out var tile))
{
_mapSystem.SetTile(gridUid, grid, node, tile.Value);
}
string? prototype;
- if (TryGetEntity(node, component, grid, out var proto) &&
+ if (TryGetEntity(node, component, (gridUid, grid), out var proto) &&
layerProto.EntityMask.TryGetValue(proto, out var maskedProto))
{
prototype = maskedProto;
if (_mapSystem.TryGetTileRef(gridUid, grid, indices, out var tileRef) && !tileRef.Tile.IsEmpty)
continue;
- if (!TryGetBiomeTile(indices, component.Layers, seed, grid, out var biomeTile))
+ if (!TryGetBiomeTile(indices, component.Layers, seed, (gridUid, grid), out var biomeTile))
continue;
_tiles.Add((indices, biomeTile.Value));
// Don't mess with anything that's potentially anchored.
var anchored = _mapSystem.GetAnchoredEntitiesEnumerator(gridUid, grid, indices);
- if (anchored.MoveNext(out _) || !TryGetEntity(indices, component, grid, out var entPrototype))
+ if (anchored.MoveNext(out _) || !TryGetEntity(indices, component, (gridUid, grid), out var entPrototype))
continue;
// TODO: Fix non-anchored ents spawning.
// Don't mess with anything that's potentially anchored.
var anchored = _mapSystem.GetAnchoredEntitiesEnumerator(gridUid, grid, indices);
- if (anchored.MoveNext(out _) || !TryGetDecals(indices, component.Layers, seed, grid, out var decals))
+ if (anchored.MoveNext(out _) || !TryGetDecals(indices, component.Layers, seed, (gridUid, grid), out var decals))
continue;
foreach (var decal in decals)
continue;
// Don't mess with anything that's potentially anchored.
- var anchored = grid.GetAnchoredEntitiesEnumerator(indices);
+ var anchored = _mapSystem.GetAnchoredEntitiesEnumerator(gridUid, grid, indices);
if (anchored.MoveNext(out _))
{
EnsureComp<SunShadowCycleComponent>(mapUid);
var moles = new float[Atmospherics.AdjustedNumberOfGases];
- moles[(int) Gas.Oxygen] = 21.824779f;
- moles[(int) Gas.Nitrogen] = 82.10312f;
+ moles[(int)Gas.Oxygen] = 21.824779f;
+ moles[(int)Gas.Nitrogen] = 82.10312f;
var mixture = new GasMixture(moles, Atmospherics.T20C);
continue;
}
- if (!TryGetBiomeTile(tileSet.GridIndices, biome.Layers, biome.Seed, mapGrid, out var tile))
+ if (!TryGetBiomeTile(tileSet.GridIndices, biome.Layers, biome.Seed, (mapUid, mapGrid), out var tile))
{
continue;
}
if (dunGen.TileMask is not null)
{
- if (!dunGen.TileMask.Contains(((ContentTileDefinition) _tileDefManager[tileRef.Value.Tile.TypeId]).ID))
+ if (!dunGen.TileMask.Contains(((ContentTileDefinition)_tileDefManager[tileRef.Value.Tile.TypeId]).ID))
continue;
}
// Need to set per-tile to override data.
- if (biomeSystem.TryGetTile(node, indexedBiome.Layers, seed, _grid, out var tile))
+ if (biomeSystem.TryGetTile(node, indexedBiome.Layers, seed, (_gridUid, _grid), out var tile))
{
_maps.SetTile(_gridUid, _grid, node, tile.Value);
}
- if (biomeSystem.TryGetDecals(node, indexedBiome.Layers, seed, _grid, out var decals))
+ if (biomeSystem.TryGetDecals(node, indexedBiome.Layers, seed, (_gridUid, _grid), out var decals))
{
foreach (var decal in decals)
{
}
}
- if (biomeSystem.TryGetEntity(node, indexedBiome.Layers, tile ?? tileRef.Value.Tile, seed, _grid, out var entityProto))
+ if (biomeSystem.TryGetEntity(node, indexedBiome.Layers, tile ?? tileRef.Value.Tile, seed, (_gridUid, _grid), out var entityProto))
{
var ent = _entManager.SpawnEntity(entityProto, new EntityCoordinates(_gridUid, node + _grid.TileSizeHalfVector));
var xform = xformQuery.Get(ent);
[Dependency] private readonly ISerializationManager _serManager = default!;
[Dependency] protected readonly ITileDefinitionManager TileDefManager = default!;
[Dependency] private readonly TileSystem _tile = default!;
+ [Dependency] private readonly SharedMapSystem _map = default!;
protected const byte ChunkSize = 8;
public bool TryGetBiomeTile(EntityUid uid, MapGridComponent grid, Vector2i indices, [NotNullWhen(true)] out Tile? tile)
{
- if (grid.TryGetTileRef(indices, out var tileRef) && !tileRef.Tile.IsEmpty)
+ if (_map.TryGetTileRef(uid, grid, indices, out var tileRef) && !tileRef.Tile.IsEmpty)
{
tile = tileRef.Tile;
return true;
return false;
}
- return TryGetBiomeTile(indices, biome.Layers, biome.Seed, grid, out tile);
+ return TryGetBiomeTile(indices, biome.Layers, biome.Seed, (uid, grid), out tile);
}
/// <summary>
/// Tries to get the tile, real or otherwise, for the specified indices.
/// </summary>
- public bool TryGetBiomeTile(Vector2i indices, List<IBiomeLayer> layers, int seed, MapGridComponent? grid, [NotNullWhen(true)] out Tile? tile)
+ public bool TryGetBiomeTile(Vector2i indices, List<IBiomeLayer> layers, int seed, Entity<MapGridComponent>? grid, [NotNullWhen(true)] out Tile? tile)
{
- if (grid?.TryGetTileRef(indices, out var tileRef) == true && !tileRef.Tile.IsEmpty)
+ if (grid is { } gridEnt && _map.TryGetTileRef(gridEnt, gridEnt.Comp, indices, out var tileRef) && !tileRef.Tile.IsEmpty)
{
tile = tileRef.Tile;
return true;
return TryGetTile(indices, layers, seed, grid, out tile);
}
+ /// <summary>
+ /// Tries to get the tile, real or otherwise, for the specified indices.
+ /// </summary>
+ [Obsolete("Use the Entity<MapGridComponent>? overload")]
+ public bool TryGetBiomeTile(Vector2i indices, List<IBiomeLayer> layers, int seed, MapGridComponent? grid, [NotNullWhen(true)] out Tile? tile)
+ {
+ return TryGetBiomeTile(indices, layers, seed, grid == null ? null : (grid.Owner, grid), out tile);
+ }
+
/// <summary>
/// Gets the underlying biome tile, ignoring any existing tile that may be there.
/// </summary>
- public bool TryGetTile(Vector2i indices, List<IBiomeLayer> layers, int seed, MapGridComponent? grid, [NotNullWhen(true)] out Tile? tile)
+ public bool TryGetTile(Vector2i indices, List<IBiomeLayer> layers, int seed, Entity<MapGridComponent>? grid, [NotNullWhen(true)] out Tile? tile)
{
for (var i = layers.Count - 1; i >= 0; i--)
{
return false;
}
+ /// <summary>
+ /// Gets the underlying biome tile, ignoring any existing tile that may be there.
+ /// </summary>
+ [Obsolete("Use the Entity<MapGridComponent>? overload")]
+ public bool TryGetTile(Vector2i indices, List<IBiomeLayer> layers, int seed, MapGridComponent? grid, [NotNullWhen(true)] out Tile? tile)
+ {
+ return TryGetTile(indices, layers, seed, grid == null ? null : (grid.Owner, grid), out tile);
+ }
+
/// <summary>
/// Gets the underlying biome tile, ignoring any existing tile that may be there.
/// </summary>
if (variantCount > 1)
{
var variantValue = (noise.GetNoise(indices.X * 8, indices.Y * 8, variantCount) + 1f) * 100;
- variant = _tile.PickVariant(tileDef, (int) variantValue);
+ variant = _tile.PickVariant(tileDef, (int)variantValue);
}
tile = new Tile(tileDef.TileId, variant);
/// <summary>
/// Tries to get the relevant entity for this tile.
/// </summary>
- public bool TryGetEntity(Vector2i indices, BiomeComponent component, MapGridComponent grid,
+ public bool TryGetEntity(Vector2i indices, BiomeComponent component, Entity<MapGridComponent>? grid,
[NotNullWhen(true)] out string? entity)
{
if (!TryGetBiomeTile(indices, component.Layers, component.Seed, grid, out var tile))
return TryGetEntity(indices, component.Layers, tile.Value, component.Seed, grid, out entity);
}
+ /// <summary>
+ /// Tries to get the relevant entity for this tile.
+ /// </summary>
+ [Obsolete("Use the Entity<MapGridComponent>? overload")]
+ public bool TryGetEntity(Vector2i indices, BiomeComponent component, MapGridComponent grid,
+ [NotNullWhen(true)] out string? entity)
+ {
+ return TryGetEntity(indices, component, grid == null ? null : (grid.Owner, grid), out entity);
+ }
- public bool TryGetEntity(Vector2i indices, List<IBiomeLayer> layers, Tile tileRef, int seed, MapGridComponent grid,
+ public bool TryGetEntity(Vector2i indices, List<IBiomeLayer> layers, Tile tileRef, int seed, Entity<MapGridComponent>? grid,
[NotNullWhen(true)] out string? entity)
{
var tileId = TileDefManager[tileRef.TypeId].ID;
return false;
}
+ [Obsolete("Use the Entity<MapGridComponent>? overload")]
+ public bool TryGetEntity(Vector2i indices, List<IBiomeLayer> layers, Tile tileRef, int seed, MapGridComponent grid,
+ [NotNullWhen(true)] out string? entity)
+ {
+ return TryGetEntity(indices, layers, tileRef, seed, grid == null ? null : (grid.Owner, grid), out entity);
+ }
+
/// <summary>
/// Tries to get the relevant decals for this tile.
/// </summary>
- public bool TryGetDecals(Vector2i indices, List<IBiomeLayer> layers, int seed, MapGridComponent grid,
+ public bool TryGetDecals(Vector2i indices, List<IBiomeLayer> layers, int seed, Entity<MapGridComponent>? grid,
[NotNullWhen(true)] out List<(string ID, Vector2 Position)>? decals)
{
if (!TryGetBiomeTile(indices, layers, seed, grid, out var tileRef))
return false;
}
+ /// <summary>
+ /// Tries to get the relevant decals for this tile.
+ /// </summary>
+ [Obsolete("Use the Entity<MapGridComponent>? overload")]
+ public bool TryGetDecals(Vector2i indices, List<IBiomeLayer> layers, int seed, MapGridComponent grid,
+ [NotNullWhen(true)] out List<(string ID, Vector2 Position)>? decals)
+ {
+ return TryGetDecals(indices, layers, seed, grid == null ? null : (grid.Owner, grid), out decals);
+ }
+
private FastNoiseLite GetNoise(FastNoiseLite seedNoise, int seed)
{
var noiseCopy = new FastNoiseLite();