ajout des mutation et refonte de l'inspecteur

* ajout des mutations #86
* changement de l'objectif #85
* refonte de l'inspecteur #71
* changement léger de la plantation
* les plantes ne donnent que des graines de leurs espèces
* refonte partielle du code, refacto
This commit is contained in:
2025-10-12 01:03:08 +02:00
parent bb24efe46b
commit ef392595de
108 changed files with 1921 additions and 477 deletions

View File

@@ -10,6 +10,7 @@ const SPRITE_SCENE : PackedScene = preload("res://entities/interactables/item_ob
item = _item
if object_sprite:
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
object_sprite.generate_particles(item.get_particles())
@onready var object_sprite : ItemObjectSprite = generate_sprite()
@@ -21,6 +22,7 @@ func _ready():
generate_collision(ITEM_AREA_WIDTH)
if item and object_sprite:
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
object_sprite.generate_particles(item.get_particles())
func pointer_text():
var name_suffix = ""
@@ -36,11 +38,7 @@ func interact_text():
return "Take"
func inspector_info() -> Inspector.Info:
return Inspector.Info.new(
pointer_text(),
item.description,
item.icon
)
return item.inspector_info()
func interact(player : Player) -> bool:
var swapped_item = player.pick_item(item)
@@ -61,16 +59,17 @@ func pickup_animation(player : Player):
func():
queue_free()
)
object_sprite.pickup_animation()
if object_sprite:
object_sprite.pickup_animation()
func generate_sprite() -> ItemObjectSprite:
var spriteNode = SPRITE_SCENE.instantiate() as ItemObjectSprite
add_child(spriteNode)
var sprite_node = SPRITE_SCENE.instantiate() as ItemObjectSprite
add_child(sprite_node)
if item:
spriteNode.apply_texture_to_sprite(
sprite_node.apply_texture_to_sprite(
item.icon,
ITEM_SPRITE_SIZE
)
return spriteNode
return sprite_node

View File

@@ -1,15 +1,26 @@
extends Node2D
class_name ItemObjectSprite
@onready var iconSprite = $Icon
@onready var icon_sprite = $Icon
const PARTICLES_SCENE : PackedScene = preload("res://common/vfx/particles/particles.tscn")
func apply_texture_to_sprite(texture, item_sprite_size = 50.):
if texture:
iconSprite.texture = texture
iconSprite.scale = Vector2(
icon_sprite.texture = texture
icon_sprite.scale = Vector2(
1./(texture.get_width()/item_sprite_size),
1./(texture.get_height()/item_sprite_size)
)
func generate_particles(particles_params : Array[Particles.Parameters]):
for c in get_children():
if c is Particles: queue_free()
for params in particles_params:
var particles_emitter : Particles = PARTICLES_SCENE.instantiate() as Particles
particles_emitter.setup_particles(params)
add_child(particles_emitter)
func pickup_animation():
%AnimationPlayer.play("pickup")

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 KiB

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://n7hhyqhhtx0q"
path="res://.godot/imported/compost.png-af443333eb9a31de9cc4cb40ab9c40c2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/machines/compost/assets/sprites/compost.png"
dest_files=["res://.godot/imported/compost.png-af443333eb9a31de9cc4cb40ab9c40c2.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

@@ -1,96 +1,27 @@
[gd_scene load_steps=11 format=3 uid="uid://bkwh1ntvgkkrt"]
[ext_resource type="Script" uid="uid://bw2ckthka71y8" path="res://entities/interactables/machines/compost/scripts/energy_compost.gd" id="1_2s0lp"]
[ext_resource type="Texture2D" uid="uid://f2rte5jc0psp" path="res://entities/interactables/machines/compost/assets/sprites/compost.svg" id="2_pi0jt"]
[ext_resource type="Texture2D" uid="uid://n7hhyqhhtx0q" path="res://entities/interactables/machines/compost/assets/sprites/compost.png" id="2_pi0jt"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_85qj7"]
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="3_y0cke"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_akkx7"]
size = Vector2(66, 84)
[sub_resource type="CircleShape2D" id="CircleShape2D_6kmun"]
radius = 51.884487
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_etofw"]
bg_color = Color(0.260098, 0.11665, 0.0419712, 0.231373)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3ao1n"]
bg_color = Color(0.270222, 0.270222, 0.270222, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="LabelSettings" id="LabelSettings_m2a0h"]
font = ExtResource("3_y0cke")
font_size = 23
[sub_resource type="Animation" id="Animation_r6435"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.291262, 0.291262)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 0)]
}
[sub_resource type="Animation" id="Animation_1758a"]
resource_name = "empty"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0, 12.605), Vector2(0, -24.56), Vector2(0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:scale")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(0.291262, 0.291262), Vector2(0.291, 0.191), Vector2(0.291, 0.366), Vector2(0.291262, 0.291262)]
}
[sub_resource type="Animation" id="Animation_etofw"]
resource_name = "fill"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.3),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(0.291262, 0.291262), Vector2(0.291, 0.231), Vector2(0.291262, 0.291262)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_etofw"]
_data = {
@@ -103,29 +34,29 @@ _data = {
script = ExtResource("1_2s0lp")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_akkx7")
shape = SubResource("CircleShape2D_6kmun")
[node name="Sprite" type="Sprite2D" parent="."]
unique_name_in_owner = true
self_modulate = Color(0.729698, 0.588265, 0.105405, 1)
scale = Vector2(0.291262, 0.291262)
[node name="Compost" type="Sprite2D" parent="."]
position = Vector2(1.9073486e-06, 15.999998)
scale = Vector2(0.11194731, 0.11194731)
texture = ExtResource("2_pi0jt")
[node name="ProgressBar" type="ProgressBar" parent="Sprite"]
[node name="ContainerCount" type="Label" parent="."]
unique_name_in_owner = true
offset_left = -62.0
offset_top = -7.0
offset_right = 62.0
offset_bottom = 120.0
theme_override_styles/background = SubResource("StyleBoxFlat_etofw")
theme_override_styles/fill = SubResource("StyleBoxFlat_3ao1n")
fill_mode = 3
show_percentage = false
modulate = Color(0.140831, 0.20012599, 0.3145095, 1)
offset_left = 18.0
offset_top = 37.0
offset_right = 59.051178
offset_bottom = 61.0
rotation = -0.48016798
text = "3/5"
label_settings = SubResource("LabelSettings_m2a0h")
[node name="Bolt" type="Sprite2D" parent="Sprite"]
[node name="Bolt" type="Sprite2D" parent="."]
modulate = Color(0.140831, 0.20012599, 0.3145095, 1)
z_index = 1
position = Vector2(0, 54.9334)
scale = Vector2(2.00278, 2.00278)
position = Vector2(-41.999996, 36)
scale = Vector2(0.5833337, 0.5833337)
texture = ExtResource("3_85qj7")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]

View File

@@ -1,96 +1,27 @@
[gd_scene load_steps=11 format=3 uid="uid://b13debm055r3t"]
[ext_resource type="Script" uid="uid://d0yt8pd41j2os" path="res://entities/interactables/machines/compost/scripts/seed_compost.gd" id="1_b8mmk"]
[ext_resource type="Texture2D" uid="uid://f2rte5jc0psp" path="res://entities/interactables/machines/compost/assets/sprites/compost.svg" id="2_s8eov"]
[ext_resource type="Script" uid="uid://bw2ckthka71y8" path="res://entities/interactables/machines/compost/scripts/energy_compost.gd" id="1_s8eov"]
[ext_resource type="Texture2D" uid="uid://n7hhyqhhtx0q" path="res://entities/interactables/machines/compost/assets/sprites/compost.png" id="2_c0so3"]
[ext_resource type="Texture2D" uid="uid://b0wy3dbpxbnt7" path="res://common/icons/seedling.svg" id="3_s8eov"]
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="3_sw66v"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_akkx7"]
size = Vector2(66, 84)
[sub_resource type="CircleShape2D" id="CircleShape2D_6kmun"]
radius = 51.884487
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_etofw"]
bg_color = Color(0.260098, 0.11665, 0.0419712, 0.231373)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3ao1n"]
bg_color = Color(0.270222, 0.270222, 0.270222, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="LabelSettings" id="LabelSettings_m2a0h"]
font = ExtResource("3_sw66v")
font_size = 23
[sub_resource type="Animation" id="Animation_r6435"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0.291262, 0.291262)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 0)]
}
[sub_resource type="Animation" id="Animation_1758a"]
resource_name = "empty"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0, 12.605), Vector2(0, -24.56), Vector2(0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:scale")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(0.291262, 0.291262), Vector2(0.291, 0.191), Vector2(0.291, 0.366), Vector2(0.291262, 0.291262)]
}
[sub_resource type="Animation" id="Animation_etofw"]
resource_name = "fill"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:scale")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.3),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(0.291262, 0.291262), Vector2(0.291, 0.231), Vector2(0.291262, 0.291262)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_etofw"]
_data = {
@@ -99,33 +30,33 @@ _data = {
&"fill": SubResource("Animation_etofw")
}
[node name="Compost" type="Area2D"]
script = ExtResource("1_b8mmk")
[node name="SeedCompost" type="Area2D"]
script = ExtResource("1_s8eov")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_akkx7")
shape = SubResource("CircleShape2D_6kmun")
[node name="Sprite" type="Sprite2D" parent="."]
[node name="Compost" type="Sprite2D" parent="."]
position = Vector2(1.9073486e-06, 15.999998)
scale = Vector2(0.11194731, 0.11194731)
texture = ExtResource("2_c0so3")
[node name="ContainerCount" type="Label" parent="."]
unique_name_in_owner = true
self_modulate = Color(0.90820795, 0.68268144, 0.2216644, 1)
scale = Vector2(0.291262, 0.291262)
texture = ExtResource("2_s8eov")
modulate = Color(0.140831, 0.20012599, 0.3145095, 1)
offset_left = 18.0
offset_top = 37.0
offset_right = 59.051178
offset_bottom = 61.0
rotation = -0.48016798
text = "3/5"
label_settings = SubResource("LabelSettings_m2a0h")
[node name="ProgressBar" type="ProgressBar" parent="Sprite"]
unique_name_in_owner = true
offset_left = -62.0
offset_top = -7.0
offset_right = 62.0
offset_bottom = 120.0
theme_override_styles/background = SubResource("StyleBoxFlat_etofw")
theme_override_styles/fill = SubResource("StyleBoxFlat_3ao1n")
fill_mode = 3
show_percentage = false
[node name="Bolt" type="Sprite2D" parent="Sprite"]
[node name="Bolt" type="Sprite2D" parent="."]
modulate = Color(0.140831, 0.20012599, 0.3145095, 1)
z_index = 1
position = Vector2(0, 54.9334)
scale = Vector2(2.00278, 2.00278)
position = Vector2(-41.999996, 36)
scale = Vector2(0.5833337, 0.5833337)
texture = ExtResource("3_s8eov")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]

