developpement d'écran de chargement et d'écran de sélection de niveau
* modification de certains assets * optimisation de chunks * ajout d'un SceneManager * ajout d'un premier dialogue avec Demeter * changement des jour en charge * mise en place d'un système de run * etc...
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 34 KiB |
@@ -2,7 +2,7 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c3t26nlbnkxg7"
|
||||
uid="uid://bseoyd8mqjo7y"
|
||||
path="res://.godot/imported/garden_decontamined_background_texture.png-059bd195ae2e24916e642e6f3275cffd.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
|
||||
|
After Width: | Height: | Size: 105 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c3t26nlbnkxg7"
|
||||
path="res://.godot/imported/garden_decontamined_background_texture_old.png-df017d633ed63644def49f2ef3a9d5b3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/garden_decontamined_background_texture_old.png"
|
||||
dest_files=["res://.godot/imported/garden_decontamined_background_texture_old.png-df017d633ed63644def49f2ef3a9d5b3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
After Width: | Height: | Size: 29 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://o43d0p2ojbbh"
|
||||
path="res://.godot/imported/moss_contamination_atlas_red.png-285da16354bb22d2c5b8102e267e7ff9.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/moss_biome/moss_contamination_atlas_red.png"
|
||||
dest_files=["res://.godot/imported/moss_contamination_atlas_red.png-285da16354bb22d2c5b8102e267e7ff9.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
After Width: | Height: | Size: 141 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dr72xhc07i56e"
|
||||
path="res://.godot/imported/moss_contamination_atlas_texture.png-315849d799f890ff8a71f9ec9fcd4776.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/moss_biome/moss_contamination_atlas_texture.png"
|
||||
dest_files=["res://.godot/imported/moss_contamination_atlas_texture.png-315849d799f890ff8a71f9ec9fcd4776.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
After Width: | Height: | Size: 60 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cquonnydto387"
|
||||
path="res://.godot/imported/moss_contamination_atlas_texture_2.png-273150e06680f719d234dbf50850407d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/moss_biome/moss_contamination_atlas_texture_2.png"
|
||||
dest_files=["res://.godot/imported/moss_contamination_atlas_texture_2.png-273150e06680f719d234dbf50850407d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
After Width: | Height: | Size: 29 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c07hqxv7mybw7"
|
||||
path="res://.godot/imported/moss_element_1.png-a6f9a32694a449c52289ffe35904adcc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/moss_biome/moss_element_1.png"
|
||||
dest_files=["res://.godot/imported/moss_element_1.png-a6f9a32694a449c52289ffe35904adcc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://x68ggxb8jbid"
|
||||
path="res://.godot/imported/moss_element_2.png-5cbf59b34a70d33c02f41b72eab35dd5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/moss_biome/moss_element_2.png"
|
||||
dest_files=["res://.godot/imported/moss_element_2.png-5cbf59b34a70d33c02f41b72eab35dd5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cb1k4g8fcsuke"
|
||||
path="res://.godot/imported/moss_element_3.png-c6f84b36571c3be4bea3a4fbc54917b2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/planet/assets/textures/moss_biome/moss_element_3.png"
|
||||
dest_files=["res://.godot/imported/moss_element_3.png-c6f84b36571c3be4bea3a4fbc54917b2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
6
stages/terrain/planet/moss_biome.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bnwq0xl7ak661"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1mp5sguc0b6u" path="res://stages/terrain/planet/scripts/planet.gd" id="1_ne67o"]
|
||||
|
||||
[node name="Planet" type="Node2D"]
|
||||
script = ExtResource("1_ne67o")
|
||||
@@ -1,6 +1,36 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://tsi5j1uxppa4"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://tsi5j1uxppa4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1mp5sguc0b6u" path="res://stages/terrain/planet/scripts/planet.gd" id="1_y7d8a"]
|
||||
[ext_resource type="PackedScene" uid="uid://dt6mptqg80dew" path="res://gui/game/tutorial/tutorial.tscn" id="2_0wx6t"]
|
||||
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="2_02xai"]
|
||||
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="3_6qoee"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="4_hyapw"]
|
||||
[ext_resource type="PackedScene" uid="uid://cg1visg52i21a" path="res://entities/interactables/truck/ladder/truck_ladder.tscn" id="5_yjoqs"]
|
||||
[ext_resource type="PackedScene" uid="uid://d324mlmgls4fs" path="res://entities/interactables/truck/recharge/truck_recharge.tscn" id="6_0wx6t"]
|
||||
|
||||
[node name="Planet" type="Node2D"]
|
||||
[node name="Planet" type="Node2D" node_paths=PackedStringArray("entity_container")]
|
||||
script = ExtResource("1_y7d8a")
|
||||
entity_container = NodePath("Entities")
|
||||
|
||||
[node name="PlanetGui" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Tutorial" parent="PlanetGui" node_paths=PackedStringArray("player", "planet") instance=ExtResource("2_0wx6t")]
|
||||
player = NodePath("../../Entities/Player")
|
||||
planet = NodePath("../..")
|
||||
|
||||
[node name="GameGui" parent="." instance=ExtResource("2_02xai")]
|
||||
|
||||
[node name="Entities" type="Node2D" parent="."]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Player" parent="Entities" instance=ExtResource("4_hyapw")]
|
||||
|
||||
[node name="TruckLadder" parent="Entities" instance=ExtResource("5_yjoqs")]
|
||||
position = Vector2(71, -149)
|
||||
|
||||
[node name="TruckRecharge" parent="Entities" instance=ExtResource("6_0wx6t")]
|
||||
position = Vector2(-85, -165)
|
||||
|
||||
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("3_6qoee")]
|
||||
position = Vector2(573, 324)
|
||||
following = NodePath("../Entities/Player")
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://85ap1buim1ha"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://q5isn3rwrir8" path="res://common/vfx/materials/shaders/texture_color_filter.gdshader" id="1_v8wor"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3t26nlbnkxg7" path="res://stages/terrain/planet/assets/textures/garden_decontamined_background_texture.png" id="2_v8wor"]
|
||||
[ext_resource type="Texture2D" uid="uid://bseoyd8mqjo7y" path="res://stages/terrain/planet/assets/textures/garden_decontamined_background_texture.png" id="2_v8wor"]
|
||||
|
||||
[resource]
|
||||
shader = ExtResource("1_v8wor")
|
||||
shader_parameter/red_overlay_tex = ExtResource("2_v8wor")
|
||||
shader_parameter/scale = 0.006944444
|
||||
shader_parameter/scale = 0.003
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Shader" uid="uid://bglep64ppn74p" path="res://common/vfx/materials/shaders/textures_data_filter.gdshader" id="1_ye8oh"]
|
||||
[ext_resource type="Texture2D" uid="uid://bnrjnvceprxfn" path="res://stages/terrain/planet/assets/textures/garden_background_texture.png" id="2_6hswu"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3t26nlbnkxg7" path="res://stages/terrain/planet/assets/textures/garden_decontamined_background_texture.png" id="2_r7pv0"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3t26nlbnkxg7" path="res://stages/terrain/planet/assets/textures/garden_decontamined_background_texture_old.png" id="2_r7pv0"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_6hswu"]
|
||||
frequency = 0.0109
|
||||
|
||||
@@ -2,14 +2,25 @@
|
||||
extends Node2D
|
||||
class_name Chunk
|
||||
|
||||
signal generated
|
||||
|
||||
var planet : Planet
|
||||
var planet_seed : int
|
||||
var wall_threshold = 0.6
|
||||
var decontamination_threshold = 0.15
|
||||
var decontamination_threshold = 0.8
|
||||
var cristal_threshold = 0.08
|
||||
var rock_noise_image : Noise = null
|
||||
var decontamination_noise_image : Noise = null
|
||||
|
||||
var is_generated : bool = false :
|
||||
set(v):
|
||||
is_generated = true
|
||||
if is_generated:
|
||||
generated.emit()
|
||||
var generation_finished : Array[String] = []
|
||||
|
||||
const GENERATION_NUMBER = 4
|
||||
|
||||
const NOISE_IMAGE_SIZE := 150
|
||||
|
||||
const LOOT_NUMBER : Array[int] = [2,3,4]
|
||||
@@ -18,11 +29,9 @@ const LOOT_ITEM_NUMBER : Array[int] = [1,2]
|
||||
const ROCK_NOISE_FREQUENCY := 0.01
|
||||
const DECONTAMINATION_NOISE_FREQUENCY := 0.01
|
||||
|
||||
var generation_thread: Thread
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = func():
|
||||
planet_seed = randi()
|
||||
setup()
|
||||
generate()
|
||||
|
||||
var data : ChunkData
|
||||
|
||||
@@ -35,23 +44,18 @@ func _init(
|
||||
planet_seed = planet.data.planet_seed
|
||||
data = _data
|
||||
|
||||
func _ready():
|
||||
setup()
|
||||
|
||||
func setup():
|
||||
func generate():
|
||||
rock_noise_image = generate_noise(planet_seed + 1, ROCK_NOISE_FREQUENCY)
|
||||
decontamination_noise_image = generate_noise(planet_seed + 2, DECONTAMINATION_NOISE_FREQUENCY)
|
||||
|
||||
generation_thread = Thread.new()
|
||||
generation_thread.start(
|
||||
func ():
|
||||
generate_rocks()
|
||||
generate_ground()
|
||||
generate_decontamination()
|
||||
)
|
||||
|
||||
global_position = data.chunk_coord * (Planet.CHUNK_TILE_SIZE * Planet.TILE_SIZE)
|
||||
queue_redraw()
|
||||
generate_rocks()
|
||||
generate_ground()
|
||||
generate_decontamination()
|
||||
|
||||
func finish_one_generation(generation_name : String):
|
||||
generation_finished.append(generation_name)
|
||||
if len(generation_finished) >= GENERATION_NUMBER:
|
||||
is_generated = true
|
||||
|
||||
func unload():
|
||||
for x in range(Planet.CHUNK_TILE_SIZE):
|
||||
@@ -62,13 +66,13 @@ func unload():
|
||||
planet.decontamination_layer.erase_cell(global_coord)
|
||||
|
||||
# Debug
|
||||
# func _draw():
|
||||
# draw_rect(
|
||||
# Rect2(Vector2.ZERO, Vector2.ONE * Planet.CHUNK_TILE_SIZE * Planet.TILE_SIZE),
|
||||
# Color.WHITE,
|
||||
# false,
|
||||
# 3
|
||||
# )
|
||||
func _draw():
|
||||
draw_rect(
|
||||
Rect2(Vector2.ZERO, Vector2.ONE * Planet.CHUNK_TILE_SIZE * Planet.TILE_SIZE),
|
||||
Color.WHITE,
|
||||
false,
|
||||
3
|
||||
)
|
||||
|
||||
# for x in range(NOISE_IMAGE_SIZE):
|
||||
# for y in range(NOISE_IMAGE_SIZE):
|
||||
@@ -120,10 +124,8 @@ func generate_rocks():
|
||||
elif tile_type == RockLayer.TileType.ROCK:
|
||||
rocks.append(global_coord)
|
||||
|
||||
planet.rock_layer.mutex.lock()
|
||||
planet.rock_layer.place_rocks(cristals, RockLayer.TileType.CRISTAL)
|
||||
planet.rock_layer.place_rocks(rocks, RockLayer.TileType.ROCK)
|
||||
planet.rock_layer.mutex.unlock()
|
||||
planet.rock_layer.place_rocks(cristals, RockLayer.TileType.CRISTAL, func(): finish_one_generation("rock"))
|
||||
planet.rock_layer.place_rocks(rocks, RockLayer.TileType.ROCK, func(): finish_one_generation("cristal"))
|
||||
|
||||
func get_generated_rock_type(coord : Vector2i) -> RockLayer.TileType:
|
||||
var tile_value : float = get_tile_value_from_noise(coord, rock_noise_image)
|
||||
@@ -137,11 +139,12 @@ func get_generated_rock_type(coord : Vector2i) -> RockLayer.TileType:
|
||||
return RockLayer.TileType.EMPTY
|
||||
|
||||
func generate_ground():
|
||||
planet.ground_layer.mutex.lock()
|
||||
var coords : Array[Vector2i] = []
|
||||
for x in range(Planet.CHUNK_TILE_SIZE):
|
||||
for y in range(Planet.CHUNK_TILE_SIZE):
|
||||
planet.ground_layer.place_ground(Vector2i(x,y) + Planet.CHUNK_TILE_SIZE * data.chunk_coord)
|
||||
planet.ground_layer.mutex.unlock()
|
||||
coords.append(Vector2i(x,y) + Planet.CHUNK_TILE_SIZE * data.chunk_coord)
|
||||
|
||||
planet.ground_layer.place_ground(coords, func(): finish_one_generation("ground"))
|
||||
|
||||
func generate_decontamination():
|
||||
var decontamination_tiles : Array[Vector2i] = []
|
||||
@@ -156,9 +159,9 @@ func generate_decontamination():
|
||||
):
|
||||
decontamination_tiles.append(Vector2i(x,y) + Planet.CHUNK_TILE_SIZE * data.chunk_coord)
|
||||
|
||||
planet.decontamination_layer.mutex.lock()
|
||||
planet.decontamination_layer.place_decontaminations(decontamination_tiles)
|
||||
planet.decontamination_layer.mutex.unlock()
|
||||
|
||||
func _exit_tree():
|
||||
generation_thread.wait_to_finish()
|
||||
planet.decontamination_layer.place_decontaminations(
|
||||
decontamination_tiles,
|
||||
false,
|
||||
func():
|
||||
finish_one_generation("decontamination")
|
||||
)
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
extends Terrain
|
||||
class_name Planet
|
||||
|
||||
signal day_limit_exceed(planet : Planet)
|
||||
signal pass_day_started(planet : Planet)
|
||||
signal pass_day_proceeded(planet : Planet)
|
||||
signal pass_day_ended(planet : Planet)
|
||||
|
||||
const PASS_DAY_ANIMATION_TIME : float = 1.5
|
||||
const DEFAULT_DAY_LIMIT : int = 7
|
||||
|
||||
const TILE_SET : TileSet = preload("res://stages/terrain/planet/resources/planet_tileset.tres")
|
||||
const TILE_SET : TileSet = preload("res://stages/terrain/planet/resources/moss_biome.tres")
|
||||
const TILE_SCALE = 1
|
||||
const TILE_SIZE : int = roundi(TILE_SET.tile_size.x * TILE_SCALE)
|
||||
const GROUND_TILE_MAP_MATERIAL : Material = preload("res://stages/terrain/planet/resources/materials/ground_planet_tilemap.tres")
|
||||
@@ -23,17 +21,20 @@ const CHUNK_UNLOAD_DISTANCE : int = 2
|
||||
@export_group("Loot")
|
||||
@export var first_loot_number : int = 3
|
||||
@export var loot_item_number : Array[int] = [1,2]
|
||||
@export var quota_reward : QuotaReward
|
||||
|
||||
var is_generated : bool : get = check_is_generated
|
||||
var generated_value : float : get = get_generated_value
|
||||
|
||||
var data : PlanetData
|
||||
|
||||
var contamination_texture : ImageTexture
|
||||
var day_limit = DEFAULT_DAY_LIMIT
|
||||
var rock_layer : RockLayer
|
||||
var ground_layer : GroundLayer
|
||||
var decontamination_layer : DecontaminationLayer
|
||||
var garden : Garden = null
|
||||
|
||||
var tile_set = Planet.TILE_SET
|
||||
|
||||
var generated_chunks : Dictionary[String,Chunk] = {}
|
||||
|
||||
func _init():
|
||||
@@ -51,9 +52,6 @@ func _ready():
|
||||
garden = Garden.new(data, plants)
|
||||
add_child(garden)
|
||||
|
||||
if len(GameInfo.game_data.unlocked_plant_types) == 0:
|
||||
quota_reward.trigger_reward()
|
||||
|
||||
generate_first_entities()
|
||||
|
||||
AudioManager.enter_planet()
|
||||
@@ -65,9 +63,6 @@ func _ready():
|
||||
decontamination_layer = DecontaminationLayer.new(self)
|
||||
add_child(decontamination_layer)
|
||||
|
||||
if player:
|
||||
generate_near_chunks(player)
|
||||
|
||||
func _process(_d):
|
||||
if player:
|
||||
generate_near_chunks(player)
|
||||
@@ -132,6 +127,7 @@ func generate_chunk(coord : Vector2i):
|
||||
generated_chunks[chunk_key] = new_chunk
|
||||
add_child(new_chunk)
|
||||
data.generated_chunk_entities.append(coord)
|
||||
new_chunk.generate()
|
||||
|
||||
func create_hole_in_chunk(chunk_data : ChunkData, hole_radius : int):
|
||||
var hole_center = Vector2i.ONE * floori(CHUNK_TILE_SIZE/2.)
|
||||
@@ -149,6 +145,25 @@ func remove_chunk(chunk : Chunk):
|
||||
chunk.unload()
|
||||
chunk.queue_free()
|
||||
|
||||
func check_is_generated() -> bool:
|
||||
if len(generated_chunks.keys()) == 0:
|
||||
return false
|
||||
return get_chunk_generation_count() == float(get_full_chunk_generation_count())
|
||||
|
||||
func get_generated_value():
|
||||
return get_chunk_generation_count() / float(get_full_chunk_generation_count())
|
||||
|
||||
func get_full_chunk_generation_count() -> int:
|
||||
return len(generated_chunks.keys()) * Chunk.GENERATION_NUMBER
|
||||
|
||||
func get_chunk_generation_count() -> int:
|
||||
var generation_count = 0
|
||||
|
||||
for key in generated_chunks.keys():
|
||||
generation_count += len(generated_chunks[key].generation_finished)
|
||||
|
||||
return generation_count
|
||||
|
||||
func save():
|
||||
data.entities_saved_data = save_entities()
|
||||
|
||||
@@ -174,7 +189,6 @@ func pass_day():
|
||||
|
||||
pass_day_proceeded.emit(self)
|
||||
data.day += 1
|
||||
data.quota_days -= 1
|
||||
for e : Node2D in entity_container.get_children():
|
||||
if e.has_method("_pass_day"):
|
||||
e._pass_day()
|
||||
@@ -187,20 +201,5 @@ func pass_day():
|
||||
|
||||
garden.update_garden_score()
|
||||
|
||||
if data.garden_score >= data.get_quota_score():
|
||||
reach_quota()
|
||||
elif data.quota_days <= 0:
|
||||
day_limit_exceed.emit(self)
|
||||
|
||||
save()
|
||||
|
||||
func reach_quota():
|
||||
data.quota += 1
|
||||
quota_reward.trigger_reward()
|
||||
await quota_reward.reward_chosen
|
||||
garden.update_garden_score()
|
||||
if data.garden_score >= data.get_quota_score():
|
||||
reach_quota()
|
||||
data.quota_days = data.get_quota_duration()
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,30 +1,18 @@
|
||||
extends Resource
|
||||
class_name PlanetData
|
||||
|
||||
signal new_quota_started(planet_data : PlanetData)
|
||||
signal plant_gaining_score(p : Plant, amount : int)
|
||||
signal updated(planet_data : PlanetData)
|
||||
|
||||
const MAX_DEFAULT_CONTAMINATION_ZONE_SURFACE = 3000
|
||||
const DEFAULT_GARDEN_SIZE = Vector2(1500,1500)
|
||||
const DEFAULT_START_CHARGE := 10
|
||||
const DEFAULT_OBJECTIVE := 10
|
||||
|
||||
@export var garden_size : Vector2 = Vector2(2000,2000)
|
||||
@export var planet_seed : int
|
||||
@export var quota : int = 0 :
|
||||
set(v):
|
||||
quota = v
|
||||
is_quota_announced = false
|
||||
new_quota_started.emit(self)
|
||||
@export var is_quota_announced : bool = false
|
||||
@export var garden_score : int = 0 :
|
||||
set(v):
|
||||
garden_score = v
|
||||
updated.emit(self)
|
||||
@export var day : int = 1
|
||||
@export var quota_days : int = get_quota_duration() :
|
||||
set(v):
|
||||
quota_days = v
|
||||
updated.emit(self)
|
||||
@export var entities_saved_data : Array[EntityData] = []
|
||||
@export var score_by_plant : Array[int] = []
|
||||
@export var generated_chunk_entities : Array[Vector2i]
|
||||
@@ -32,9 +20,16 @@ const DEFAULT_GARDEN_SIZE = Vector2(1500,1500)
|
||||
|
||||
@export var chunks_data : Dictionary[String, ChunkData]
|
||||
|
||||
func _init(_base_size : Vector2 = DEFAULT_GARDEN_SIZE):
|
||||
planet_seed = randi()
|
||||
garden_size = _base_size
|
||||
@export var charges : int
|
||||
@export var objective : int
|
||||
|
||||
func _init(
|
||||
parameter : PlanetParameter = PlanetParameter.new()
|
||||
):
|
||||
charges = parameter.charges
|
||||
objective = parameter.objective
|
||||
planet_seed = parameter.planet_seed
|
||||
print(planet_seed)
|
||||
|
||||
#region ------------------ Chunks ------------------
|
||||
|
||||
@@ -58,24 +53,6 @@ func get_or_create_chunk_data(coord : Vector2i) -> ChunkData:
|
||||
add_chunk_data(coord, new_chunk_data)
|
||||
return new_chunk_data
|
||||
|
||||
#region ------------------ Quotas ------------------
|
||||
func get_quota_score(q : int = quota) -> int:
|
||||
var first_quotas = [
|
||||
4,
|
||||
10,
|
||||
20,
|
||||
40,
|
||||
80,
|
||||
]
|
||||
|
||||
if quota >= len(first_quotas):
|
||||
return pow(q, 3)
|
||||
else:
|
||||
return first_quotas[q]
|
||||
|
||||
func get_quota_duration(_q = quota) -> int:
|
||||
return 7
|
||||
|
||||
#endregion
|
||||
|
||||
#region ------------------ Score ------------------
|
||||
@@ -84,4 +61,3 @@ func plant_has_gained_score(plant : Plant, amount : int):
|
||||
plant_gaining_score.emit(plant, amount)
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
14
stages/terrain/planet/scripts/planet_parameter.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends Resource
|
||||
class_name PlanetParameter
|
||||
|
||||
@export var charges : int
|
||||
@export var objective : int
|
||||
@export var planet_seed : int
|
||||
|
||||
func _init(
|
||||
_charges : int = 10,
|
||||
_objective : int = 10
|
||||
):
|
||||
charges = _charges
|
||||
objective = _objective
|
||||
planet_seed = randi()
|
||||
1
stages/terrain/planet/scripts/planet_parameter.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ddk7j5b8p51dk
|
||||
@@ -2,22 +2,21 @@
|
||||
extends PlanetLayer
|
||||
class_name DecontaminationLayer
|
||||
|
||||
const MATERIAL : Material = preload("res://stages/terrain/planet/resources/materials/decontamination_planet_tilemap.tres")
|
||||
const DECONTAMINATION_TILE_TERRAIN_SET : int = 0
|
||||
const DECONTAMINATION_TILE_TERRAIN : int = 2
|
||||
const DECONTAMINATION_TILE_TERRAIN : int = 0
|
||||
|
||||
func setup():
|
||||
material = MATERIAL
|
||||
z_index = -99
|
||||
|
||||
func place_decontamination(coord : Vector2i, save = false):
|
||||
place_decontaminations([coord], save)
|
||||
|
||||
func place_decontaminations(coords : Array[Vector2i], save = false):
|
||||
set_cells_terrain_connect(
|
||||
func place_decontaminations(coords : Array[Vector2i], save = false, on_finished : Callable = (func(): pass)):
|
||||
async_place_terrain_cells(
|
||||
coords,
|
||||
DECONTAMINATION_TILE_TERRAIN_SET,
|
||||
DECONTAMINATION_TILE_TERRAIN
|
||||
DECONTAMINATION_TILE_TERRAIN,
|
||||
on_finished
|
||||
)
|
||||
if save:
|
||||
for coord in coords:
|
||||
|
||||
@@ -3,16 +3,17 @@ extends PlanetLayer
|
||||
class_name GroundLayer
|
||||
|
||||
const MATERIAL : Material = preload("res://stages/terrain/planet/resources/materials/ground_planet_tilemap.tres")
|
||||
const GROUND_TILE_SOURCE_ID : int = 0
|
||||
const GROUND_TILE_ATLAS_COORD : Vector2i = Vector2i.ZERO
|
||||
const GROUND_TILE_TERRAIN_SET : int = 0
|
||||
const GROUND_TILE_TERRAIN : int = 3
|
||||
|
||||
func setup():
|
||||
material = MATERIAL
|
||||
z_index = -100
|
||||
|
||||
func place_ground(tile_position : Vector2i):
|
||||
set_cell(
|
||||
tile_position,
|
||||
GROUND_TILE_SOURCE_ID,
|
||||
GROUND_TILE_ATLAS_COORD,
|
||||
func place_ground(coords : Array[Vector2i], on_finished : Callable = (func(): pass)):
|
||||
async_place_terrain_cells(
|
||||
coords,
|
||||
GROUND_TILE_TERRAIN_SET,
|
||||
GROUND_TILE_TERRAIN,
|
||||
on_finished
|
||||
)
|
||||
@@ -2,9 +2,10 @@
|
||||
extends TileMapLayer
|
||||
class_name PlanetLayer
|
||||
|
||||
var threads : Array[Thread] = []
|
||||
var is_generated = false
|
||||
var planet : Planet
|
||||
@onready var mutex : Mutex = Mutex.new()
|
||||
|
||||
@onready var semaphore : Semaphore = Semaphore.new()
|
||||
|
||||
func _init(
|
||||
_planet : Planet = null
|
||||
@@ -12,9 +13,10 @@ func _init(
|
||||
planet = _planet
|
||||
|
||||
func _ready():
|
||||
tile_set = Planet.TILE_SET
|
||||
tile_set = planet.tile_set
|
||||
scale = Vector2.ONE * Planet.TILE_SCALE
|
||||
navigation_enabled = false
|
||||
semaphore.post()
|
||||
setup()
|
||||
|
||||
func setup():
|
||||
@@ -33,4 +35,42 @@ func get_all_neighbors_cell(coord : Vector2i) -> Array[Vector2i]:
|
||||
return neighbors
|
||||
|
||||
func has_cell(tile_position : Vector2i) -> bool:
|
||||
return get_cell_source_id(tile_position) != -1
|
||||
return get_cell_source_id(tile_position) != -1
|
||||
|
||||
func async_place_terrain_cells(
|
||||
coords : Array[Vector2i],
|
||||
tile_terrain_set : int = 0,
|
||||
tile_terrain : int = 0,
|
||||
on_finished : Callable = (func(): pass)
|
||||
):
|
||||
var nb = randi()
|
||||
print("async place cells %d" % nb)
|
||||
var thread = Thread.new()
|
||||
threads.append(thread)
|
||||
thread.start(
|
||||
func ():
|
||||
place_terrain_cells(
|
||||
coords,
|
||||
tile_terrain_set,
|
||||
tile_terrain
|
||||
)
|
||||
print("finish cells %d" % nb)
|
||||
on_finished.call_deferred()
|
||||
)
|
||||
|
||||
func place_terrain_cells(
|
||||
coords : Array[Vector2i],
|
||||
tile_terrain_set : int = 0,
|
||||
tile_terrain : int = 0
|
||||
):
|
||||
semaphore.wait()
|
||||
set_cells_terrain_connect(
|
||||
coords,
|
||||
tile_terrain_set,
|
||||
tile_terrain
|
||||
)
|
||||
semaphore.post()
|
||||
|
||||
func _exit_tree():
|
||||
for t in threads:
|
||||
t.wait_to_finish()
|
||||
@@ -4,8 +4,8 @@ class_name RockLayer
|
||||
|
||||
const MATERIAL : Material = preload("res://stages/terrain/planet/resources/materials/rock_planet_tilemap.tres")
|
||||
const ROCK_TILE_TERRAIN_SET : int = 0
|
||||
const ROCK_TILE_TERRAIN : int = 0
|
||||
const CRISTAL_TILE_TERRAIN : int = 1
|
||||
const ROCK_TILE_TERRAIN : int = 1
|
||||
const CRISTAL_TILE_TERRAIN : int = 2
|
||||
|
||||
const CRISTAL_LOOT_CHANCE : float = 1
|
||||
|
||||
@@ -15,27 +15,21 @@ func setup():
|
||||
material = MATERIAL
|
||||
z_index = 2
|
||||
|
||||
func place_rock(coord : Vector2i, type := TileType.ROCK):
|
||||
func place_rocks(coords : Array[Vector2i], type := TileType.ROCK,on_finished : Callable = (func(): pass)):
|
||||
if type != TileType.EMPTY:
|
||||
set_cells_terrain_connect(
|
||||
[coord],
|
||||
ROCK_TILE_TERRAIN_SET,
|
||||
ROCK_TILE_TERRAIN if type == TileType.ROCK else CRISTAL_TILE_TERRAIN
|
||||
)
|
||||
|
||||
func place_rocks(coords : Array[Vector2i], type := TileType.ROCK):
|
||||
if type != TileType.EMPTY:
|
||||
set_cells_terrain_connect(
|
||||
async_place_terrain_cells(
|
||||
coords,
|
||||
ROCK_TILE_TERRAIN_SET,
|
||||
ROCK_TILE_TERRAIN if type == TileType.ROCK else CRISTAL_TILE_TERRAIN
|
||||
ROCK_TILE_TERRAIN if type == TileType.ROCK else CRISTAL_TILE_TERRAIN,
|
||||
on_finished
|
||||
)
|
||||
|
||||
func remove_rocks(coords : Array[Vector2i], save = false):
|
||||
set_cells_terrain_connect(
|
||||
func remove_rocks(coords : Array[Vector2i], save = false,on_finished : Callable = (func(): pass)):
|
||||
async_place_terrain_cells(
|
||||
coords,
|
||||
ROCK_TILE_TERRAIN_SET,
|
||||
-1
|
||||
-1,
|
||||
on_finished
|
||||
)
|
||||
if save:
|
||||
for coord in coords:
|
||||
@@ -73,11 +67,6 @@ func loot_rock(coord : Vector2i):
|
||||
floor(Planet.TILE_SIZE/2.)
|
||||
)
|
||||
|
||||
func update_cells(coords : Array[Vector2i]):
|
||||
for coord in coords:
|
||||
if has_tile(coord):
|
||||
place_rock(coord)
|
||||
|
||||
func has_tile(coord : Vector2i) -> bool:
|
||||
return has_cell(coord)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ func _on_exit_interacted(_p : Player):
|
||||
data.rewards = []
|
||||
for c in composts:
|
||||
data.rewards.append(c.reward)
|
||||
get_tree().change_scene_to_file(PLANET_RUN_PATH)
|
||||
SceneManager.change_scene(SceneManager.PLANET_SCENE)
|
||||
|
||||
func _ready():
|
||||
load_entities(data.entities_saved_data)
|
||||
|
||||