Continued
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Unity.Collections;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Pure, deterministic build-placement helpers (unit-tested like <see cref="BaseGridMath"/> /
|
||||
/// <c>StorageMath</c>). Occupancy is DERIVED from the live structure set each placement (the structure
|
||||
/// ghosts are the source of truth — restart- and replay-order-safe), never cached on the immutable
|
||||
/// baked <see cref="BaseAnchor"/>. The server passes a Temp <see cref="NativeHashSet{T}"/> of occupied
|
||||
/// cells built by scanning live <see cref="PlacedStructure"/> ghosts.
|
||||
/// </summary>
|
||||
public static class BuildPlacementMath
|
||||
{
|
||||
/// <summary>True if <paramref name="cell"/> is occupied in the derived set.</summary>
|
||||
public static bool IsOccupied(in NativeHashSet<int2> occupied, int2 cell) => occupied.Contains(cell);
|
||||
|
||||
/// <summary>Full server placement legality: the cell is in-plot (half-open, negative-safe) AND not occupied.</summary>
|
||||
public static bool CanPlace(in BaseAnchor anchor, in NativeHashSet<int2> occupied, int2 cell)
|
||||
{
|
||||
return BaseGridMath.IsCellInPlot(anchor, cell) && !occupied.Contains(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user