View File

@@ -1,7 +1,10 @@
extends Machine
class_name Compost
var containing_seed : int = 0
@onready var containing_seed : int = 0 :
set(v):
containing_seed = v
%ContainerCount.text = str(containing_seed) + "/" + str(get_seed_needed())
func get_seed_needed(l : int = level) -> int:
match l:
@@ -10,12 +13,6 @@ func get_seed_needed(l : int = level) -> int:
3: return 3
_: return 2
func setup_machine_sprite():
%Sprite.self_modulate = Machine.get_level_color(level)
func _process(_delta):
%ProgressBar.value = lerp(%ProgressBar.value, float(containing_seed) / float(get_seed_needed()) * 100, 0.5)
func interact_text():
return "Put a seed ("+str(get_seed_needed() - containing_seed)+" left)"
@@ -35,6 +32,7 @@ func interact(p : Player) -> bool:
product(p)
else:
$AnimationPlayer.play("fill")
return true
func product(player : Player):

View File

@@ -22,7 +22,6 @@ func get_energy_production(l : int = level) -> int:
func _pass_day():
if not charged:
recharge_days += 1
print(get_days_to_recharge())
if recharge_days >= get_days_to_recharge():
set_charged(true)

View File

@@ -2,6 +2,7 @@ extends InspectableEntity
class_name Objective
const RANDOM_MAX_OBJECTIVE_INTERVAL = 1.
const DECONTAMINATION_ICON = preload("res://common/icons/skull.svg")
var completed : bool = false
var planet : Planet
@@ -17,11 +18,21 @@ func pointer_text():
return "Contamination Objective"
func inspector_info() -> Inspector.Info:
return Inspector.Info.new(
var info : Inspector.Info = Inspector.Info.new(
pointer_text(),
"If the zone around is decontaminated, give the following reward.\n\n" + reward.get_description(),
"This dead log can hide a treasure of life."
)
info.framed_infos.append(
Inspector.FramedInfo.new(
"When decontamined",
reward.get_description(),
DECONTAMINATION_ICON
)
)
return info
func _end_pass_day():
if planet and not completed:
if not planet.is_there_contamination(global_position):

View File

@@ -1,11 +1,9 @@
[gd_scene load_steps=10 format=3 uid="uid://2hrg6yjk0yt0"]
[gd_scene load_steps=9 format=3 uid="uid://2hrg6yjk0yt0"]
[ext_resource type="Script" uid="uid://bmjjpk4lvijws" path="res://entities/plants/scripts/plant_sprite.gd" id="1_pq8o7"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="3_j6jm5"]
[ext_resource type="Texture2D" uid="uid://bu26h0iqutnky" path="res://entities/underground_loot/assets/sprites/underground_loot.svg" id="4_j6jm5"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_rbgiq"]
[sub_resource type="AtlasTexture" id="AtlasTexture_wyuub"]
atlas = ExtResource("3_j6jm5")
region = Rect2(76, 75, 124, 135)
@@ -106,7 +104,7 @@ script = ExtResource("1_pq8o7")
[node name="Sprite" type="Sprite2D" parent="."]
unique_name_in_owner = true
scale = Vector2(0.15, 0.15)
texture = SubResource("CompressedTexture2D_rbgiq")
offset = Vector2(0, -151.56)
[node name="PlantedSeed" type="Sprite2D" parent="Sprite"]
unique_name_in_owner = true

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="AncientMutation" load_steps=2 format=3 uid="uid://dys1ehlg4kwh7"]
[ext_resource type="Script" uid="uid://c7po0bstyg80u" path="res://entities/plants/scripts/plant_mutation/ancient_mutation.gd" id="1_5g2qg"]
[resource]
script = ExtResource("1_5g2qg")
metadata/_custom_type_script = "uid://c7po0bstyg80u"

View File

@@ -0,0 +1,6 @@
[gd_resource type="Resource" script_class="ElitistMutation" load_steps=2 format=3 uid="uid://d38alhstybdtf"]
[ext_resource type="Script" uid="uid://bt1xh7ss13e5e" path="res://entities/plants/scripts/plant_mutation/elitist_mutation.gd" id="1_jevqj"]
[resource]
script = ExtResource("1_jevqj")

View File

@@ -0,0 +1,6 @@
[gd_resource type="Resource" script_class="ErmitMutation" load_steps=2 format=3 uid="uid://dktlbpira5kxb"]
[ext_resource type="Script" uid="uid://domy822vgxfxs" path="res://entities/plants/scripts/plant_mutation/ermit_mutation.gd" id="1_yqhf5"]
[resource]
script = ExtResource("1_yqhf5")

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="PrecociousMutation" load_steps=2 format=3 uid="uid://c3am7s5bjy8qk"]
[ext_resource type="Script" uid="uid://cx5mg5vf62bia" path="res://entities/plants/scripts/plant_mutation/precocious_mutation.gd" id="1_wjcm0"]
[resource]
script = ExtResource("1_wjcm0")
metadata/_custom_type_script = "uid://cx5mg5vf62bia"

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="QualityMutation" load_steps=2 format=3 uid="uid://uabbkvg1rciq"]
[ext_resource type="Script" uid="uid://bdobyk2j625lb" path="res://entities/plants/scripts/plant_mutation/quality_mutation.gd" id="1_u0ku1"]
[resource]
script = ExtResource("1_u0ku1")
metadata/_custom_type_script = "uid://bdobyk2j625lb"

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="QuickMutation" load_steps=2 format=3 uid="uid://b04gaipu237sx"]
[ext_resource type="Script" uid="uid://bhtq0cbrgu58v" path="res://entities/plants/scripts/plant_mutation/quick_mutation.gd" id="1_hr7tm"]
[resource]
script = ExtResource("1_hr7tm")
metadata/_custom_type_script = "uid://bhtq0cbrgu58v"

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="SociableMutation" load_steps=2 format=3 uid="uid://bpkvdvael2ojh"]
[ext_resource type="Script" uid="uid://b8q5xgvy85qeb" path="res://entities/plants/scripts/plant_mutation/sociable_mutation.gd" id="1_7u0mw"]
[resource]
script = ExtResource("1_7u0mw")
metadata/_custom_type_script = "uid://b8q5xgvy85qeb"

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="StrongMutation" load_steps=2 format=3 uid="uid://co2r0jnkf8hyb"]
[ext_resource type="Script" uid="uid://cwj3k4p6ci5t4" path="res://entities/plants/scripts/plant_mutation/strong_mutation.gd" id="1_c0ieg"]
[resource]
script = ExtResource("1_c0ieg")
metadata/_custom_type_script = "uid://cwj3k4p6ci5t4"

