Fix pour l'alpha 1.3.1

* Correction du bug de collision des chunks (talion qui ne se détruit pas, zone fertile infertile, c'est fini !)
* Equilibrage de la difficulté pour le mode infini
* Correction de la mutation éphémère (ne donne maitenant des graines qu'à la maturation)
This commit is contained in:
2026-03-29 19:02:33 +02:00
parent a395311952
commit 84a2eafe57
6 changed files with 105 additions and 64 deletions

View File

@@ -1,3 +1,4 @@
@tool
extends Node2D
class_name Chunk
@@ -13,7 +14,7 @@ const ROCK_NOISE_FREQUENCY := 0.005
const CRISTAL_NOISE_FREQUENCY := 0.008
const DECONTAMINATION_NOISE_FREQUENCY := 0.008
const CHUNK_RANDOM_PADDING := 2
const CHUNK_RANDOM_PADDING := 1
@export var region_data : RegionData
@export var chunk_coord : Vector2i
@@ -36,18 +37,18 @@ var generation_semaphore : Semaphore
var all_tiles : Array[Vector2i]
var all_global_tiles : Array[Vector2i]
# @export_tool_button("Update", "Callable") var update_action = func():
# generation_semaphore.post()
# for c in get_children():
# c.queue_free()
@export_tool_button("Update", "Callable") var update_action = func():
generation_semaphore.post()
for c in get_children():
c.queue_free()
# setup_position()
# # queue_redraw()
# generate()
setup_position()
# queue_redraw()
generate()
# @export_tool_button("Clear", "Callable") var clear_action = func():
# for c in get_children():
# c.queue_free()
@export_tool_button("Clear", "Callable") var clear_action = func():
for c in get_children():
c.queue_free()
func _init(
_chunk_coord : Vector2i = Vector2i.ZERO,
@@ -100,45 +101,51 @@ func generate():
func calculate_all_tiles() -> Array[Vector2i]:
var coords : Array[Vector2i] = []
for x in range(-CHUNK_RANDOM_PADDING, Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING):
for y in range(-CHUNK_RANDOM_PADDING, Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING):
for x in range(-Region.CHUNK_TILE_SIZE, Region.CHUNK_TILE_SIZE * 2):
for y in range(-Region.CHUNK_TILE_SIZE, Region.CHUNK_TILE_SIZE * 2):
var coord := Vector2i(x,y)
if is_tile_in_chunk(coord):
coords.append(coord)
return coords
func is_tile_in_chunk(coord : Vector2i) -> bool:
var check_select = (chunk_coord.x + chunk_coord.y%2)%2 == 0
var x := coord.x
var y := coord.y
var tile_value = get_tile_value_from_noise(coord, random_padding_noise)
if not (
x in range(-CHUNK_RANDOM_PADDING, Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING)
and y in range(-CHUNK_RANDOM_PADDING, Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING)
if (
coord.x > Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING - 1
or coord.x < -CHUNK_RANDOM_PADDING
or coord.y > Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING - 1
or coord.y < - CHUNK_RANDOM_PADDING
):
return false
else:
var possible_chunk_x : Array[int] = [0]
var possible_chunk_y : Array[int] = [0]
if coord.x >= Region.CHUNK_TILE_SIZE - CHUNK_RANDOM_PADDING:
possible_chunk_x.append(1)
if coord.y >= Region.CHUNK_TILE_SIZE - CHUNK_RANDOM_PADDING:
possible_chunk_y.append(1)
if coord.x < CHUNK_RANDOM_PADDING:
possible_chunk_x.append(-1)
if coord.y < CHUNK_RANDOM_PADDING:
possible_chunk_y.append(-1)
var possible_chunk : Array[String] = []
for dir_x in possible_chunk_x:
for dir_y in possible_chunk_y:
possible_chunk.append(
"%d:%d" % [dir_x + chunk_coord.x, dir_y + chunk_coord.y]
)
possible_chunk.sort()
if not (
(x < 0 or x >= Region.CHUNK_TILE_SIZE)
and (y < 0 or y >= Region.CHUNK_TILE_SIZE)
):
if (
x in range(-CHUNK_RANDOM_PADDING, CHUNK_RANDOM_PADDING)
or x in range(Region.CHUNK_TILE_SIZE - CHUNK_RANDOM_PADDING, Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING)
or y in range(-CHUNK_RANDOM_PADDING, CHUNK_RANDOM_PADDING)
or y in range(Region.CHUNK_TILE_SIZE - CHUNK_RANDOM_PADDING, Region.CHUNK_TILE_SIZE + CHUNK_RANDOM_PADDING)
):
var tile_value = get_tile_value_from_noise(Vector2i(x,y), random_padding_noise)
if check_select:
if tile_value >= 0.5:
return true
else :
if tile_value < 0.5:
return true
else:
return true
return false
var choosen_chunk = possible_chunk[
floori(tile_value * len(possible_chunk))
]
return (
choosen_chunk == "%d:%d" % [chunk_coord.x, chunk_coord.y]
)
# Debug

View File

@@ -14,14 +14,20 @@ const DEFAULT_START_DECONTAMINATION_ZONE_RADIUS = 3
@export var modifiers : Array[RegionModifier]
static func get_objective_by_level(l : int) -> int:
match l:
0: return 5
1: return 8
2: return 10
3: return 15
4: return 20
5: return 30
_: return get_objective_by_level(l-1) + (l-3) * 5
if GameInfo and GameInfo.game_data.game_mode == GameData.GameMode.STORY:
match l:
0: return 5
1: return 8
2: return 10
3: return 15
4: return 20
5: return 30
_: return get_objective_by_level(l-1) + (l-3) * 5
else :
match l:
0: return 8
1: return 15
_: return get_objective_by_level(l-1) + l * 5
func _init(
_level = 0,

View File

@@ -23,12 +23,6 @@ rock_tiles_data = SubResource("Resource_ame7t")
decontamination_tiles_data = SubResource("Resource_0rtv3")
metadata/_custom_type_script = "uid://cx30nvq8b34lj"
[sub_resource type="FastNoiseLite" id="FastNoiseLite_ct7cr"]
frequency = 0.0071
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_0rtv3"]
noise = SubResource("FastNoiseLite_ct7cr")
[node name="TestChunk" type="Node2D" unique_id=990498648]
[node name="Chunk" type="Node2D" parent="." unique_id=709095052]
@@ -37,25 +31,57 @@ region_data = SubResource("Resource_tiw8g")
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk2" type="Node2D" parent="." unique_id=509661921]
position = Vector2(1280, 0)
position = Vector2(640, 0)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(1, 0)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk3" type="Node2D" parent="." unique_id=1505202284]
position = Vector2(0, 1280)
position = Vector2(1280, 0)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(2, 0)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk4" type="Node2D" parent="." unique_id=774217732]
position = Vector2(0, 640)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(0, 1)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk4" type="Node2D" parent="." unique_id=774217732]
position = Vector2(1280, 1280)
[node name="Chunk5" type="Node2D" parent="." unique_id=653124103]
position = Vector2(640, 640)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(1, 1)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1962434767]
texture = SubResource("NoiseTexture2D_0rtv3")
[node name="Chunk6" type="Node2D" parent="." unique_id=1783819673]
position = Vector2(1280, 640)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(2, 1)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk7" type="Node2D" parent="." unique_id=701583017]
position = Vector2(0, 1280)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(0, 2)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk8" type="Node2D" parent="." unique_id=1149469796]
position = Vector2(640, 1280)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(1, 2)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"
[node name="Chunk9" type="Node2D" parent="." unique_id=882201367]
position = Vector2(1280, 1280)
script = ExtResource("1_mhr83")
region_data = SubResource("Resource_tiw8g")
chunk_coord = Vector2i(2, 2)
metadata/_custom_type_script = "uid://d2ixbaa2uqlv4"