Files
Performance-Fish/Source/PerformanceFish/CellIndex.cs
T
bbradson 79e8b5f70d Fixed rare TryFindBestBetterStoreCellFor errors, added better exception handling for drawing errors thrown by other mods
Those log messages now include things and the position where drawing fails
Plant printing was slightly improved further too, correctly handling theoretical hydroponics of sizes above 20 now
2024-04-30 20:37:18 +02:00

29 lines
1.0 KiB
C#

// Copyright (c) 2023 bradson
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
namespace PerformanceFish;
public record struct CellIndex(int Value)
{
public int Value = Value;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CellIndex(IntVec3 cell, Map map) : this(cell, map.cellIndices.mapSizeX) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CellIndex(IntVec3 cell, int mapSizeX) : this(cell.CellToIndex(mapSizeX)) {}
public IntVec3 ToCell(Map map) => ToCell(map.cellIndices.mapSizeX);
public IntVec3 ToCell(int mapSizeX) => CellIndicesUtility.IndexToCell(Value, mapSizeX);
public List<Thing> GetThingList(Map map) => map.thingGrid.thingGrid[Value];
public bool IsFogged(Map map) => map.fogGrid.fogGrid[Value];
public float GetSnowDepth(Map map) => map.snowGrid.depthGrid[Value];
public Building? GetEdifice(Map map) => map.edificeGrid[Value];
}