View File

@@ -1,15 +1,18 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=8 format=3 uid="uid://cxrc5wchpqm18"]
[gd_resource type="Resource" script_class="PlantType" load_steps=10 format=3 uid="uid://cxrc5wchpqm18"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="1_cf34j"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_ipcpv"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_l2hi3"]
[ext_resource type="Texture2D" uid="uid://dmsls8siudy1u" path="res://entities/plants/assets/sprites/champ/growing.png" id="2_l2hi3"]
[ext_resource type="Texture2D" uid="uid://crc4aop6ajiau" path="res://entities/plants/assets/sprites/champ/mature.png" id="3_y8qve"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_liopn"]
[sub_resource type="Resource" id="Resource_5hyy8"]
[sub_resource type="Resource" id="Resource_l2hi3"]
script = ExtResource("1_cf34j")
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="Resource" id="Resource_cf34j"]
script = ExtResource("1_cf34j")
produce_types_path = Array[String](["uid://cxrc5wchpqm18", "uid://b04vho33bl52b", "uid://dsctivn1vrem2", "uid://c5oxxif3h5yxo"])
produce_number = Array[int]([1, 0])
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
@@ -19,11 +22,11 @@ region = Rect2(610, 315, 124, 180)
[resource]
script = ExtResource("1_ipcpv")
name = "Champ"
description = "When mature, can produce one seed every day."
growing_time = 1
description = "A cool fluorescent plant. Some say that it has a big network of roots underground."
default_growing_time = 3
seed_texture = SubResource("AtlasTexture_my6by")
growing_texture = ExtResource("2_l2hi3")
mature_texture = ExtResource("3_y8qve")
cyclic_effect = SubResource("Resource_5hyy8")
harvest_types_path = Array[String](["uid://cxrc5wchpqm18"])
default_harvest_effects = Array[ExtResource("1_l2hi3")]([SubResource("Resource_cf34j"), null])
default_cyclic_effects = Array[ExtResource("1_l2hi3")]([SubResource("Resource_l2hi3")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,14 +1,20 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=8 format=3 uid="uid://b04vho33bl52b"]
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://b04vho33bl52b"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_40c3e"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_moyj3"]
[ext_resource type="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/chardi/growing.png" id="1_prk5s"]
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_cky1j"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_prk5s"]
[ext_resource type="Texture2D" uid="uid://bupl1y0cfj21q" path="res://entities/plants/assets/sprites/chardi/mature.png" id="3_40c3e"]
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="3_ajihu"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_cky1j"]
[sub_resource type="Resource" id="Resource_c76qk"]
script = ExtResource("2_cky1j")
improve_by_lifetime_max = 300
[sub_resource type="Resource" id="Resource_40c3e"]
script = ExtResource("2_prk5s")
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="Resource" id="Resource_k7yib"]
script = ExtResource("3_ajihu")
level = 1
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
@@ -19,11 +25,9 @@ region = Rect2(1140, 345, 141, 128)
script = ExtResource("1_moyj3")
name = "Chardi"
description = "This plant remove a lot of contamination around when it becomes mature."
growing_time = 1
seed_texture = SubResource("AtlasTexture_qt76e")
growing_texture = ExtResource("1_prk5s")
mature_texture = ExtResource("3_40c3e")
mature_effect = SubResource("Resource_c76qk")
harvest_types_path = Array[String](["uid://b04vho33bl52b"])
harvest_number = Array[int]([1, 2, 1])
default_harvest_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_40c3e")])
default_mature_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_k7yib")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,15 +1,16 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=8 format=3 uid="uid://dsctivn1vrem2"]
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://dsctivn1vrem2"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_740j2"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_eqtut"]
[ext_resource type="Texture2D" uid="uid://dwr3c6r6piwaa" path="res://entities/plants/assets/sprites/maias/growing.png" id="1_vyplc"]
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_vyplc"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_740j2"]
[ext_resource type="Texture2D" uid="uid://d3apfwbqsg5ha" path="res://entities/plants/assets/sprites/maias/mature.png" id="3_pi4ie"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_mwrj8"]
[sub_resource type="Resource" id="Resource_q4pje"]
script = ExtResource("2_vyplc")
impact_radius = 20
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
[sub_resource type="Resource" id="Resource_1llfc"]
script = ExtResource("2_740j2")
level = 2
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3b"]
atlas = ExtResource("6_mwrj8")
@@ -18,12 +19,9 @@ region = Rect2(1697, 331, 125, 158)
[resource]
script = ExtResource("1_eqtut")
name = "Maias"
description = "This gorgeous flower produce a lot of seeds of Maias and Chardi when harvested."
growing_time = 1
description = "This gorgeous flower produce a lot of seeds when harvested."
seed_texture = SubResource("AtlasTexture_sri3b")
growing_texture = ExtResource("1_vyplc")
mature_texture = ExtResource("3_pi4ie")
mature_effect = SubResource("Resource_q4pje")
harvest_types_path = Array[String](["uid://b04vho33bl52b", "uid://dsctivn1vrem2"])
harvest_number = Array[int]([3, 4])
default_harvest_effects = Array[ExtResource("1_740j2")]([SubResource("Resource_1llfc")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,18 +1,22 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=8 format=3 uid="uid://c5oxxif3h5yxo"]
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://c5oxxif3h5yxo"]
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="1_8wi4i"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_8fstu"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_vn146"]
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_8fstu"]
[ext_resource type="Texture2D" uid="uid://xw47qw12d3dv" path="res://entities/plants/assets/sprites/pili/growing.png" id="2_k4b1k"]
[ext_resource type="Texture2D" uid="uid://4mh1w1f4q2sa" path="res://entities/plants/assets/sprites/pili/mature.png" id="3_8fstu"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="3_26e4l"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="5_26e4l"]
[sub_resource type="Resource" id="Resource_eytxu"]
script = ExtResource("1_8wi4i")
impact_radius = 50
improve_by_lifetime = true
improve_by_lifetime_value = 50
script = ExtResource("2_8fstu")
level = 2
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
[sub_resource type="Resource" id="Resource_kidty"]
script = ExtResource("3_26e4l")
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_kidty"]
atlas = ExtResource("5_26e4l")
region = Rect2(1415, 91, 149, 102)
@@ -21,10 +25,11 @@ region = Rect2(1415, 91, 149, 102)
script = ExtResource("1_vn146")
name = "Pili"
description = "Pili slowly decontaminate each day when mature. Effect end in four days."
growing_time = 1
default_growing_time = 4
default_plant_score = 2
seed_texture = SubResource("AtlasTexture_kidty")
growing_texture = ExtResource("2_k4b1k")
mature_texture = ExtResource("3_8fstu")
cyclic_effect = SubResource("Resource_eytxu")
harvest_types_path = Array[String](["uid://c5oxxif3h5yxo"])
default_harvest_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_kidty"), null])
default_cyclic_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_eytxu")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,10 +1,15 @@
extends InspectableEntity
class_name Plant
const PLANT_AREA_WIDTH = 20
const PLANT_AREA_RADIUS = 20
const PLANT_INFLUENCE_RADIUS = 100
const HARVESTED_SEED_DISPLACEMENT_FACTOR = 100
const RANDOM_MAX_GROW_INTERVAL = Planet.PASS_DAY_ANIMATION_TIME/2. - 0.1
const PLANT_POINT_ICON = preload("res://common/icons/growth.svg")
const LIFETIME_ICON = preload("res://common/icons/calendar-week.svg")
const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")
@@ -18,82 +23,167 @@ var state: State = State.PLANTED: set = change_state
@onready var plant_sprite: PlantSprite = generate_sprite()
@onready var collision_shape: CollisionShape2D = generate_collision_shape()
@onready var influence_zone : PlantInfluenceZone = generate_influence_zone()
func _init(_plant_type = null, _planet = null):
var harvest_effects = []
var mature_effects = []
var cyclic_effects = []
var plant_score = 0
var plant_mutations : Array[PlantMutation] = []
func _init(
_plant_type : PlantType,
_planet : Planet,
_plant_mutations : Array[PlantMutation] = []
):
plant_type = _plant_type
harvest_effects = plant_type.default_harvest_effects.duplicate_deep()
mature_effects = plant_type.default_mature_effects.duplicate_deep()
cyclic_effects = plant_type.default_cyclic_effects.duplicate_deep()
planet = _planet
plant_mutations = _plant_mutations
func pointer_text():
var state_text = "Growing"
if state == State.MATURE: state_text = "Mature"
return state_text + " " + plant_type.name
func inspect(is_inspected : bool = true):
modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
influence_zone.show_influence = is_inspected
func inspector_info() -> Inspector.Info:
return Inspector.Info.new(
var info = Inspector.Info.new(
pointer_text(),
plant_type.description,
"",
plant_type.mature_texture
)
for m in plant_mutations:
info.framed_infos.append(
PlantMutation.get_framed_info_from_mutation(m)
)
info.framed_infos.append_array(
PlantEffect.get_framed_info_from_all_trigger_effects(
mature_effects, harvest_effects, cyclic_effects
)
)
info.stat_infos.append(
Inspector.StatInfo.new(
"Day [b]%d[/b]" % day,
LIFETIME_ICON
)
)
if state != State.MATURE:
info.stat_infos.append_array([
Inspector.StatInfo.new(
"Mature on day [b]%d[/b]" % calculate_grow_time(),
GROWING_ICON,
),
Inspector.StatInfo.new(
"[b]%d[/b]" % [
calculate_plant_score()
],
PLANT_POINT_ICON
),
])
else:
info.stat_infos.append(
Inspector.StatInfo.new(
"[b]%d[/b] point%s" % [
calculate_plant_score(),
"s" if calculate_plant_score() > 0 else ""
],
PLANT_POINT_ICON
),
)
return info
func generate_sprite() -> PlantSprite:
var spriteObject : PlantSprite = SPRITE_SCENE.instantiate()
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
add_child(spriteObject)
spriteObject.update_plant_sprite(self)
add_child(sprite_object)
sprite_object.update_plant_sprite(self)
sprite_object.generate_mutation_effects(self)
return spriteObject
return sprite_object
func generate_collision_shape() -> CollisionShape2D:
var collision = CollisionShape2D.new()
var shape = CircleShape2D.new()
shape.radius = PLANT_AREA_WIDTH
shape.radius = PLANT_AREA_RADIUS
collision.shape = shape
add_child(collision)
return collision
func generate_influence_zone() -> PlantInfluenceZone:
var zone = PlantInfluenceZone.new(PLANT_INFLUENCE_RADIUS)
add_child(zone)
return zone
# Méthode déclenchée par la classe planet
func _pass_day():
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
if state == State.MATURE and plant_type.cyclic_effect:
plant_type.cyclic_effect.effect(self)
if state == State.MATURE and len(cyclic_effects):
for effect in cyclic_effects:
effect.effect(self)
day += 1
func set_day(d):
day = d
if day == 0:
change_state(State.PLANTED)
if day > plant_type.growing_time:
if day + 1 > calculate_grow_time():
if state != State.MATURE:
change_state(State.MATURE)
elif day == 0:
change_state(State.PLANTED)
else:
if state != State.GROWING:
change_state(State.GROWING)
func calculate_plant_score() -> int:
var mutated_plant_score = plant_type.default_plant_score if state == State.MATURE else 0
for m in plant_mutations:
mutated_plant_score = m.mutate_score(self, mutated_plant_score)
return mutated_plant_score
func calculate_grow_time() -> int:
var mutated_grow_time = plant_type.default_growing_time
for m in plant_mutations:
mutated_grow_time = m.mutate_grow_time(self, mutated_grow_time)
return mutated_grow_time
func change_state(_state: State):
state = _state
if state == State.MATURE and plant_type.mature_effect:
plant_type.mature_effect.effect(self)
if state == State.MATURE and len(mature_effects):
for effect in mature_effects:
if effect : effect.effect(self)
for effect in cyclic_effects:
if effect : effect.effect(self)
plant_sprite.update_plant_sprite(self, true)
func harvest():
if state == State.MATURE:
var seed_number = plant_type.harvest_number.pick_random()
for i in range(seed_number):
var seed_plant_type : PlantType = plant_type
if len(plant_type.harvest_types_path):
seed_plant_type = load(plant_type.harvest_types_path.pick_random())
planet.drop_item(
Seed.new(seed_plant_type),
global_position,
HARVESTED_SEED_DISPLACEMENT_FACTOR,
)
for effect in harvest_effects:
if effect : effect.effect(self)
plant_sprite.start_harvest_animation()
await plant_sprite.harvest_animation_finished
queue_free()

View File

@@ -2,6 +2,87 @@
extends Resource
class_name PlantEffect
func effect(plant):
printerr("Classe abstraite PlantEffect appelée")
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
@export var level : int
func _init(_level : int = 1):
level = _level
func get_effect_name() -> String:
printerr("Classe abstraite PlantEffect appelée")
return ""
func get_effect_description() -> String:
printerr("Classe abstraite PlantEffect appelée")
return ""
func effect(plant):
printerr("Classe abstraite PlantEffect appelée")
static func get_framed_info_from_effects(
effects : Array[PlantEffect],
trigger_text = "",
trigger_icon: Texture = null
) -> Array[Inspector.FramedInfo]:
if len(effects) == 0 : return []
var desc = "%s %s" % [PlantEffect.get_framed_info_effect_name(effects[0]), effects[0].get_effect_description()]
for i in range(1, len(effects)):
if effects[i]:
desc += "\n%s %s" % [PlantEffect.get_framed_info_effect_name(effects[i]), effects[i].get_effect_description()]
return [Inspector.FramedInfo.new(
trigger_text,
desc,
trigger_icon
)]
static func get_framed_info_effect_name(e : PlantEffect):
var levels_bbcode = [
"[color=#ffffff][b]%s[/b][/color]",
"[color=#FFBE0B][b]%s %d[/b][/color]",
"[color=#FB5607][b]%s %d[/b][/color]",
"[color=#3A86FF][b]%s %d[/b][/color]",
"[color=#8338EC][b]%s %d[/b][/color]",
"[color=#FF006E][b]%s %d[/b][/color]",
"[rainbow][b]%s %d[/b][/rainbow]"
]
if e.level == 1:
return levels_bbcode[0] % e.get_effect_name()
else :
return levels_bbcode[min(e.level - 1, len(levels_bbcode) - 1)] % [e.get_effect_name(), e.level]
static func get_framed_info_from_all_trigger_effects(
mature_effects : Array[PlantEffect],
harvest_effects : Array[PlantEffect],
cyclic_effects : Array[PlantEffect],
) -> Array[Inspector.FramedInfo] :
var framed_infos : Array[Inspector.FramedInfo] = []
framed_infos.append_array(
PlantEffect.get_framed_info_from_effects(
mature_effects,
"On maturation",
MATURE_EFFECT_ICON
)
)
framed_infos.append_array(
PlantEffect.get_framed_info_from_effects(
harvest_effects,
"When harvested",
HARVEST_EFFECT_ICON
)
)
framed_infos.append_array(
PlantEffect.get_framed_info_from_effects(
cyclic_effects,
"Each days",
CYCLIC_EFFECT_ICON
)
)
return framed_infos

View File

@@ -1,17 +1,18 @@
extends PlantEffect
class_name DecontaminateTerrainEffect
@export var impact_radius = 100
@export var improve_by_lifetime := false
@export var improve_by_lifetime_value := 20
@export var improve_by_lifetime_max := 200
func get_decontamination_radius():
return 100 * level
func get_effect_name() -> String:
return "Decontaminate"
func get_effect_description() -> String:
var ret = "Decontaminate %d unit around it" % [get_decontamination_radius()]
return ret
func effect(plant):
var radius = impact_radius
if improve_by_lifetime:
radius = min(radius + improve_by_lifetime_value * plant.day, improve_by_lifetime_max)
var radius = get_decontamination_radius()
plant.planet.impact_contamination(
plant.global_position,

View File

@@ -1,15 +1,29 @@
extends PlantEffect
class_name ProduceSeedsEffect
@export_file var produce_types_path : Array[String] = []
@export var produce_number : Array[int] = [1]
func get_produce_number():
return [level - 1, level, level + 1]
func get_effect_name() -> String:
return "Seed Production"
func get_effect_description() -> String:
var number_str = ""
for i in range(len(get_produce_number())):
if i != 0:
if i == len(get_produce_number()) - 1:
number_str += " or "
else :
number_str += ", "
number_str += str(get_produce_number()[i])
return "Produce %s seeds" % [number_str]
func effect(plant):
for _i in range(produce_number.pick_random()):
if len(produce_types_path):
var seed_plant_type = load(produce_types_path.pick_random())
plant.planet.drop_item(
Seed.new(seed_plant_type),
plant.global_position,
plant.HARVESTED_SEED_DISPLACEMENT_FACTOR,
)
for _i in range(get_produce_number().pick_random()):
plant.planet.drop_item(
Seed.new(plant.plant_type, plant.plant_mutations),
plant.global_position,
plant.HARVESTED_SEED_DISPLACEMENT_FACTOR,
)

View File

@@ -0,0 +1,31 @@
extends Area2D
class_name PlantInfluenceZone
var radius : int
var sprite : Circle
var collision_shape : CollisionShape2D
var show_influence : bool = false :
set(v):
show_influence = v
if sprite:
sprite.visible = v
print(sprite.visible)
func _init(_radius = 100):
radius = _radius
func _ready():
sprite = Circle.new()
# sprite.z_index = 100
sprite.radius = 100
sprite.fill = false
sprite.width = 1
sprite.opacity = 0.2
sprite.visible = show_influence
add_child(sprite)
collision_shape = CollisionShape2D.new()
var circle_shape : CircleShape2D = CircleShape2D.new()
circle_shape.radius = radius
collision_shape.shape = circle_shape
add_child(collision_shape)

View File

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

View File

@@ -0,0 +1,111 @@
extends Resource
class_name PlantMutation
const BASE_RARITY_CHANCE : Array[float] = [
0.6,
0.8,
0.9,
0.95,
1
]
@export var level : int = 1
func _init(_level : int = 1):
level = _level
func get_icon() -> Texture:
return preload("res://common/icons/dna.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
printerr("Classe abstraite PlantMutation appelée")
return ""
func get_mutation_description() -> String:
printerr("Classe abstraite PlantMutation appelée")
return ""
func mutate_score(_plant : Plant, score) -> int:
return score
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
return grow_time
func mutate_plant(_plant : Plant):
pass
func get_level_for_rarity(rarity : int) -> int :
return rarity - get_base_rarity() + 1
static func get_rarity(mutation : PlantMutation) -> int:
return mutation.get_base_rarity() + mutation.level - 1
static func get_rarity_text(mutation : PlantMutation) -> String:
var rarity_text : Array[String] = [
"Common",
"Rare",
"Very rare",
"Impossible",
"Absurd",
]
var rarity = PlantMutation.get_rarity(mutation)
if rarity < len(rarity_text):
return rarity_text[rarity]
else :
return rarity_text[len(rarity_text) - 1] + " " + str(rarity - len(rarity_text) + 2)
static func get_rarity_bg_color(mutation : PlantMutation) -> Color:
var rarity_colors : Array[Color] = [
Color("4b3700"),
Color("6d2300"),
Color("001f50"),
Color("311558"),
Color("780235"),
]
return rarity_colors[min(PlantMutation.get_rarity(mutation), len(rarity_colors) - 1)]
static func get_rarity_color(mutation : PlantMutation) -> Color:
var rarity_colors : Array[Color] = [
Color("FFBE0B"),
Color("FB5607"),
Color("3A86FF"),
Color("8338EC"),
Color("FF006E"),
]
return rarity_colors[min(PlantMutation.get_rarity(mutation), len(rarity_colors) - 1)]
static func get_framed_info_from_mutation(
mutation : PlantMutation
) -> Inspector.FramedInfo:
return Inspector.FramedInfo.new(
mutation.get_mutation_name() + (" %d" % mutation.level if mutation.level > 1 else ""),
"[b]%s[/b] %s" % [PlantMutation.get_rarity_text(mutation), mutation.get_mutation_description()],
mutation.get_icon(),
PlantMutation.get_rarity_bg_color(mutation)
)
static func random_rarity() -> int:
var random_float = randf()
for i in range(len(BASE_RARITY_CHANCE) - 1):
if random_float < BASE_RARITY_CHANCE[i]:
return i
return len(BASE_RARITY_CHANCE) - 1
static func random_mutation(rarity = PlantMutation.random_rarity()) -> PlantMutation:
var all_mutations = GameInfo.game_data.unlocked_plant_mutations.duplicate_deep()
all_mutations.shuffle()
for new_mutation in all_mutations:
var level_for_rarity = new_mutation.get_level_for_rarity(rarity)
if level_for_rarity >= 1:
new_mutation.level = level_for_rarity
return new_mutation
return null

View File

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

View File

@@ -0,0 +1,23 @@
extends PlantMutation
class_name AncientMutation
const DEFAULT_DAY_FACTOR = 5
func get_icon() -> Texture:
return preload("res://common/icons/wood.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Ancient"
func get_mutation_description() -> String:
return "Add [b]1[/b] to the score for each [b]%d[/b] days passed" % get_day_factor()
func get_day_factor():
return max(1, DEFAULT_DAY_FACTOR - level + 1)
func mutate_score(plant : Plant, score) -> int:
return score + floori(plant.day / get_day_factor())

View File

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

View File

@@ -0,0 +1,26 @@
extends PlantMutation
class_name ElitistMutation
func get_icon() -> Texture:
return preload("res://common/icons/copy.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Intolerant"
func get_mutation_description() -> String:
return "Add [b]%d[/b] to the score for each plant of the same species around, but score become 0 if none is around." % level
func mutate_score(plant : Plant, score) -> int:
var plant_count = 0
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant and area.plant_type.name == plant.plant_type.name:
plant_count += 1
if plant_count == 0:
return 0
else :
return score + level * plant_count

View File

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

View File

@@ -0,0 +1,21 @@
extends PlantMutation
class_name ErmitMutation
func get_icon() -> Texture:
return preload("res://common/icons/seedling-off.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Ermit"
func get_mutation_description() -> String:
return "Multiply the score by %d if no plant is near, but set it to 0 otherwise." % level
func mutate_score(plant : Plant, score) -> int:
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant:
return 0
return score * 2

View File

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

View File

@@ -0,0 +1,17 @@
extends PlantMutation
class_name PrecociousMutation
func get_icon() -> Texture:
return preload("res://common/icons/hourglass-empty.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Precocious"
func get_mutation_description() -> String:
return "Add [b]%d[/b] to the score while the plant is growing" % level
func mutate_score(plant : Plant, score) -> int:
return score + (0 if plant.state == Plant.State.MATURE else level)

View File

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

View File

@@ -0,0 +1,17 @@
extends PlantMutation
class_name QualityMutation
func get_icon() -> Texture:
return preload("res://common/icons/north-star.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Quality"
func get_mutation_description() -> String:
return "Add [b]%d[/b] to the score if the plant is mature." % level
func mutate_score(plant : Plant, score : int) -> int:
return score + (level if plant.state == Plant.State.MATURE else 0)

View File

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

View File

@@ -0,0 +1,17 @@
extends PlantMutation
class_name QuickMutation
func get_icon() -> Texture:
return preload("res://common/icons/chevrons-up.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Quick"
func get_mutation_description() -> String:
return "Reduce the grow time by %d" % level
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
return max(grow_time - level, 0)

View File

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

View File

@@ -0,0 +1,28 @@
extends PlantMutation
class_name SociableMutation
const NEAR_PLANT_NEEDED = 2
func get_icon() -> Texture:
return preload("res://common/icons/seedling.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Sociable"
func get_mutation_description() -> String:
return "Add [b]%d[/b] to the score if near %d other plants" % [get_score_bonus(), NEAR_PLANT_NEEDED]
func get_score_bonus():
return (level + 2)
func mutate_score(plant : Plant, score) -> int:
var plant_count = 0
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant:
plant_count += 1
return score + (get_score_bonus() if plant_count >= NEAR_PLANT_NEEDED else 0)

View File

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

View File

@@ -0,0 +1,20 @@
extends PlantMutation
class_name StrongMutation
func get_icon() -> Texture:
return preload("res://common/icons/dna.svg")
func get_base_rarity() -> int:
return 0
func get_mutation_name() -> String:
return "Strong"
func get_mutation_description() -> String:
return "Plus [b]%d[/b] percent of the score" % roundi(get_score_multiplier() * 100)
func get_score_multiplier():
return float(level)/2.
func mutate_score(_plant : Plant, score: int) -> int:
return score + roundi(score * get_score_multiplier())

View File

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

View File

@@ -2,7 +2,9 @@ extends Node2D
class_name PlantSprite
const PLANTED_SEED_CROP_WIDTH = 50
const PLANTED_SEED_POS_Y = -50
const PLANTED_SEED_POS_Y = 0
const PARTICLES_SCENE : PackedScene = preload("res://common/vfx/particles/particles.tscn")
signal harvest_animation_finished
@@ -35,6 +37,16 @@ func get_state_texture(s: Plant.State, plant_type : PlantType) -> Texture2D:
return plant_type.mature_texture
return null
func generate_mutation_effects(plant : Plant):
for m in plant.plant_mutations:
var particles_emitter : Particles = PARTICLES_SCENE.instantiate() as CPUParticles2D
particles_emitter.setup_particles(
Particles.Parameters.new(
m.get_icon(),
PlantMutation.get_rarity_color(m)
)
)
add_child(particles_emitter)
func start_harvest_animation():
$AnimationPlayer.play("harvest")

View File

@@ -4,14 +4,13 @@ class_name PlantType
@export var name : String
@export_multiline var description : String
@export var growing_time : int
@export var default_growing_time : int = 2
@export var default_plant_score : int = 1
@export var seed_texture : Texture
@export var growing_texture : Texture
@export var mature_texture : Texture
@export var mature_effect : PlantEffect
@export var cyclic_effect : PlantEffect
@export_file var harvest_types_path : Array[String] = []
@export var harvest_number : Array[int] = [1,2]
@export var default_harvest_effects : Array[PlantEffect] = []
@export var default_mature_effects : Array[PlantEffect] = []
@export var default_cyclic_effects : Array[PlantEffect] = []

View File

@@ -27,8 +27,8 @@ var energy : int = max_energy :
player_updated.emit(self)
@onready var inventory : Inventory = Inventory.new(DEFAULT_INVENTORY_SIZE)
@onready var preview_zone : Area2D = null
@onready var action_zone : Area2D = null
@onready var preview_zone : ActionZone = null
@onready var action_zone : ActionZone = null
func _ready():
player_updated.emit(self)
@@ -126,9 +126,9 @@ func try_move(move_to : Vector2):
func pick_item(item : Item) -> Item:
play_sfx("pick")
if inventory.length() >= inventory.size:
var currentItem : Item = inventory.get_item()
var current_item : Item = inventory.get_item()
inventory.set_item(item, inventory.current_item_ind)
return currentItem
return current_item
else :
inventory.add_item(item)
return null
@@ -153,7 +153,7 @@ func try_use_item(item : Item, use_position : Vector2):
func preview_can_use_item(item : Item) -> bool:
return can_use_item_on_zone(item, preview_zone)
func can_use_item_on_zone(item : Item, zone: Area2D) -> bool:
func can_use_item_on_zone(item : Item, zone: ActionZone) -> bool:
return (
inventory.has_item(item)
and (energy - item.energy_usage) >= 0
@@ -185,43 +185,29 @@ func recharge(amount : int = max_energy):
func full_recharge():
energy = max(energy, max_energy)
func generate_action_zone(radius : int = 0) -> Area2D:
var area2D = Area2D.new()
var collision_shape = CollisionShape2D.new()
var circle_shape = CircleShape2D.new()
func generate_action_zone(radius : int = 0) -> ActionZone:
var zone = ActionZone.new(radius)
circle_shape.radius = radius
collision_shape.shape = circle_shape
area2D.add_child(collision_shape)
get_parent().add_child(zone.area)
get_parent().add_child(area2D)
return zone
return area2D
func setup_preview_zone(zone_radius : int) -> Area2D:
func setup_preview_zone(zone_radius : int) -> ActionZone:
if preview_zone:
preview_zone.queue_free()
preview_zone.destroy()
preview_zone = generate_action_zone(zone_radius)
return preview_zone
func setup_action_zone(zone_position : Vector2, zone_radius : int) -> Area2D:
func setup_action_zone(zone_position : Vector2, zone_radius : int) -> ActionZone:
if action_zone:
action_zone.queue_free()
action_zone.destroy()
action_zone = generate_action_zone(zone_radius)
action_zone.global_position = zone_position
action_zone.area.global_position = zone_position
return action_zone
func move_preview_zone(zone_position : Vector2):
if preview_zone:
preview_zone.global_position = zone_position
func detect_area_in_preview_zone() -> Array:
return preview_zone.get_overlapping_areas()
func detect_area_in_action_zone() -> Array:
if action_zone:
return action_zone.get_overlapping_areas()
return []
preview_zone.move_to_position(zone_position)
func play_sfx(sound : String):
match sound:
@@ -277,3 +263,37 @@ class InteractableInstruction extends Instruction:
func do(player : Player):
interactable.interact(player)
class ActionZone:
var radius : int = 10
var area : Area2D
func _init(_r : int):
radius = _r
area = Area2D.new()
var collision_shape = CollisionShape2D.new()
var circle_shape = CircleShape2D.new()
circle_shape.radius = radius
collision_shape.shape = circle_shape
area.add_child(collision_shape)
func destroy():
area.queue_free()
func get_global_position() -> Vector2:
return Vector2.ZERO if area == null else area.global_position
func move_to_position(pos : Vector2):
if area:
area.global_position = pos
func get_points_in_zone(point_factor = 10) -> Array[Vector2]:
var points : Array[Vector2] = []
for x in range(-radius, radius, point_factor):
for y in range(-radius, radius, point_factor):
if Vector2(x, y).length() <= radius:
points.append(area.global_position + Vector2(x, y))
return points