Scale coastal crab spawning by habitat
This commit is contained in:
parent
d8bf59bca0
commit
0158b0215f
9 changed files with 261 additions and 59 deletions
|
|
@ -12,6 +12,9 @@ const GeneratedLakePool: FishPool = preload(
|
|||
const GeneratedRiverPool: FishPool = preload(
|
||||
"res://fish/pools/generated_river_pool.tres"
|
||||
)
|
||||
const Gatherables: GatherableCatalog = preload(
|
||||
"res://gathering/catalog/gatherable_catalog.tres"
|
||||
)
|
||||
const PrecipitationOcclusionType = preload(
|
||||
"res://world/environment/precipitation_occlusion.gd"
|
||||
)
|
||||
|
|
@ -402,7 +405,7 @@ func _validate_generated_region(
|
|||
+ generator.stacked_elevated_placement_keys().size()
|
||||
)
|
||||
)
|
||||
_validate_elevated_cliff_feature(generator)
|
||||
_validate_elevated_cliff_feature(region, generator)
|
||||
|
||||
var shop := region.get_node("Interactables/FishingShopWorld") as Node3D
|
||||
var storage := region.get_node("Interactables/PlayerStorageBox") as Node3D
|
||||
|
|
@ -536,6 +539,7 @@ func _validate_generated_region(
|
|||
-INF,
|
||||
0.35,
|
||||
)
|
||||
_validate_crab_spawn_surfaces(region)
|
||||
_validate_water_recovery_positions(
|
||||
region,
|
||||
grass_prop_surface_triangles,
|
||||
|
|
@ -691,6 +695,7 @@ func _validate_generated_region(
|
|||
|
||||
|
||||
func _validate_elevated_cliff_feature(
|
||||
region: GeneratedWorldRegion,
|
||||
generator: TerrainChunkGenerator,
|
||||
) -> void:
|
||||
var elevated_coordinates: Dictionary[Vector2i, StringName] = {}
|
||||
|
|
@ -824,6 +829,27 @@ func _validate_elevated_cliff_feature(
|
|||
or generator.placement_keys()[low_index].begins_with("chunk_spawn@")
|
||||
)
|
||||
assert(found_primary_ramp == not primary_is_third_tier)
|
||||
var primary_surface_height := (
|
||||
generator.elevated_cliff_level_height
|
||||
* (2.0 if primary_is_third_tier else 1.0)
|
||||
)
|
||||
var primary_surface_position := generator.to_global(
|
||||
generator.chunk_position(feature_center)
|
||||
+ Vector3.UP * primary_surface_height
|
||||
)
|
||||
assert(
|
||||
region.is_home_exterior_position_accessible(primary_surface_position)
|
||||
== not primary_is_third_tier
|
||||
)
|
||||
assert(region.is_home_exterior_position_accessible(generator.to_global(
|
||||
generator.chunk_position(feature_center)
|
||||
)))
|
||||
# A higher surface sharing a ramp-accessible base cell is still invalid
|
||||
# unless that elevation has its own authored ramp connection.
|
||||
assert(not region.is_home_exterior_position_accessible(generator.to_global(
|
||||
generator.chunk_position(feature_center)
|
||||
+ Vector3.UP * (generator.elevated_cliff_level_height * 2.0)
|
||||
)))
|
||||
|
||||
var generated := generator.get_generated_chunks_root()
|
||||
assert(generated != null)
|
||||
|
|
@ -1251,6 +1277,58 @@ func _validate_decoration_transform(
|
|||
)
|
||||
|
||||
|
||||
func _validate_crab_spawn_surfaces(region: GeneratedWorldRegion) -> void:
|
||||
var brown := Gatherables.get_entry(&"crab_brown")
|
||||
var blue := Gatherables.get_entry(&"crab_blue")
|
||||
assert(brown != null and blue != null)
|
||||
assert(is_equal_approx(
|
||||
region.get_saltwater_surface_height(),
|
||||
GeneratedWorldRegion.WATER_HEIGHT,
|
||||
))
|
||||
var brown_minimum := maxf(
|
||||
brown.minimum_surface_y,
|
||||
GeneratedWorldRegion.WATER_HEIGHT + brown.waterline_margin,
|
||||
)
|
||||
var blue_maximum := minf(
|
||||
blue.maximum_surface_y,
|
||||
GeneratedWorldRegion.WATER_HEIGHT - blue.waterline_margin,
|
||||
)
|
||||
assert(brown_minimum > blue_maximum)
|
||||
var brown_triangles := region.get_spawn_surface_triangles(
|
||||
brown.surface_materials,
|
||||
brown_minimum,
|
||||
0.6,
|
||||
brown.maximum_surface_y,
|
||||
)
|
||||
var blue_triangles := region.get_spawn_surface_triangles(
|
||||
blue.surface_materials,
|
||||
blue.minimum_surface_y,
|
||||
0.6,
|
||||
blue_maximum,
|
||||
)
|
||||
assert(not brown_triangles.is_empty())
|
||||
assert(not blue_triangles.is_empty())
|
||||
assert(
|
||||
brown.target_population_for_surface_area(
|
||||
_surface_triangle_area(brown_triangles)
|
||||
) > brown.population
|
||||
)
|
||||
assert(
|
||||
blue.target_population_for_surface_area(
|
||||
_surface_triangle_area(blue_triangles)
|
||||
) > blue.population
|
||||
)
|
||||
|
||||
|
||||
func _surface_triangle_area(triangles: Array[PackedVector3Array]) -> float:
|
||||
var area := 0.0
|
||||
for triangle: PackedVector3Array in triangles:
|
||||
area += (triangle[1] - triangle[0]).cross(
|
||||
triangle[2] - triangle[0]
|
||||
).length() * 0.5
|
||||
return area
|
||||
|
||||
|
||||
func _triangle_surface_height_at(
|
||||
position: Vector3,
|
||||
triangles: Array[PackedVector3Array],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue