[Add] Thread fix
This commit is contained in:
@@ -58,6 +58,54 @@ namespace InfiniteWorld.VoxelWorld
|
||||
public bool allowRotations = true;
|
||||
}
|
||||
|
||||
internal sealed class WorldPrefabCollectionRuntime
|
||||
{
|
||||
public WorldPrefabCollectionRuntime(int sourceIndex, int maxPlacementsPerChunk, int attemptsPerPlacement, int chunkEdgePadding, IReadOnlyList<WorldPrefabEntryRuntime> entries)
|
||||
{
|
||||
SourceIndex = sourceIndex;
|
||||
MaxPlacementsPerChunk = maxPlacementsPerChunk;
|
||||
AttemptsPerPlacement = attemptsPerPlacement;
|
||||
ChunkEdgePadding = chunkEdgePadding;
|
||||
Entries = entries ?? Array.Empty<WorldPrefabEntryRuntime>();
|
||||
}
|
||||
|
||||
public int SourceIndex { get; }
|
||||
public int MaxPlacementsPerChunk { get; }
|
||||
public int AttemptsPerPlacement { get; }
|
||||
public int ChunkEdgePadding { get; }
|
||||
public IReadOnlyList<WorldPrefabEntryRuntime> Entries { get; }
|
||||
}
|
||||
|
||||
internal sealed class WorldPrefabEntryRuntime
|
||||
{
|
||||
public WorldPrefabEntryRuntime(int sourceIndex, string id, float weight, float spawnChancePercent, WorldPlacementMode placementMode, Vector2Int footprint, int clearance, int flattenPadding, int flattenSearchRadius, bool allowRotations, bool hasPrefab)
|
||||
{
|
||||
SourceIndex = sourceIndex;
|
||||
Id = string.IsNullOrWhiteSpace(id) ? $"entry_{sourceIndex}" : id;
|
||||
Weight = Mathf.Max(0f, weight);
|
||||
SpawnChancePercent = Mathf.Clamp(spawnChancePercent, 0f, 100f);
|
||||
PlacementMode = placementMode;
|
||||
Footprint = new Vector2Int(Mathf.Max(1, footprint.x), Mathf.Max(1, footprint.y));
|
||||
Clearance = Mathf.Max(0, clearance);
|
||||
FlattenPadding = Mathf.Max(0, flattenPadding);
|
||||
FlattenSearchRadius = Mathf.Max(1, flattenSearchRadius);
|
||||
AllowRotations = allowRotations;
|
||||
HasPrefab = hasPrefab;
|
||||
}
|
||||
|
||||
public int SourceIndex { get; }
|
||||
public string Id { get; }
|
||||
public float Weight { get; }
|
||||
public float SpawnChancePercent { get; }
|
||||
public WorldPlacementMode PlacementMode { get; }
|
||||
public Vector2Int Footprint { get; }
|
||||
public int Clearance { get; }
|
||||
public int FlattenPadding { get; }
|
||||
public int FlattenSearchRadius { get; }
|
||||
public bool AllowRotations { get; }
|
||||
public bool HasPrefab { get; }
|
||||
}
|
||||
|
||||
public sealed class WorldTerrainPatch
|
||||
{
|
||||
private readonly List<Vector2Int> flattenedCells;
|
||||
@@ -72,14 +120,14 @@ namespace InfiniteWorld.VoxelWorld
|
||||
|
||||
public readonly struct WorldSpawnPoint
|
||||
{
|
||||
public WorldSpawnPoint(long spawnId, Vector2Int chunkCoord, int spawnOrdinalInChunk, int collectionIndex, int entryIndex, WorldPrefabEntry entry, Vector3 position, Quaternion rotation)
|
||||
public WorldSpawnPoint(long spawnId, Vector2Int chunkCoord, int spawnOrdinalInChunk, int collectionIndex, int entryIndex, string entryId, Vector3 position, Quaternion rotation)
|
||||
{
|
||||
SpawnId = spawnId;
|
||||
ChunkCoord = chunkCoord;
|
||||
SpawnOrdinalInChunk = spawnOrdinalInChunk;
|
||||
CollectionIndex = collectionIndex;
|
||||
EntryIndex = entryIndex;
|
||||
Entry = entry;
|
||||
EntryId = entryId;
|
||||
Position = position;
|
||||
Rotation = rotation;
|
||||
}
|
||||
@@ -89,7 +137,7 @@ namespace InfiniteWorld.VoxelWorld
|
||||
public int SpawnOrdinalInChunk { get; }
|
||||
public int CollectionIndex { get; }
|
||||
public int EntryIndex { get; }
|
||||
public WorldPrefabEntry Entry { get; }
|
||||
public string EntryId { get; }
|
||||
public Vector3 Position { get; }
|
||||
public Quaternion Rotation { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user