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...
This commit is contained in:
2026-01-10 13:04:33 +01:00
parent c130c47042
commit 9c449b234f
136 changed files with 3464 additions and 1147 deletions

View File

@@ -1,63 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://d0n52psuns1vl"]
[gd_scene load_steps=2 format=3 uid="uid://d0n52psuns1vl"]
[ext_resource type="Script" uid="uid://ddf3fktoer2ng" path="res://stages/intro/scripts/intro.gd" id="1_2nxbv"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_u726n"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="3_mi20s"]
[ext_resource type="Script" uid="uid://d2wapgm313xhr" path="res://stages/intro/scripts/intro_step_story.gd" id="5_tg2p4"]
[node name="Intro" type="Node"]
script = ExtResource("1_2nxbv")
game_scene_path = "uid://d28cp7a21kwou"
[node name="Story" type="CanvasLayer" parent="."]
visible = false
script = ExtResource("5_tg2p4")
[node name="CenterContainer2" type="CenterContainer" parent="Story"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="CenterContainer" type="VBoxContainer" parent="Story/CenterContainer2"]
layout_mode = 2
theme = ExtResource("1_u726n")
alignment = 1
[node name="Label" type="Label" parent="Story/CenterContainer2/CenterContainer"]
layout_mode = 2
text = "STORY"
label_settings = ExtResource("3_mi20s")
horizontal_alignment = 1
[node name="Story" type="RichTextLabel" parent="Story/CenterContainer2/CenterContainer"]
custom_minimum_size = Vector2(500, 0)
layout_mode = 2
theme = ExtResource("1_u726n")
theme_override_font_sizes/normal_font_size = 16
theme_override_font_sizes/bold_font_size = 16
theme_override_font_sizes/bold_italics_font_size = 16
theme_override_font_sizes/italics_font_size = 16
theme_override_font_sizes/mono_font_size = 16
bbcode_enabled = true
text = "STORY_TEXT"
fit_content = true
horizontal_alignment = 1
[node name="ControlsTitle" type="Label" parent="Story/CenterContainer2/CenterContainer"]
layout_mode = 2
text = "CONTROLS"
label_settings = ExtResource("3_mi20s")
horizontal_alignment = 1
[node name="ControlsText" type="Label" parent="Story/CenterContainer2/CenterContainer"]
layout_mode = 2
text = "CONTROLS_TEXT"
horizontal_alignment = 1
[node name="Button" type="Button" parent="Story/CenterContainer2/CenterContainer"]
layout_mode = 2
text = "OK"
[connection signal="pressed" from="Story/CenterContainer2/CenterContainer/Button" to="Story" method="_on_button_pressed"]

View File

@@ -5,24 +5,32 @@ var steps : Array[IntroStep]
@export_file var game_scene_path : String
func _ready():
for c in get_children():
if c is IntroStep:
steps.append(c)
c.hide()
Dialogic.start('demeter_intro')
for i in range(len(steps)):
steps[i].step_over.connect(
func():
change_step(i+1)
)
await Dialogic.timeline_ended
await LoadingScreen.show_loading_screen()
SceneManager.change_scene(SceneManager.REGION_SELECTION_SCREEN)
# for c in get_children():
# if c is IntroStep:
# steps.append(c)
# c.hide()
# for i in range(len(steps)):
# steps[i].step_over.connect(
# func():
# change_step(i+1)
# )
change_step(0)
# change_step(0)
func change_step(nb):
if nb >= len(steps):
get_tree().change_scene_to_file(game_scene_path)
for i in range(len(steps)):
if i == nb:
steps[i].show()
else :
steps[i].hide()
# func change_step(nb):
# if nb >= len(steps):
# get_tree().change_scene_to_file(game_scene_path)
# for i in range(len(steps)):
# if i == nb:
# steps[i].show()
# else :
# steps[i].hide()

View File

@@ -1,64 +0,0 @@
[gd_scene load_steps=12 format=3 uid="uid://d28cp7a21kwou"]
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="1_yy1uy"]
[ext_resource type="PackedScene" uid="uid://v41hfc7haaye" path="res://gui/game/win/win.tscn" id="3_6guxm"]
[ext_resource type="PackedScene" uid="uid://doxm7uab8i3tq" path="res://gui/game/quota_reward/quota_reward.tscn" id="4_fbkgs"]
[ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="4_g33f4"]
[ext_resource type="PackedScene" uid="uid://fh3dsuvn5h78" path="res://gui/game/tutorial/in_game_indicator/in_game_indicator.tscn" id="5_gisiu"]
[ext_resource type="PackedScene" uid="uid://dt6mptqg80dew" path="res://gui/game/tutorial/tutorial.tscn" id="5_orelw"]
[ext_resource type="Script" uid="uid://ds7ej47i3wsym" path="res://gui/game/tutorial/in_game_indicator/scripts/in_game_base_indicator.gd" id="6_cnjsq"]
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="8_t31p7"]
[ext_resource type="PackedScene" uid="uid://cg1visg52i21a" path="res://entities/interactables/truck/ladder/truck_ladder.tscn" id="9_gisiu"]
[ext_resource type="PackedScene" uid="uid://d324mlmgls4fs" path="res://entities/interactables/truck/recharge/truck_recharge.tscn" id="10_cnjsq"]
[ext_resource type="PackedScene" uid="uid://dj7gp3crtg2yt" path="res://entities/camera/camera.tscn" id="16_m18ms"]
[node name="PlanetRun" type="Node2D"]
[node name="Reward" parent="." instance=ExtResource("4_fbkgs")]
layer = 2
[node name="RootGui" parent="." node_paths=PackedStringArray("quota_reward") instance=ExtResource("1_yy1uy")]
quota_reward = NodePath("../Reward")
metadata/_edit_use_anchors_ = true
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Win" parent="CanvasLayer" instance=ExtResource("3_6guxm")]
visible = false
[node name="Tutorial" parent="CanvasLayer" node_paths=PackedStringArray("player", "planet") instance=ExtResource("5_orelw")]
player = NodePath("../../Planet/Entities/Player")
planet = NodePath("../../Planet")
[node name="BaseIndicator" parent="CanvasLayer" node_paths=PackedStringArray("player") instance=ExtResource("5_gisiu")]
visible = false
offset_bottom = 91.0
size_flags_horizontal = 4
size_flags_vertical = 4
script = ExtResource("6_cnjsq")
player = NodePath("../../Planet/Entities/Player")
[node name="Planet" parent="." node_paths=PackedStringArray("quota_reward", "entity_container") instance=ExtResource("8_t31p7")]
loot_item_number = Array[int]([1])
quota_reward = NodePath("../Reward")
entity_container = NodePath("Entities")
[node name="Entities" type="Node2D" parent="Planet"]
y_sort_enabled = true
[node name="Player" parent="Planet/Entities" instance=ExtResource("4_g33f4")]
position = Vector2(2, 0)
[node name="TruckLadder" parent="Planet/Entities" instance=ExtResource("9_gisiu")]
position = Vector2(50, -135)
[node name="TruckRecharge" parent="Planet/Entities" instance=ExtResource("10_cnjsq")]
position = Vector2(-46, -152)
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("16_m18ms")]
position = Vector2(2.22, 0)
following = NodePath("../Planet/Entities/Player")
[connection signal="day_limit_exceed" from="Planet" to="CanvasLayer/Win" method="_on_planet_day_limit_exceed"]
[connection signal="pass_day_ended" from="Planet" to="RootGui" method="_on_planet_pass_day_ended"]
[connection signal="pass_day_started" from="Planet" to="RootGui" method="_on_planet_pass_day_started"]

View File

@@ -0,0 +1,38 @@
[gd_scene load_steps=8 format=3 uid="uid://gxbqe5rtqi58"]
[ext_resource type="Script" uid="uid://j8cd0qbk4bma" path="res://stages/region_selection/region_point/scripts/region_point.gd" id="1_65ijn"]
[ext_resource type="Script" uid="uid://b4eimt3v08jhc" path="res://common/game_data/scripts/run/run_point.gd" id="2_34ylp"]
[ext_resource type="Script" uid="uid://ddk7j5b8p51dk" path="res://stages/terrain/planet/scripts/planet_parameter.gd" id="3_dm7jk"]
[ext_resource type="Texture2D" uid="uid://dqsx56wc73wry" path="res://common/icons/map-pin-check.svg" id="4_ndccb"]
[sub_resource type="Resource" id="Resource_ndccb"]
script = ExtResource("3_dm7jk")
charges = 10
objective = 10
planet_seed = 4074963764
[sub_resource type="Resource" id="Resource_txxa3"]
script = ExtResource("2_34ylp")
level = 1
planet_parameter = SubResource("Resource_ndccb")
region_name = "Usaf"
position = 61
metadata/_custom_type_script = "uid://b4eimt3v08jhc"
[sub_resource type="SphereShape3D" id="SphereShape3D_ys0ma"]
radius = 1.0629065
[node name="RegionPoint" type="Area3D"]
script = ExtResource("1_65ijn")
run_point = SubResource("Resource_txxa3")
state = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_ys0ma")
[node name="Sprite3D" type="Sprite3D" parent="."]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0.5)
pixel_size = 0.04
billboard = 1
texture = ExtResource("4_ndccb")

View File

@@ -0,0 +1,71 @@
@tool
extends Area3D
class_name RegionPoint
enum State {VISITED, CURRENT, TO_VISIT}
const SPRITE_HOVER_SCALE_MULTIPLIER = 1.5
const VISITED_OPACITY = 0.5
const YELLOW_COLOR = Color("FFA617")
const VISITED_SPRITE = preload("res://common/icons/map-pin-check.svg")
const CURRENT_SPRITE = preload("res://common/icons/map-pin.svg")
const TO_VISIT_SPRITE = preload("res://common/icons/map-pin-empty.svg")
@export var run_point : RunPoint
@export var state : State = State.CURRENT :
set(v):
state = v
if is_node_ready():
update_state()
var hovered := false
func _ready():
update_state()
func _process(_delta):
var scale_multiplier = SPRITE_HOVER_SCALE_MULTIPLIER if hovered else 1.
%Sprite3D.scale = lerp(%Sprite3D.scale, Vector3.ONE * scale_multiplier, 0.1)
func _on_mouse_entered():
hovered = true
Pointer.inspect(self)
func _on_mouse_exited():
hovered = false
Pointer.stop_inspect(self)
func card_info() -> CardInfo:
var info = run_point.card_info()
var visited_text = "VISITED_REGION"
if state == State.CURRENT:
visited_text = "CURRENT_REGION"
elif state == State.TO_VISIT:
visited_text = "REGION_TO_VISIT"
info.stats.append(
CardStatInfo.new(
visited_text,
%Sprite3D.texture
)
)
return info
func update_state():
var texture = VISITED_SPRITE
var color = Color(1.,1.,1.,VISITED_OPACITY)
if state == State.CURRENT:
texture = CURRENT_SPRITE
color = Color.WHITE
elif state == State.TO_VISIT:
texture = TO_VISIT_SPRITE
color = YELLOW_COLOR
%Sprite3D.texture = texture
%Sprite3D.modulate = color

View File

@@ -0,0 +1 @@
uid://j8cd0qbk4bma

View File

@@ -0,0 +1,148 @@
[gd_scene load_steps=13 format=3 uid="uid://bjs67nvh61otf"]
[ext_resource type="Script" uid="uid://bmb4beevw5r40" path="res://stages/region_selection/scripts/region_selection.gd" id="1_gqvix"]
[ext_resource type="PackedScene" uid="uid://cm5b7w7j6527f" path="res://stages/title_screen/planet_3d.tscn" id="5_bi8m0"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="5_twywe"]
[ext_resource type="Script" uid="uid://dqj1qh7xcmnhc" path="res://stages/region_selection/scripts/region_selection_camera.gd" id="6_gcxbq"]
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="6_gqvix"]
[ext_resource type="Shader" uid="uid://bv2rghn44mrrf" path="res://stages/title_screen/resources/shaders/stars.gdshader" id="7_2ywd4"]
[ext_resource type="PackedScene" uid="uid://rxao2rluuwqq" path="res://gui/game/screen/screen.tscn" id="7_gqvix"]
[ext_resource type="Script" path="res://stages/region_selection/scripts/region_selection_travel_validation.gd" id="8_jxqjc"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_twywe"]
seed = 172208034
frequency = 1.0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ee13y"]
shader = ExtResource("7_2ywd4")
shader_parameter/sky_color = Color(0.03, 0.05, 0.11, 1)
shader_parameter/star_base_color = Color(0.8, 1, 0.3, 1)
shader_parameter/star_hue_offset = 0.6
shader_parameter/star_intensity = 0.08
shader_parameter/star_twinkle_speed = 0.8
shader_parameter/star_twinkle_intensity = 0.2
shader_parameter/layer_scale = 20.0
shader_parameter/layer_scale_step = 10.0
shader_parameter/layers_count = 3
[sub_resource type="Sky" id="Sky_65b6a"]
sky_material = SubResource("ShaderMaterial_ee13y")
[sub_resource type="Environment" id="Environment_187ay"]
background_mode = 2
sky = SubResource("Sky_65b6a")
sky_custom_fov = 61.7
reflected_light_source = 1
tonemap_exposure = 1.54
glow_enabled = true
glow_intensity = 1.22
glow_bloom = 0.39
glow_hdr_threshold = 0.81
glow_hdr_scale = 0.0
glow_hdr_luminance_cap = 0.3
fog_density = 0.0
fog_sky_affect = 0.0
adjustment_enabled = true
adjustment_brightness = 1.04
adjustment_contrast = 1.2
adjustment_saturation = 0.88
[node name="RegionSelectionScreen" type="Node3D"]
script = ExtResource("1_gqvix")
[node name="Planet3d" parent="." instance=ExtResource("5_bi8m0")]
unique_name_in_owner = true
transform = Transform3D(0.17364822, 0, -0.9848077, 0, 1, 0, 0.9848077, 0, 0.17364822, 0.0020446777, 0, 0)
noise = SubResource("FastNoiseLite_twywe")
[node name="RegionPointContainer" type="Node3D" parent="Planet3d"]
unique_name_in_owner = true
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, -79.21178)
current = true
fov = 34.0
script = ExtResource("6_gcxbq")
_sprite_layer = 1
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_187ay")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.8423772, -0.34588623, 0.4132353, -0.5388884, -0.5406809, 0.6459594, 0, -0.76682913, -0.6418513, 0, 14.918039, 0)
[node name="Hud" type="CanvasLayer" parent="."]
[node name="MarginContainer" type="MarginContainer" parent="Hud"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("5_twywe")
[node name="Label" type="Label" parent="Hud/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
text = "CHOOSE_A_REGION"
label_settings = ExtResource("6_gqvix")
[node name="ReturnButton" type="Button" parent="Hud/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8
theme = ExtResource("5_twywe")
text = "RETURN"
[node name="TravelValidation" parent="Hud" instance=ExtResource("7_gqvix")]
unique_name_in_owner = true
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -359.0
offset_top = -137.0
offset_right = 359.0
offset_bottom = 96.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
script = ExtResource("8_jxqjc")
[node name="TravelValidationContainer" type="VBoxContainer" parent="Hud/TravelValidation/ScreenContainer" index="0"]
layout_mode = 2
theme = ExtResource("5_twywe")
alignment = 1
[node name="TravelValidationLabel" type="Label" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "TRAVEL_TO_REGION_%s"
label_settings = ExtResource("6_gqvix")
horizontal_alignment = 1
[node name="TravelValidationButtons" type="HBoxContainer" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer"]
layout_mode = 2
theme = ExtResource("5_twywe")
alignment = 1
[node name="TravelValidationGoButton" type="Button" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons"]
layout_mode = 2
theme = ExtResource("5_twywe")
text = "GO"
[node name="TravelValidationNoNowButton" type="Button" parent="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons"]
layout_mode = 2
theme = ExtResource("5_twywe")
text = "NOT_NOW"
[connection signal="region_point_clicked" from="Camera3D" to="." method="_on_camera_3d_region_point_clicked"]
[connection signal="button_down" from="Hud/MarginContainer/ReturnButton" to="." method="_on_return_button_button_down"]
[connection signal="button_down" from="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons/TravelValidationGoButton" to="." method="_on_travel_validation_go_button_button_down"]
[connection signal="button_down" from="Hud/TravelValidation/ScreenContainer/TravelValidationContainer/TravelValidationButtons/TravelValidationNoNowButton" to="." method="_on_travel_validation_no_now_button_button_down"]
[editable path="Hud/TravelValidation"]

View File

@@ -0,0 +1,114 @@
@tool
extends Node3D
class_name RegionSelection
const REGION_POINT_SCENE := preload("res://stages/region_selection/region_point/region_point.tscn")
const PLANET_REGION_POINT_MARGIN = 0
var target_planet_rotation = Vector2(0,0)
var planet_acceleration := Vector2(0,0)
var rotating := false
var prev_mouse_pos : Vector2
var next_mouse_pos : Vector2
var selected_run_point : RunPoint
@export_tool_button("Update Region Points", "Callable") var update_action = update_region_points
@onready var run_data : RunData = GameInfo.game_data.current_run
@onready var planet_radius = %Planet3d.radius + %Planet3d.height
func _ready():
%TravelValidation.hide()
update_region_points()
%Planet3d.generate_noise(GameInfo.game_data.current_run.run_seed)
if not GameInfo.game_data.get_current_planet_data():
%ReturnButton.hide()
func _process(delta):
if not Engine.is_editor_hint():
rotate_planet(delta)
func rotate_planet(delta):
next_mouse_pos = get_viewport().get_mouse_position()
if Input.is_action_just_pressed("action"):
rotating = true
prev_mouse_pos = get_viewport().get_mouse_position()
if Input.is_action_just_released("action"):
rotating = false
var mouse_acceleration = Vector2(
float(next_mouse_pos.x - prev_mouse_pos.x),
float(next_mouse_pos.y - prev_mouse_pos.y)
)
planet_acceleration = Vector2(mouse_acceleration.y, - mouse_acceleration.x)
var planet_rotation = planet_acceleration
if rotating:
var mouse_rotation = Vector2(
float(next_mouse_pos.x - prev_mouse_pos.x),
float(next_mouse_pos.y - prev_mouse_pos.y)
)
planet_rotation = Vector2(mouse_rotation.y, - mouse_rotation.x)
prev_mouse_pos = next_mouse_pos
else :
# var default_planet_rotation = Vector2(%Planet3d.rotation.x, %Planet3d.rotation.y) - target_planet_rotation
planet_acceleration = planet_acceleration.lerp(Vector2.ZERO, 0.1)
# %Planet3d.rotation.z = lerp(%Planet3d.rotation.z, 0., 0.05)
%Planet3d.rotate(Vector3.LEFT, planet_rotation.x * delta)
%Planet3d.rotate(Vector3.DOWN, planet_rotation.y * delta)
func generate_region_point(run_point : RunPoint, state : RegionPoint.State = RegionPoint.State.VISITED) -> RegionPoint:
var region_point := REGION_POINT_SCENE.instantiate() as RegionPoint
region_point.run_point = run_point
region_point.state = state
%RegionPointContainer.add_child(region_point)
var sphere_radius = planet_radius + PLANET_REGION_POINT_MARGIN
var default_pos = Vector3(0, sphere_radius, 0)
var vertical_pos = default_pos.rotated(Vector3.LEFT, run_point.level/float(RunData.RUN_POINT_MAX_LEVEL) * PI)
var final_pos = vertical_pos.rotated(Vector3.UP, (run_point.position % 360)/float(360) * 2 * PI)
region_point.position = final_pos
return region_point
func update_region_points():
for c in %RegionPointContainer.get_children():
c.queue_free()
if run_data.current_run_point:
generate_region_point(run_data.current_run_point, RegionPoint.State.CURRENT)
target_planet_rotation = Vector2(
0.,
- run_data.current_run_point.position/float(360) * 2 * PI,
)
%Planet3d.rotation = Vector3(target_planet_rotation.x, target_planet_rotation.y, 0.)
for visited_rp in run_data.visited_run_points:
generate_region_point(visited_rp, RegionPoint.State.VISITED)
for to_visit_rp in run_data.next_run_points:
generate_region_point(to_visit_rp, RegionPoint.State.TO_VISIT)
func _on_camera_3d_region_point_clicked(rp : RunPoint):
selected_run_point = rp
%TravelValidationLabel.text = tr("TRAVEL_TO_REGION_%s") % rp.region_name
%TravelValidation.show()
func _on_travel_validation_go_button_button_down():
if selected_run_point:
GameInfo.game_data.current_run.choose_next_run_point(selected_run_point)
SceneManager.change_scene(SceneManager.PLANET_SCENE)
func _on_travel_validation_no_now_button_button_down():
%TravelValidation.hide()
func _on_return_button_button_down():
if GameInfo.game_data.get_current_planet_data():
SceneManager.change_scene(SceneManager.PLANET_SCENE)

View File

@@ -0,0 +1 @@
uid://bmb4beevw5r40

View File

@@ -0,0 +1,43 @@
extends Camera3D
signal region_point_clicked(rp : RunPoint)
const RAY_LENGTH = 1000.
@export_flags_3d_physics var _sprite_layer
var region_point_hovered : RegionPoint = null
var _mouse_event : InputEventMouse
var _query_mouse := false
func _unhandled_input(event):
if event is InputEventMouse:
_mouse_event = event
_query_mouse = true
if event.is_action_pressed("action") and region_point_hovered and region_point_hovered.state == RegionPoint.State.TO_VISIT:
region_point_clicked.emit(region_point_hovered.run_point)
func _physics_process(_delta):
if _query_mouse:
update_mouse_hovered_region_points()
_query_mouse = false
func update_mouse_hovered_region_points() -> void:
var space_state = get_world_3d().direct_space_state
var from = project_ray_origin(_mouse_event.position)
var to = from + project_ray_normal(_mouse_event.position) * RAY_LENGTH
var query = PhysicsRayQueryParameters3D.create(from, to, _sprite_layer)
query.collide_with_areas = true
var result = space_state.intersect_ray(query)
if result.is_empty():
if region_point_hovered:
region_point_hovered._on_mouse_exited()
region_point_hovered = null
elif result.collider is RegionPoint:
if region_point_hovered and region_point_hovered != result.collider:
region_point_hovered._on_mouse_exited()
region_point_hovered = result.collider
region_point_hovered._on_mouse_entered()

View File

@@ -0,0 +1 @@
uid://dqj1qh7xcmnhc

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -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

View 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")

View File

@@ -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")

View File

@@ -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

View File

@@ -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

View File

@@ -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")
)

View File

@@ -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

View File

@@ -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

View 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()

View File

@@ -0,0 +1 @@
uid://ddk7j5b8p51dk

View File

@@ -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:

View File

@@ -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
)

View File

@@ -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()

View File

@@ -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)

View File

@@ -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)

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://c26wmvhmhpqw7"]
[resource]
transparency = 1
albedo_color = Color(0, 0.18850002, 0.29, 0.8156863)

View File

@@ -77,11 +77,11 @@ func create_sphere(sphere_radius : float, sphere_details : int) -> Array:
return sphere.get_mesh_arrays()
func generate_noise() -> Noise:
func generate_noise(seed = randi()) -> Noise:
var n := FastNoiseLite.new()
n.noise_type = FastNoiseLite.TYPE_SIMPLEX_SMOOTH
n.frequency = 1.0
n.seed = randi()
n.seed = seed
return n

View File

@@ -10,14 +10,11 @@ var rotating := false
var prev_mouse_pos : Vector2
var next_mouse_pos : Vector2
@export_file var game_scene_path : String
func _ready():
%Version.text = ProjectSettings.get_setting("application/config/version")
func _on_start_pressed():
GameInfo.game_data.current_planet_data = PlanetData.new()
get_tree().change_scene_to_file(game_scene_path)
SceneManager.change_scene(SceneManager.INTRO_SCENE)
func _process(delta):
next_mouse_pos = get_viewport().get_mouse_position()

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=13 format=3 uid="uid://dxvtm81tq1a6w"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_4ph5l"]
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="1_4ph5l"]
[ext_resource type="Script" uid="uid://cwmp2une7hobe" path="res://stages/title_screen/scripts/title_screen.gd" id="1_6yuhi"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_6yuhi"]
[ext_resource type="Texture2D" uid="uid://cdpqg3pkjcw2h" path="res://stages/title_screen/assets/textures/title.png" id="3_y6tw6"]
@@ -12,7 +12,7 @@
viewport_path = NodePath("SubViewport")
[sub_resource type="FastNoiseLite" id="FastNoiseLite_6yuhi"]
seed = 240332359
seed = 1714900736
frequency = 1.0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7a1qq"]