changement du scene manager, amélioration du cockpit et autres

* refonte du scene manager
* refonte du audio manager
* premier rework des plantes
* nettoyage des dossiers/fichiers
* renommage de planète en region
* fix des run
This commit is contained in:
2026-01-23 18:06:27 +01:00
parent 62b34473b6
commit 83d462f2f4
247 changed files with 2964 additions and 3159 deletions

View File

@@ -6,71 +6,71 @@ const ITEM_SPRITE_SIZE = 40.
const SPRITE_SCENE : PackedScene = preload("res://entities/interactables/item_object/item_object_sprite.tscn")
@export var item : Item :
set(_item):
item = _item
if object_sprite:
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
object_sprite.generate_particles(item.get_particles())
set(_item):
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()
func _init(_item = null):
if _item:
item = _item
if _item:
item = _item
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())
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() -> String:
var name_suffix = ""
var name_suffix = ""
if item is Seed:
name_suffix = tr("SEED")
if item is Package:
name_suffix = tr("PACKAGE")
if item is Seed:
name_suffix = tr("SEED")
if item is Package:
name_suffix = tr("PACKAGE")
return item.name + (" " + name_suffix if name_suffix else "")
return item.name + (" " + name_suffix if name_suffix else "")
func interact_text():
return tr("TAKE")
return tr("TAKE")
func card_info() -> CardInfo:
return item.card_info()
return item.card_info()
func interact(player : Player) -> bool:
player.pick_item(item)
pickup_animation(player)
return true
player.pick_item(item)
pickup_animation(player)
return true
func pickup_animation(player : Player):
available = false
var tween : Tween = get_tree().create_tween()
available = false
var tween : Tween = get_tree().create_tween()
tween.tween_property(self, "position", player.position, 0.2)
tween.tween_callback(
func():
Pointer.stop_inspect(self)
queue_free()
)
if object_sprite:
object_sprite.pickup_animation()
tween.tween_property(self, "position", player.position, 0.2)
tween.tween_callback(
func():
Pointer.stop_inspect(self)
queue_free()
)
if object_sprite:
object_sprite.pickup_animation()
func generate_sprite() -> ItemObjectSprite:
var sprite_node = SPRITE_SCENE.instantiate() as ItemObjectSprite
add_child(sprite_node)
var sprite_node = SPRITE_SCENE.instantiate() as ItemObjectSprite
add_child(sprite_node)
if item:
sprite_node.apply_texture_to_sprite(
item.icon,
ITEM_SPRITE_SIZE
)
if item:
sprite_node.apply_texture_to_sprite(
item.icon,
ITEM_SPRITE_SIZE
)
return sprite_node
return sprite_node
func save() -> EntityData:
return ItemObjectData.new(self)
return ItemObjectData.new(self)

View File

@@ -7,5 +7,5 @@ func _init(e : ItemObject):
position = e.global_position
item = e.item
func load() -> Entity:
func load_entity() -> Entity:
return ItemObject.new(item)

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dlrj7tyi5wfh8"
path="res://.godot/imported/truck_ladder.png-00d93dc49c0cc6457febb75d7b82dec4.ctex"
path="res://.godot/imported/truck_ladder.png-925870bf5fd0f6bfe7226189e1ff2e75.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/truck/assets/sprites/truck_ladder.png"
dest_files=["res://.godot/imported/truck_ladder.png-00d93dc49c0cc6457febb75d7b82dec4.ctex"]
source_file="res://entities/interactables/ladder/assets/truck_ladder.png"
dest_files=["res://.godot/imported/truck_ladder.png-925870bf5fd0f6bfe7226189e1ff2e75.ctex"]
[params]

View File

@@ -0,0 +1,170 @@
[gd_scene load_steps=12 format=3 uid="uid://cg1visg52i21a"]
[ext_resource type="Script" uid="uid://buimaomxu01wj" path="res://entities/interactables/ladder/scripts/ladder.gd" id="1_26qdk"]
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/ladder/assets/truck_ladder.png" id="2_xila4"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="3_214ms"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hslnw"]
radius = 26.0
height = 112.0
[sub_resource type="AtlasTexture" id="AtlasTexture_gmirm"]
atlas = ExtResource("2_xila4")
region = Rect2(205, 157, 87, 208)
[sub_resource type="Animation" id="Animation_4ixvu"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1, 1)]
}
[sub_resource type="Animation" id="Animation_214ms"]
resource_name = "Pulse"
length = 0.8
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.4, 0.8),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector2(1, 1), Vector2(1.4, 1.4), Vector2(1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_px7p1"]
_data = {
&"Pulse": SubResource("Animation_214ms"),
&"RESET": SubResource("Animation_4ixvu")
}
[sub_resource type="Animation" id="Animation_bgoyn"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("TruckLadder:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(-1.25, -30)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Icon:self_modulate:a")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0.0]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("TruckLadder:modulate:a")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_xvoyd"]
resource_name = "appear"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("TruckLadder:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.7),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, -108), Vector2(-1.25, -30)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Icon:self_modulate:a")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.6666667, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 1.0]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("TruckLadder:modulate:a")
tracks/2/interp = 2
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 1.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_orxxj"]
_data = {
&"RESET": SubResource("Animation_bgoyn"),
&"appear": SubResource("Animation_xvoyd")
}
[node name="Ladder" type="Area2D"]
script = ExtResource("1_26qdk")
default_interact_text = "ENTER_TRUCK"
default_info_title = "TRUCK_ENTRANCE"
default_info_desc = "LADDER_DESC_TEXT"
metadata/_custom_type_script = "uid://dyprcd68fjstf"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-0.25, -28)
shape = SubResource("CapsuleShape2D_hslnw")
[node name="TruckLadder" type="Sprite2D" parent="."]
modulate = Color(1, 1, 1, 0)
position = Vector2(-1.25, -30)
scale = Vector2(0.5, 0.5)
texture = SubResource("AtlasTexture_gmirm")
[node name="Icon" type="Sprite2D" parent="."]
self_modulate = Color(1, 1, 1, 0)
position = Vector2(0.75, -29.000004)
texture = ExtResource("3_214ms")
[node name="IconAnimationPlayer" type="AnimationPlayer" parent="Icon"]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_px7p1")
}
autoplay = "RESET"
[node name="LadderAnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_orxxj")
}

View File

@@ -0,0 +1,20 @@
extends Interactable
class_name Ladder
func _ready():
appear()
# hide()
GameInfo.game_data.current_region_data.updated.connect(
func (region_data : RegionData):
if region_data.get_state() == RegionData.State.SUCCEEDED or region_data.get_state() == RegionData.State.FAILED:
%IconAnimationPlayer.play("Pulse")
)
func appear():
show()
%LadderAnimationPlayer.play("appear")
func interact(p : Player):
p.region.save()
SceneManager.change_scene("COCKPIT")
return true

View File

@@ -1,27 +0,0 @@
extends Interactable
class_name Machine
const MAX_MACHINE_LEVEL = 3
var level : int = 1
var type : MachineType
func pointer_text() -> String:
return type.name
static func get_level_color(l : int) -> Color:
match l:
1: return Color("4ed38a")
2: return Color("4ec6ee")
3: return Color("bd70e2")
_: return Color("bd70e2")
static func instantiate_machine(machine_type : MachineType, machine_level = 1) -> Machine:
var new_machine : Machine = machine_type.scene.instantiate() as Machine
new_machine.level = machine_level
new_machine.type = machine_type
return new_machine
func save() -> EntityData:
return MachineData.new(self)

View File

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

View File

@@ -1,13 +0,0 @@
extends EntityData
class_name MachineData
@export var level : int
@export var type : MachineType
func _init(m : Machine):
position = m.global_position
level = m.level
type = m.type
func load() -> Entity:
return Machine.instantiate_machine(type, level)

View File

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

View File

@@ -1,6 +0,0 @@
extends Resource
class_name MachineType
@export var name : String
@export var scene : PackedScene
@export_multiline var description : String

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c22re5wfsm1ax"
path="res://.godot/imported/panneau_solaire_3.png-022ae039aa352e1519471d4f9c114a8b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_3.png"
dest_files=["res://.godot/imported/panneau_solaire_3.png-022ae039aa352e1519471d4f9c114a8b.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,90 +0,0 @@
extends Machine
class_name SolarPanel
const ENERGY_ICON = preload("res://common/icons/bolt.svg")
var charged : bool = false
var recharge_days : int = 0
func get_days_to_recharge(l : int = level) -> int:
match l:
1: return 2
2: return 2
3: return 2
_: return 1
func get_energy_production(l : int = level) -> int:
match l:
1: return 1
2: return 2
3: return 3
_: return 1
# Méthode déclenchée par la classe planet
func _pass_day():
if not charged:
recharge_days += 1
if recharge_days >= get_days_to_recharge():
set_charged(true)
func set_charged(_charged = true, with_anim : bool = true):
charged = _charged
recharge_days = 0
if with_anim:
if charged:
%AnimationPlayer.play("charged")
else :
%AnimationPlayer.play_backwards("charged")
await %AnimationPlayer.animation_finished
%Flair.modulate = Color.WHITE if charged else Color.TRANSPARENT
%Pannels.modulate = Color.WHITE if charged else Color("6c6c6c")
func card_info() -> CardInfo:
var info = CardInfo.new(
pointer_text()
)
if default_info_desc != "":
var desc_section = CardSectionInfo.new(
tr("DESCRIPTION"),
default_info_desc
)
desc_section.title_icon = DESC_ICON
info.sections.append(
desc_section
)
var charged_text = tr("CHARGED")
if not charged and (get_days_to_recharge() - recharge_days) == 1:
charged_text = tr("1_DAY_BEFORE_CHARGE")
elif not charged and (get_days_to_recharge() - recharge_days) > 1:
charged_text = tr("%d_DAYS_BEFORE_CHARGE") % (get_days_to_recharge() - recharge_days)
info.stats.append(
CardStatInfo.new(
charged_text,
ENERGY_ICON
)
)
return info
func setup_machine_sprite():
# %Base.self_modulate = Machine.get_level_color(level)
pass
func interact_text():
return tr("RECHARGE_%d_ENERGY") % get_energy_production()
func can_interact(_p : Player) -> bool:
return charged
func interact(p : Player) -> bool:
p.recharge(get_energy_production())
set_charged(false)
return true
func save() -> EntityData:
return SolarPanelData.new(self)

View File

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

View File

@@ -1,19 +0,0 @@
extends MachineData
class_name SolarPanelData
@export var charged : bool = false
@export var recharge_days : int = 0
func _init(m : SolarPanel):
position = m.global_position
level = m.level
type = m.type
charged = m.charged
recharge_days = m.recharge_days
func load() -> Entity:
var sp = Machine.instantiate_machine(type, level) as SolarPanel
sp.set_charged(charged, false)
sp.recharge_days = recharge_days
return sp

View File

@@ -1,11 +0,0 @@
[gd_resource type="Resource" script_class="MachineType" load_steps=3 format=3 uid="uid://dew3p4fffjryo"]
[ext_resource type="Script" uid="uid://bepx311a3f0o" path="res://entities/interactables/machines/scripts/machine_type.gd" id="1_ctita"]
[ext_resource type="PackedScene" uid="uid://gwq2oos6ljyp" path="res://entities/interactables/machines/solar_pannel/solar_pannel.tscn" id="1_naexs"]
[resource]
script = ExtResource("1_ctita")
name = "SOLAR_PANNEL"
scene = ExtResource("1_naexs")
description = "SOLAR_PANNEL_DESCRIPTION_TEXT"
metadata/_custom_type_script = "uid://bepx311a3f0o"

View File

@@ -1,104 +0,0 @@
[gd_scene load_steps=9 format=3 uid="uid://gwq2oos6ljyp"]
[ext_resource type="Script" uid="uid://bjy8gc0eyl2ss" path="res://entities/interactables/machines/solar_pannel/scripts/solar_pannel.gd" id="1_t4vnu"]
[ext_resource type="Texture2D" uid="uid://b1n8nad43usw4" path="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_2.png" id="2_ny3sb"]
[ext_resource type="Texture2D" uid="uid://cqqlkm14lawpa" path="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_1.png" id="3_bml32"]
[ext_resource type="Texture2D" uid="uid://c22re5wfsm1ax" path="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_3.png" id="4_ob8kj"]
[sub_resource type="CircleShape2D" id="CircleShape2D_6utw7"]
radius = 48.0
[sub_resource type="Animation" id="Animation_77hon"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprites/Pannels:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(0.42352942, 0.42352942, 0.42352942, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprites/Flair:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 0)]
}
[sub_resource type="Animation" id="Animation_gal8b"]
resource_name = "charged"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprites/Pannels:modulate")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.033333335, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(0.42365062, 0.42365065, 0.42365062, 1), Color(1, 1, 1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprites/Flair:modulate")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5vw1f"]
_data = {
&"RESET": SubResource("Animation_77hon"),
&"charged": SubResource("Animation_gal8b")
}
[node name="SolarPannel" type="Area2D"]
script = ExtResource("1_t4vnu")
default_interact_text = "USE"
default_info_title = "SOLAR_PANNEL"
default_info_desc = "SOLAR_PANNEL_DESCRIPTION_TEXT"
metadata/_custom_type_script = "uid://du7qppxobx5nd"
[node name="Sprites" type="Node2D" parent="."]
position = Vector2(15.999999, -16.999998)
scale = Vector2(0.09, 0.09)
[node name="Pannels" type="Sprite2D" parent="Sprites"]
unique_name_in_owner = true
modulate = Color(0.42352942, 0.42352942, 0.42352942, 1)
texture = ExtResource("2_ny3sb")
[node name="Base" type="Sprite2D" parent="Sprites"]
unique_name_in_owner = true
texture = ExtResource("3_bml32")
[node name="Flair" type="Sprite2D" parent="Sprites"]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0)
texture = ExtResource("4_ob8kj")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(6, -23)
shape = SubResource("CircleShape2D_6utw7")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_5vw1f")
}

View File

@@ -1,7 +0,0 @@
extends Interactable
class_name TruckLadder
func interact(p : Player):
p.planet.save()
SceneManager.change_scene(SceneManager.COCKPIT_SCENE)
return true

View File

@@ -1,33 +0,0 @@
[gd_scene load_steps=6 format=3 uid="uid://cg1visg52i21a"]
[ext_resource type="Script" uid="uid://buimaomxu01wj" path="res://entities/interactables/truck/ladder/scripts/truck_ladder.gd" id="1_26qdk"]
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/truck/assets/sprites/truck_ladder.png" id="2_xila4"]
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="3_214ms"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hslnw"]
radius = 26.0
height = 112.0
[sub_resource type="AtlasTexture" id="AtlasTexture_gmirm"]
atlas = ExtResource("2_xila4")
region = Rect2(205, 157, 87, 208)
[node name="TruckLadder" type="Area2D"]
script = ExtResource("1_26qdk")
default_interact_text = "ENTER_TRUCK"
default_info_title = "TRUCK_ENTRANCE"
default_info_desc = "LADDER_DESC_TEXT"
metadata/_custom_type_script = "uid://dyprcd68fjstf"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-0.25, -28)
shape = SubResource("CapsuleShape2D_hslnw")
[node name="TruckLadder" type="Sprite2D" parent="."]
position = Vector2(-1.25, -30)
scale = Vector2(0.5, 0.5)
texture = SubResource("AtlasTexture_gmirm")
[node name="Bolt" type="Sprite2D" parent="."]
position = Vector2(0.75, -29.000004)
texture = ExtResource("3_214ms")

View File

@@ -1,20 +1,24 @@
extends Interactable
class_name TruckRecharge
func _ready():
if region:
%Bolt.modulate = Color.WHITE if region.data.charges > 0 else Color.RED
func can_interact(_p : Player) -> bool:
return (
planet != null
and planet.data
and planet.data.charges > 0
region != null
and region.data
and region.data.charges > 0
)
func interact(_p: Player) -> bool:
if can_interact(_p):
planet.data.charges -= 1
planet.pass_day()
region.data.charges -= 1
region.pass_day()
%Bolt.modulate = Color.WHITE if planet.data.charges > 0 else Color.RED
%Bolt.modulate = Color.WHITE if region.data.charges > 0 else Color.RED
return true
return false

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://d324mlmgls4fs"]
[ext_resource type="Script" uid="uid://bsrn3gd2a532q" path="res://entities/interactables/truck/recharge/scripts/truck_recharge.gd" id="1_ipgcv"]
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/truck/assets/sprites/truck_ladder.png" id="2_87dtp"]
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/ladder/assets/truck_ladder.png" id="2_87dtp"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_jcfmm"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bjhct"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cqqlkm14lawpa"
path="res://.godot/imported/panneau_solaire_1.png-b9a4049f295152380ed394a82c03b8e2.ctex"
uid="uid://b0kllgnpxuh54"
path="res://.godot/imported/dead.png-ef8b87be14a560f3ce6b4050f956f227.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_1.png"
dest_files=["res://.godot/imported/panneau_solaire_1.png-b9a4049f295152380ed394a82c03b8e2.ctex"]
source_file="res://entities/plants/assets/sprites/default/dead.png"
dest_files=["res://.godot/imported/dead.png-ef8b87be14a560f3ce6b4050f956f227.ctex"]
[params]

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://c00jac2jlgdfu"
path="res://.godot/imported/growing.png-47abe743f83ddd7bdc16b98f9d66692f.ctex"
path="res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/plants/assets/sprites/solita/growing.png"
dest_files=["res://.godot/imported/growing.png-47abe743f83ddd7bdc16b98f9d66692f.ctex"]
source_file="res://entities/plants/assets/sprites/default/growing.png"
dest_files=["res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"]
[params]

View File

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 169 KiB

View File

@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b3wom2xu26g43"
path="res://.godot/imported/mature.png-834a1cd5820fc22805f96d5019fd7c30.ctex"
path="res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/plants/assets/sprites/solita/mature.png"
dest_files=["res://.godot/imported/mature.png-834a1cd5820fc22805f96d5019fd7c30.ctex"]
source_file="res://entities/plants/assets/sprites/default/mature.png"
dest_files=["res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"]
[params]

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b1n8nad43usw4"
path="res://.godot/imported/panneau_solaire_2.png-479b68803815c59c599ff8c3a78ca895.ctex"
uid="uid://bruce7ds0u8i1"
path="res://.godot/imported/seed.png-634c35552c5b52a8d7f2a15b4c2c65e4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_2.png"
dest_files=["res://.godot/imported/panneau_solaire_2.png-479b68803815c59c599ff8c3a78ca895.ctex"]
source_file="res://entities/plants/assets/sprites/default/seed.png"
dest_files=["res://.godot/imported/seed.png-634c35552c5b52a8d7f2a15b4c2c65e4.ctex"]
[params]

View File

@@ -0,0 +1,6 @@
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://m48oo6cqbq37"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="1_v3qq7"]
[resource]
atlas = ExtResource("1_v3qq7")

View File

@@ -1,28 +0,0 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=9 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_cf34j"]
script = ExtResource("1_cf34j")
level = 2
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
atlas = ExtResource("6_liopn")
region = Rect2(610, 315, 124, 180)
[resource]
script = ExtResource("1_ipcpv")
name = "Champ"
description = "A cool fluorescent mushroom that reproduce very fast."
default_growing_time = 3
seed_texture = SubResource("AtlasTexture_my6by")
growing_texture = ExtResource("2_l2hi3")
mature_texture = ExtResource("3_y8qve")
mature_effects = Array[ExtResource("1_l2hi3")]([SubResource("Resource_cf34j")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,34 +0,0 @@
[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://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_40c3e"]
script = ExtResource("2_prk5s")
level = 2
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="Resource" id="Resource_ajihu"]
script = ExtResource("3_ajihu")
level = 1
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
atlas = ExtResource("6_cky1j")
region = Rect2(1140, 345, 141, 128)
[resource]
script = ExtResource("1_moyj3")
name = "Chardi"
description = "This fern use the bas component of the ground to grow."
seed_texture = SubResource("AtlasTexture_qt76e")
growing_texture = ExtResource("1_prk5s")
mature_texture = ExtResource("3_40c3e")
harvest_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_40c3e")])
mature_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_ajihu")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,33 +0,0 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://djap3rggcdf3r"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_srjq6"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_72r72"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_rb4mq"]
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="3_s6g12"]
[ext_resource type="Texture2D" uid="uid://ds1nf2876m6bh" path="res://entities/plants/assets/sprites/ferno/growing.png" id="4_5qaoo"]
[ext_resource type="Texture2D" uid="uid://bfj6wji21amgk" path="res://entities/plants/assets/sprites/ferno/mature.png" id="5_er4cp"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_0y7r8"]
[sub_resource type="Resource" id="Resource_rb4mq"]
script = ExtResource("2_rb4mq")
level = 2
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="Resource" id="Resource_s6g12"]
script = ExtResource("3_s6g12")
level = 1
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
[sub_resource type="AtlasTexture" id="AtlasTexture_g1td4"]
atlas = ExtResource("7_0y7r8")
region = Rect2(57, 620, 159, 99)
[resource]
script = ExtResource("2_72r72")
name = "Ferno"
description = "This mysterious flower emmit a strong signal in the ground when harvested."
seed_texture = SubResource("AtlasTexture_g1td4")
growing_texture = ExtResource("4_5qaoo")
mature_texture = ExtResource("5_er4cp")
harvest_effects = Array[ExtResource("1_srjq6")]([SubResource("Resource_rb4mq"), SubResource("Resource_s6g12")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,27 +0,0 @@
[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://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_740j2"]
script = ExtResource("2_740j2")
level = 3
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3b"]
atlas = ExtResource("6_mwrj8")
region = Rect2(1697, 331, 125, 158)
[resource]
script = ExtResource("1_eqtut")
name = "Maias"
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")
harvest_effects = Array[ExtResource("1_740j2")]([SubResource("Resource_740j2")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,29 +0,0 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://dr4omh4gf85hl"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_mi4ef"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_jyjjp"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_lqh06"]
[ext_resource type="Texture2D" uid="uid://dna7x371cs0tu" path="res://entities/plants/assets/sprites/philea/growing.png" id="3_n0hvm"]
[ext_resource type="Texture2D" uid="uid://bj801geprrhfu" path="res://entities/plants/assets/sprites/philea/mature.png" id="4_cafy4"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_oaspo"]
[sub_resource type="Resource" id="Resource_jyjjp"]
script = ExtResource("2_jyjjp")
level = 1
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_ogrgq"]
atlas = ExtResource("6_oaspo")
region = Rect2(322, 598, 159, 136)
[resource]
script = ExtResource("2_lqh06")
name = "Philea"
description = "A very cool shurb that glow in the night."
default_growing_time = 5
default_plant_score = 3
seed_texture = SubResource("AtlasTexture_ogrgq")
growing_texture = ExtResource("3_n0hvm")
mature_texture = ExtResource("4_cafy4")
mature_effects = Array[ExtResource("1_mi4ef")]([SubResource("Resource_jyjjp")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,35 +0,0 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://c5oxxif3h5yxo"]
[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_8fstu"]
script = ExtResource("3_26e4l")
level = 2
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="Resource" id="Resource_26e4l"]
script = ExtResource("2_8fstu")
level = 2
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
[sub_resource type="AtlasTexture" id="AtlasTexture_kidty"]
atlas = ExtResource("5_26e4l")
region = Rect2(1415, 91, 149, 102)
[resource]
script = ExtResource("1_vn146")
name = "Pili"
description = "This cool plant produce softs and warms blue flames."
default_growing_time = 3
seed_texture = SubResource("AtlasTexture_kidty")
growing_texture = ExtResource("2_k4b1k")
mature_texture = ExtResource("3_8fstu")
harvest_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_8fstu")])
mature_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_26e4l")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,29 +0,0 @@
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://cuk3hl5tkjhmg"]
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_mksys"]
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_1q5bp"]
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_x4nie"]
[ext_resource type="Texture2D" uid="uid://c00jac2jlgdfu" path="res://entities/plants/assets/sprites/solita/growing.png" id="3_j4n5p"]
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/solita/mature.png" id="4_njidq"]
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_yn0yu"]
[sub_resource type="Resource" id="Resource_j4n5p"]
script = ExtResource("2_1q5bp")
level = 2
metadata/_custom_type_script = "uid://ceqx5va1ormau"
[sub_resource type="AtlasTexture" id="AtlasTexture_auuc2"]
atlas = ExtResource("6_yn0yu")
region = Rect2(335, 74, 134, 142)
[resource]
script = ExtResource("2_x4nie")
name = "Solita"
description = "A magnificient flower that reflect the light of nearest star."
default_growing_time = 3
default_plant_score = 2
seed_texture = SubResource("AtlasTexture_auuc2")
growing_texture = ExtResource("3_j4n5p")
mature_texture = ExtResource("4_njidq")
harvest_effects = Array[ExtResource("1_mksys")]([SubResource("Resource_j4n5p")])
metadata/_custom_type_script = "uid://jnye5pe1bgqw"

View File

@@ -1,205 +1,184 @@
extends InspectableEntity
class_name Plant
signal harvested(p: Plant)
signal state_changed(p: Plant)
const PLANT_AREA_RADIUS = 20
const PLANT_INFLUENCE_RADIUS = 100
const HARVESTED_SEED_DISPLACEMENT_FACTOR = 100
const RANDOM_MAX_GROW_INTERVAL = Planet.MIN_PASS_DAY_ANIMATION_TIME/2. - 0.1
const RANDOM_MAX_GROW_INTERVAL = Region.MIN_PASS_DAY_ANIMATION_TIME/2. - 0.1
const PLANT_TYPE_ICON = preload("res://common/icons/seedling.svg")
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 DEATH_ICON = preload("res://common/icons/skull.svg")
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")
enum State {PLANTED, GROWING, MATURE}
@export var plant_type: PlantType
var state: State = State.PLANTED
@export var day: int
@export var data : PlantData
@onready var plant_sprite: PlantSprite
@onready var collision_shape: CollisionShape2D
@onready var influence_zone : PlantInfluenceZone
var plant_score = 0
var plant_mutations : Array[PlantMutation] = []
func _init(
_plant_type : PlantType,
_plant_mutations : Array[PlantMutation] = [],
_day = 0,
_data : PlantData
):
plant_type = _plant_type
day = _day
plant_mutations = _plant_mutations
data = _data
func _ready():
plant_sprite = generate_sprite()
collision_shape = generate_collision_shape()
influence_zone = generate_influence_zone()
plant_sprite = generate_sprite()
collision_shape = generate_collision_shape()
influence_zone = generate_influence_zone()
update_plant(false)
plant_sprite.update_plant_sprite(self, false)
plant_sprite.update_plant_sprite(data, false)
func pointer_text() -> String:
return plant_type.name
return data.plant_name
func inspect(is_inspected : bool = true):
plant_sprite.modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
influence_zone.show_influence = is_inspected
plant_sprite.modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
influence_zone.show_influence = is_inspected
func affect_preview(is_affected : bool = true):
plant_sprite.modulate = MODULATE_AFFECTED_COLOR if is_affected else default_modulate
plant_sprite.modulate = MODULATE_AFFECTED_COLOR if is_affected else default_modulate
func generate_sprite() -> PlantSprite:
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
add_child(sprite_object)
sprite_object.generate_mutation_effects(self)
add_child(sprite_object)
sprite_object.generate_mutation_effects(self)
return sprite_object
return sprite_object
func generate_collision_shape() -> CollisionShape2D:
var collision = CollisionShape2D.new()
var shape = CircleShape2D.new()
shape.radius = PLANT_AREA_RADIUS
var collision = CollisionShape2D.new()
var shape = CircleShape2D.new()
shape.radius = PLANT_AREA_RADIUS
collision.shape = shape
add_child(collision)
collision.shape = shape
add_child(collision)
return collision
return collision
func generate_influence_zone() -> PlantInfluenceZone:
var zone = PlantInfluenceZone.new(PLANT_INFLUENCE_RADIUS)
var zone = PlantInfluenceZone.new(PLANT_INFLUENCE_RADIUS)
add_child(zone)
add_child(zone)
return zone
return zone
# Méthode déclenchée par la classe planet
# Méthode déclenchée par la classe region
func _pass_day():
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
if state == State.MATURE and len(plant_type.cyclic_effects):
for effect in plant_type.cyclic_effects:
effect.effect(self)
var old_state = state
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
var last_state = data.get_state()
day += 1
update_plant()
data.day += 1
for m in data.mutations:
m._start_day_effect(self)
if old_state != state and state == State.MATURE:
for effect in plant_type.mature_effects:
if effect : effect.effect(self)
for effect in plant_type.cyclic_effects:
if effect : effect.effect(self)
match data.get_state():
PlantData.State.MATURE:
if last_state != PlantData.State.MATURE:
mature()
PlantData.State.DEAD:
die()
plant_sprite.update_plant_sprite(data, last_state != data.get_state())
func update_plant(with_animation : bool = true):
if day + 1 > calculate_grow_time():
if state != State.MATURE:
change_state(State.MATURE, with_animation)
elif day == 0:
change_state(State.PLANTED, with_animation)
else:
if state != State.GROWING:
change_state(State.GROWING, with_animation)
func calculate_plant_score(
overwite_state : State = state
with_state : PlantData.State = data.get_state()
) -> int:
var mutated_plant_score = plant_type.default_plant_score if overwite_state == State.MATURE else 0
for m in plant_mutations:
mutated_plant_score = m.mutate_score(overwite_state, 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 max(1, mutated_grow_time)
func change_state(_state: State, with_animation : bool = true):
if state != _state:
state = _state
plant_sprite.update_plant_sprite(self, with_animation)
state_changed.emit(self)
return data.get_score(with_state)
func harvest():
if state == State.MATURE:
for effect in plant_type.harvest_effects:
if effect : effect.effect(self)
for i in range(data.get_random_seed_income()):
produce_seed()
plant_sprite.start_harvest_animation()
await plant_sprite.harvest_animation_finished
harvested.emit(self)
queue_free()
if data.get_state() == PlantData.State.MATURE:
for m in data.mutations:
m._start_harvested_effect(self)
plant_sprite.start_harvest_animation()
await plant_sprite.harvest_animation_finished
disappear()
func produce_seed():
region.drop_item(
Seed.generate_from_parent(data),
global_position,
HARVESTED_SEED_DISPLACEMENT_FACTOR,
)
func mature():
for m in data.mutations:
m._start_maturation_effect(self)
func die():
for m in data.mutations:
m._start_dead_effect(self)
disappear()
func disappear():
data.disappear()
queue_free()
func save() -> EntityData:
return PlantData.new(self)
return data
func card_info() -> CardInfo:
var info = CardInfo.new(
pointer_text()
)
var info = CardInfo.new(
pointer_text()
)
info.important_stat_icon = PLANT_POINT_ICON
info.important_stat_text = "%d" % calculate_plant_score()
info.texture = plant_type.mature_texture
info.type_icon = PLANT_TYPE_ICON
var state = data.get_state()
var state_text = tr("MATURE")
if state != State.MATURE:
state_text = tr("GROWING")
info.important_stat_icon = PLANT_POINT_ICON
info.important_stat_text = "%d" % calculate_plant_score()
info.texture = null #TODO
info.type_icon = PLANT_TYPE_ICON
info.stats.append(CardStatInfo.new(
tr("DAY_%d") % day,
LIFETIME_ICON
))
var state_text = tr("MATURE")
if state != PlantData.State.MATURE:
state_text = tr("GROWING")
info.stats.append(CardStatInfo.new(
state_text,
PLANT_TYPE_ICON
))
info.stats.append(CardStatInfo.new(
tr("DAY_%d") % data.day,
LIFETIME_ICON
))
if state != State.MATURE:
info.stats.append(CardStatInfo.new(
tr("MATURE_ON_DAY_%d") % calculate_grow_time(),
GROWING_ICON
))
info.stats.append(CardStatInfo.new(
state_text,
PLANT_TYPE_ICON
))
info.stats.append(CardStatInfo.new(
tr("%d_SCORE_WHEN_MATURE") % calculate_plant_score(State.MATURE),
PLANT_POINT_ICON
))
if state != PlantData.State.MATURE:
info.stats.append(CardStatInfo.new(
tr("MATURE_ON_DAY_%d") % data.get_growing_time(),
GROWING_ICON
))
info.stats.append(CardStatInfo.new(
tr("%d_SCORE_WHEN_MATURE") % data.get_score(PlantData.State.MATURE),
PLANT_POINT_ICON
))
info.stats.append(CardStatInfo.new(
tr("DIE_ON_DAY_%d") % (data.get_lifetime()),
DEATH_ICON
))
if len(plant_mutations) != 0:
var rarest : int = plant_mutations.map(
func(m : PlantMutation) : return m.get_rarity()
).max()
info.bg_color = PlantMutation.get_rarity_color(rarest)
for m in plant_mutations:
info.sections.append(m.card_section())
if len(data.mutations) != 0:
var rarest : int = data.mutations.map(
func(m : PlantMutation) : return m.get_rarity()
).max()
info.bg_color = PlantMutation.get_rarity_color(rarest)
for m in data.mutations:
info.sections.append(m.card_section())
info.sections.append_array(PlantEffect.card_effect_sections(
plant_type.mature_effects,
plant_type.harvest_effects,
plant_type.cyclic_effects,
))
return info
return info

View File

@@ -0,0 +1,19 @@
@tool
extends Resource
class_name PlantArchetype
@export var archetype_name = Random.generate_random_name()
@export var texture_builder = TextureBuilder.new()
@export var plant_area_radius = 20
@export var plant_influence_radius = 100
@export var growing_time= 2
@export var lifetime = 5
@export var base_score = 1
@export var seed_number = 2
@export var seed_random_loose = 1
@export var available_mutations : Array[PlantMutation] = [
AncientMutation.new(),
PrecociousMutation.new(),
QualityMutation.new(),
QuickMutation.new()
]

View File

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

View File

@@ -1,20 +1,114 @@
extends EntityData
class_name PlantData
var plant_type : PlantType
var plant_mutations : Array[PlantMutation]
var day : int
signal updated(p : PlantData)
signal disappeared(p : PlantData)
func _init(plant : Plant):
position = plant.global_position
plant_type = plant.plant_type
plant_mutations = plant.plant_mutations
day = plant.day
enum State {PLANTED, GROWING, MATURE, DEAD}
func load() -> Entity:
var plant = Plant.new(
plant_type,
plant_mutations,
day
@export var archetype: PlantArchetype
@export var plant_name : String
@export var mutations : Array[PlantMutation]
@export var day : int :
set(v):
day = v
updated.emit(self)
@export var random_seed : int
@export var leafs = 0 # +1 score
@export var roots = 0 # +1 lifetime
func _init(
_position : Vector2,
_archetype : PlantArchetype,
_plant_name : String = Random.generate_random_name(),
_mutations : Array[PlantMutation] = [],
_day : int = 0,
_random_seed = randi()
):
position = _position
archetype = _archetype
plant_name = _plant_name
mutations = _mutations
day = _day
random_seed = _random_seed
for m in mutations:
m.mutate_plant_data(self)
static func generate_from_seed(plant_seed : Seed, plant_position : Vector2) -> PlantData:
return PlantData.new(
plant_position,
plant_seed.plant_archetype,
plant_seed.plant_name,
plant_seed.plant_mutations
)
return plant
func load_entity() -> Entity:
var plant = Plant.new(
self
)
return plant
func get_lifetime() -> int:
var lifetime = archetype.lifetime + roots
for m in mutations:
lifetime = m.mutate_lifetime(self, lifetime)
return lifetime
func get_growing_time() -> int:
var growing_time = archetype.growing_time
for m in mutations:
growing_time = m.mutate_growing_time(self, growing_time)
return growing_time
func get_score(state : State = get_state()) -> int:
var score = archetype.base_score + leafs if state == State.MATURE else 0
for m in mutations:
score = m.mutate_score(self, score)
return score
func get_state() -> State:
if day >= get_lifetime():
return State.DEAD
elif day == 0:
return State.PLANTED
elif day < archetype.growing_time:
return State.GROWING
return State.MATURE
func get_plant_texture() -> Texture:
return archetype.texture_builder.build_plant_texture(self)
func get_seed_texture():
return archetype.texture_builder.build_seed_texture(random_seed)
func get_seed_number(state = get_state()):
var seed_number = archetype.seed_number if state == State.MATURE else 0
for m in mutations:
seed_number = m.mutate_seed_number(self, seed_number)
return seed_number
func get_seed_random_loose():
var seed_random_loose = archetype.seed_random_loose
for m in mutations:
seed_random_loose = m.mutate_seed_random_loose(self, seed_random_loose)
return seed_random_loose
func get_random_seed_income():
return max(
get_seed_number() - randi_range(0, get_seed_random_loose()),
0
)
func disappear():
disappeared.emit(self)

View File

@@ -1,76 +0,0 @@
# Classe abstraite permettant de développer divers effets de plantes
extends Resource
class_name PlantEffect
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")
func get_styled_effect_name():
var levels_bbcode = [
"[color=#2364AA]%s[/color]",
"[color=#25C147]%s %d[/color]",
"[color=#8B2DFF]%s %d[/color]",
"[color=#FF006E]%s %d[/color]",
"[color=#FFA617]%s %d[/color]",
"[rainbow]%s %d[/rainbow]"
]
if level == 1:
return levels_bbcode[0] % get_effect_name()
else :
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
static func card_effect_sections(
mature_effects : Array[PlantEffect],
harvest_effects : Array[PlantEffect],
cyclic_effects : Array[PlantEffect]
) -> Array[CardSectionInfo]:
var sections : Array[CardSectionInfo] = []
var effects_category = [
mature_effects,
harvest_effects,
cyclic_effects
]
var effects_category_labels : Array[String] = [
"ON_MATURE",
"WHEN_HARVESTED",
"EACH_DAY_WHEN_MATURE",
]
var effects_category_icon : Array[Texture] = [
MATURE_EFFECT_ICON,
HARVEST_EFFECT_ICON,
CYCLIC_EFFECT_ICON,
]
for i in range(len(effects_category)):
var effects = effects_category[i]
if len(effects) > 0:
var section = CardSectionInfo.new(
effects_category_labels[i]
)
section.title_icon = effects_category_icon[i]
var effects_text : Array = effects.map(
func (e : PlantEffect): return "[b]%s[/b] %s" % [e.get_styled_effect_name() , e.get_effect_description()]
)
section.text = "\n".join(effects_text)
sections.append(section)
return sections

View File

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

View File

@@ -1,20 +0,0 @@
extends PlantEffect
class_name DecontaminateTerrainEffect
func get_decontamination_radius():
return (1 + level)
func get_effect_name() -> String:
return tr("DECONTAMINATE")
func get_effect_description() -> String:
var ret = tr("DECONTAMINATE_%d_UNIT_AROUND_IT") % [get_decontamination_radius()]
return ret
func effect(plant):
var tiles := Math.get_tiles_in_circle(
plant.global_position,
get_decontamination_radius() * Planet.TILE_SIZE + Planet.TILE_SIZE/2.
)
plant.planet.decontamination_layer.place_decontaminations(tiles, true)

View File

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

View File

@@ -1,29 +0,0 @@
extends PlantEffect
class_name ProduceSeedsEffect
func get_produce_number():
return [level - 1, level]
func get_effect_name() -> String:
return tr("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 += tr("OR")
else :
number_str += tr("COMMA")
number_str += str(get_produce_number()[i])
return tr("PRODUCE_%s_SEEDS") % [number_str]
func effect(plant):
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

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

View File

@@ -20,13 +20,37 @@ func get_mutation_description() -> String:
printerr("Classe abstraite PlantMutation appelée")
return ""
func mutate_score(_plant_state : Plant.State, _plant : Plant, score,) -> int:
func mutate_plant_data(_plant_data : PlantData):
pass
func mutate_score(_plant_data : PlantData, score : int) -> int:
return score
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
return grow_time
func mutate_lifetime(_plant_data : PlantData, lifetime : int) -> int:
return lifetime
func mutate_plant(_plant : Plant):
func mutate_growing_time(_plant_data : PlantData, growing_time : int) -> int:
return growing_time
func mutate_seed_number(_plant_data, seed_number):
return seed_number
func mutate_seed_random_loose(_plant_data, seed_random_loose):
return seed_random_loose
func _start_planted_effect(_plant : Plant):
pass
func _start_day_effect(_plant : Plant):
pass
func _start_maturation_effect(_plant : Plant):
pass
func _start_dead_effect(_plant : Plant):
pass
func _start_harvested_effect(_plant : Plant):
pass
func get_level_for_rarity(rarity : int) -> int :
@@ -70,16 +94,3 @@ static func get_rarity_color(rarity : int) -> Color:
]
return rarity_colors[min(rarity, len(rarity_colors) - 1)]
static func random_mutation(except_mutations : Array[PlantMutation] = []) -> PlantMutation:
var all_mutations = GameInfo.game_data.unlocked_plant_mutations.duplicate_deep()
all_mutations = all_mutations.filter(
func (f1 : PlantMutation):
return except_mutations.find_custom(
func (f2 : PlantMutation): return f2.get_mutation_name() == f1.get_mutation_name()
) == -1
)
if len(all_mutations):
return all_mutations.pick_random()
else :
return null

View File

@@ -18,7 +18,7 @@ func get_mutation_description() -> String:
func get_day_factor():
return max(1, DEFAULT_DAY_FACTOR - level + 1)
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
if plant_state != Plant.State.MATURE:
func mutate_score(data : PlantData, score) -> int:
if data.get_state() != PlantData.State.MATURE:
return score
return score + floori(plant.day / get_day_factor())
return score + floori(data.day / get_day_factor())

View File

@@ -1,29 +0,0 @@
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 tr("ELITIST")
func get_mutation_description() -> String:
return tr("ELITIST_EFFECT_TEXT_LEVEL_%d") % level
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
if plant.influence_zone == null:
return score
if plant_state != Plant.State.MATURE:
return score
var plant_count = 0
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant and area != 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

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

View File

@@ -1,26 +0,0 @@
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 tr("ERMIT")
func get_mutation_description() -> String:
return tr("ERMIT_EFFECT_TEXT_LEVEL_%d") % get_score_multiplier()
func get_score_multiplier():
return level + 1
func mutate_score(_plant_state : Plant.State, plant : Plant, score) -> int:
if plant.influence_zone == null:
return score
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant and area != plant:
return 0
return score * get_score_multiplier()

View File

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

View File

@@ -13,5 +13,5 @@ func get_mutation_name() -> String:
func get_mutation_description() -> String:
return tr("PRECOCIOUS_EFFECT_TEXT_LEVEL_%d") % level
func mutate_score(plant_state : Plant.State, _plant : Plant, score) -> int:
return score + (0 if plant_state == Plant.State.MATURE else level)
func mutate_score(data : PlantData, score : int) -> int:
return score + (0 if data.get_state() == PlantData.State.MATURE else level)

View File

@@ -13,5 +13,5 @@ func get_mutation_name() -> String:
func get_mutation_description() -> String:
return tr("QUALITY_EFFECT_TEXT_LEVEL_%d") % level
func mutate_score(plant_state : Plant.State, _plant : Plant, score : int) -> int:
return score + (level if plant_state == Plant.State.MATURE else 0)
func mutate_score(data : PlantData, score : int) -> int:
return score + (level if data.get_state() == PlantData.State.MATURE else 0)

View File

@@ -13,5 +13,5 @@ func get_mutation_name() -> String:
func get_mutation_description() -> String:
return tr("QUICK_EFFECT_TEXT_LEVEL_%d") % level
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
func mutate_grow_time(_data : PlantData, grow_time : int) -> int:
return max(grow_time - level, 0)

View File

@@ -1,32 +0,0 @@
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 tr("SOCIABLE")
func get_mutation_description() -> String:
return tr("SOCIABLE_EFFECT_TEXT_LEVEL_%d") % [get_score_bonus(), NEAR_PLANT_NEEDED]
func get_score_bonus():
return (level + 2)
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
if plant.influence_zone == null:
return score
if plant_state != Plant.State.MATURE:
return score
var plant_count = 0
for area in plant.influence_zone.get_overlapping_areas():
if area is Plant and area != plant :
plant_count += 1
return score + (get_score_bonus() if plant_count >= NEAR_PLANT_NEEDED else 0)

View File

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

View File

@@ -1,20 +0,0 @@
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 tr("STRONG")
func get_mutation_description() -> String:
return tr("STRONG_EFFECT_TEXT_LEVEL_%d") % [roundi(get_score_multiplier() * 100)]
func get_score_multiplier():
return float(level)/2
func mutate_score(_plant_state : Plant.State, _plant : Plant, score: int) -> int:
return score + roundi(score * get_score_multiplier())

View File

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

View File

@@ -8,47 +8,38 @@ const PARTICLES_SCENE : PackedScene = preload("res://common/vfx/particles/partic
signal harvest_animation_finished
func update_plant_sprite(plant : Plant, with_animation = false):
if with_animation:
%AnimationPlayer.play("bump")
await %AnimationPlayer.animation_finished
%Sprite.flip_h = true if randi()%2 == 0 else false
var last_updated_on_state : PlantData.State = PlantData.State.MATURE
%Sprite.texture = get_state_texture(plant.state, plant.plant_type)
func update_plant_sprite(plant_data : PlantData, with_animation = false):
if with_animation:
%AnimationPlayer.play("bump")
await %AnimationPlayer.animation_finished
%Sprite.flip_h = true if plant_data.random_seed%2 == 0 else false
%Sprite.texture = plant_data.get_plant_texture()
%PlantedSeed.visible = plant.state == Plant.State.PLANTED
%PlantedSeed.texture = plant.plant_type.seed_texture
%PlantedSeed.texture = plant_data.get_seed_texture()
%PlantedSeed.visible = plant_data.get_state() == PlantData.State.PLANTED
%PlantedSeed.region_rect = Rect2(
0,
PLANTED_SEED_POS_Y,
plant.plant_type.seed_texture.get_width(),
plant.plant_type.seed_texture.get_height() - PLANTED_SEED_CROP_WIDTH + -1 * PLANTED_SEED_POS_Y,
)
func get_state_texture(s: Plant.State, plant_type : PlantType) -> Texture2D:
match s:
Plant.State.PLANTED:
return null
Plant.State.GROWING:
return plant_type.growing_texture
Plant.State.MATURE:
return plant_type.mature_texture
return null
# %PlantedSeed.region_rect = Rect2(
# 0,
# PLANTED_SEED_POS_Y,
# %PlantedSeed.texture.get_width(),
# %PlantedSeed.texture.texture.get_height() - PLANTED_SEED_CROP_WIDTH + -1 * PLANTED_SEED_POS_Y,
# )
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.get_rarity())
)
)
add_child(particles_emitter)
for m in plant.data.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.get_rarity())
)
)
add_child(particles_emitter)
func start_harvest_animation():
$AnimationPlayer.play("harvest")
await $AnimationPlayer.animation_finished
harvest_animation_finished.emit()
$AnimationPlayer.play("harvest")
await $AnimationPlayer.animation_finished
harvest_animation_finished.emit()

View File

@@ -1,128 +0,0 @@
extends Resource
class_name PlantType
@export var name : String
@export_multiline var description : String
@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 harvest_effects : Array[PlantEffect] = []
@export var mature_effects : Array[PlantEffect] = []
@export var cyclic_effects : Array[PlantEffect] = []
func card_info() -> CardInfo:
var info = CardInfo.new(
name
)
info.important_stat_icon = Plant.PLANT_POINT_ICON
info.important_stat_text = "%d" % default_plant_score
info.texture = mature_texture
info.type_icon = Plant.PLANT_TYPE_ICON
info.stats.append(CardStatInfo.new(
tr("GROW_IN_%d") % default_growing_time,
Plant.GROWING_ICON
))
info.stats.append(CardStatInfo.new(
tr("%s_SCORE_WHEN_MATURE") % default_plant_score,
Plant.PLANT_POINT_ICON
))
info.sections.append_array(PlantEffect.card_effect_sections(
mature_effects,
harvest_effects,
cyclic_effects,
))
return info
func get_available_evolution() -> Array[Evolution]:
var evolutions : Array[Evolution] = [
ScoreEvolution.new(self)
]
if len(mature_effects) > 0:
evolutions.append(MatureEffectEvolution.new(self))
if len(harvest_effects) > 0:
evolutions.append(HarvestEffectEvolution.new(self))
if len(cyclic_effects) > 0:
evolutions.append(CyclicEffectEvolution.new(self))
return evolutions
class Evolution:
var level : int
var plant_type : PlantType
func _init(_type : PlantType, _l : int = 1):
plant_type = _type
level = _l
func get_title():
return ""
func get_description():
return ""
func evolve(_pt : PlantType = plant_type):
pass
class ScoreEvolution extends Evolution:
func get_title():
return tr("%s_SCORE_EVOLUTION") % plant_type.name
func get_description():
return tr("ADD_%s_TO_THE_DEFAULT_SCORE_OF_THE_PLANT") % level
func evolve(pt : PlantType = plant_type):
pt.default_plant_score += level
class MatureEffectEvolution extends Evolution:
var effect_index : int
func _init(_type : PlantType, _l : int = 1):
plant_type = _type
level = _l
pick_effect()
func pick_effect():
effect_index = randi() % len(plant_type.mature_effects)
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
return pt.mature_effects[effect_index]
func get_title():
return tr("%s_EVOLUTION") % plant_type.name
func get_description():
return tr("UPGRADE_THE_LEVEL_OF_%s_EFFECT_OF_%d_LEVEL") % [get_effect().get_effect_name(), level]
func evolve(pt : PlantType = plant_type):
get_effect(pt).level += level
class HarvestEffectEvolution extends MatureEffectEvolution:
func pick_effect():
effect_index = randi() % len(plant_type.harvest_effects)
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
return pt.harvest_effects[effect_index]
class CyclicEffectEvolution extends MatureEffectEvolution:
func pick_effect():
effect_index = randi() % len(plant_type.harvest_effects)
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
return pt.harvest_effects[effect_index]

View File

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

View File

@@ -0,0 +1,19 @@
extends Resource
class_name TextureBuilder
const PLACEHOLDER_SEED_TEXTURE : Texture = preload("res://entities/plants/assets/sprites/default/seed.png")
const PLACEHOLDER_MATURE_TEXTURE : Texture = preload("res://entities/plants/assets/sprites/default/mature.png")
const PLACEHOLDER_GROWING_TEXTURE : Texture = preload("res://entities/plants/assets/sprites/default/growing.png")
func build_seed_texture(_random_seed : int) -> Texture:
return PLACEHOLDER_SEED_TEXTURE
func build_plant_texture(plant_data : PlantData) -> Texture:
match plant_data.get_state():
PlantData.State.MATURE:
return PLACEHOLDER_MATURE_TEXTURE
PlantData.State.GROWING:
return PLACEHOLDER_GROWING_TEXTURE
_:
return null

View File

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

View File

@@ -6,93 +6,97 @@ signal updated(inventory: Inventory)
@export var items: Array[Item] = []
@export var current_item_ind: int = 0
@export var size = 0 :
set(s):
size = s
items.resize(size)
updated.emit(self)
set(s):
size = s
items.resize(size)
updated.emit(self)
func _init(inventory_size: int = 1):
size = inventory_size
size = inventory_size
func get_best_available_slot_ind():
if items[current_item_ind] == null:
return current_item_ind
for i in items.size():
if items[i] == null:
return i
return current_item_ind
if items[current_item_ind] == null:
return current_item_ind
for i in items.size():
if items[i] == null:
return i
return current_item_ind
func set_current_item(new_ind: int):
if new_ind >= items.size():
return
if new_ind >= items.size():
return
if new_ind != current_item_ind:
current_item_ind = new_ind
updated.emit(self)
if new_ind != current_item_ind:
current_item_ind = new_ind
updated.emit(self)
func change_current_item(ind_mod: int):
if items.size() == 0:
current_item_ind = 0
return
var new_ind: int = current_item_ind + ind_mod
new_ind = new_ind % items.size()
if new_ind < 0:
new_ind += items.size()
set_current_item(new_ind)
if items.size() == 0:
current_item_ind = 0
return
var new_ind: int = current_item_ind + ind_mod
new_ind = new_ind % items.size()
if new_ind < 0:
new_ind += items.size()
set_current_item(new_ind)
func add_item(item: Item):
var best_ind = get_best_available_slot_ind()
if best_ind != current_item_ind:
set_item(item, best_ind)
updated.emit(self)
return true
else:
return false
var best_ind = get_best_available_slot_ind()
if best_ind != current_item_ind:
set_item(item, best_ind)
updated.emit(self)
return true
else:
return false
func set_item(item: Item, ind: int = 0) -> bool:
if ind < 0 || ind >= items.size():
return false
while len(items) <= ind:
items.append(null)
items[ind] = item
updated.emit(self)
return true
if ind < 0 || ind >= items.size():
return false
while len(items) <= ind:
items.append(null)
items[ind] = item
updated.emit(self)
return true
func get_item(ind: int = current_item_ind) -> Item:
if ind < 0 || items.size() <= ind:
return null
return items[ind]
if ind < 0 || items.size() <= ind:
return null
return items[ind]
func has_item(item: Item) -> bool:
return item in items
return item in items
func remove_item(item: Item):
var ind = items.find(item)
if ind >= 0:
items[ind] = null
updated.emit(self)
var ind = items.find(item)
if ind >= 0:
items[ind] = null
updated.emit(self)
func remove_item_at(ind: int = current_item_ind):
if items.size() <= ind:
return
if items.size() <= ind:
return
items[ind] = null
updated.emit(self)
items[ind] = null
updated.emit(self)
func remove_current_item():
remove_item_at()
remove_item_at()
func pop_item(ind: int = current_item_ind) -> Item:
if items.size() == 0:
return
if items.size() == 0:
return
var item_removed: Item = items[ind]
items[ind] = null
updated.emit(self)
return item_removed
var item_removed: Item = items[ind]
items[ind] = null
updated.emit(self)
return item_removed
func is_full():
for i in items:
if i == null : return false
return true
for i in items:
if i == null : return false
return true
func clear():
for i in range(len(items)):
items[i] = null
updated.emit(self)

View File

@@ -33,11 +33,11 @@ func is_one_time_use():
return true
func can_use(player : Player, _zone : Player.ActionZone) -> bool:
return player.terrain is Planet
return player.terrain is Region
func use(player : Player, zone : Player.ActionZone) -> bool:
if machine_type and machine_level and player.planet:
player.planet.add_entity(
if machine_type and machine_level and player.region:
player.region.add_entity(
Machine.instantiate_machine(machine_type, machine_level),
zone.get_global_position()
)

View File

@@ -25,8 +25,8 @@ func is_one_time_use():
return true
func can_use(player : Player, _zone : Player.ActionZone) -> bool:
return player.planet != null
return player.region != null
func use(player : Player, zone : Player.ActionZone) -> bool:
player.planet.instantiate_entity(scene, zone.get_global_position())
player.region.instantiate_entity(scene, zone.get_global_position())
return true

View File

@@ -7,17 +7,51 @@ const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
const SCORE_ICON = preload("res://common/icons/growth.svg")
@export var plant_type: PlantType
@export var plant_name : String
@export var plant_archetype: PlantArchetype
@export var plant_mutations: Array[PlantMutation]
@export var random_seed : int
func _init(
_plant_name : String,
_plant_archetype : PlantArchetype,
_plant_mutations : Array[PlantMutation] = [],
):
plant_name = _plant_name
plant_archetype = _plant_archetype
plant_mutations = _plant_mutations
random_seed = randi()
static func generate_from_parent(plant_data : PlantData) -> Seed:
if randf() > MUTATION_PROBABILITY:
return Seed.new(
plant_data.plant_name,
plant_data.archetype,
mutate(plant_data.mutations)
)
else :
# TODO
return Seed.new(
plant_data.plant_name,
plant_data.archetype,
mutate(plant_data.mutations)
)
static func generate_random() -> Seed:
return Seed.new(
Random.generate_random_name(),
PlantArchetype.new(),
[]
)
func get_item_name() -> String:
return tr("%s_SEED") % plant_type.name
return tr("%s_SEED") % plant_name
func get_description() -> String:
return tr("PLANT_%s_MUST_BE_USED_IN_DECONTAMINATED_ZONE") % plant_type.name
return tr("PLANT_%s_MUST_BE_USED_IN_DECONTAMINATED_ZONE") % plant_name
func get_icon() -> Texture2D:
return plant_type.seed_texture
return plant_archetype.texture_builder.build_seed_texture(random_seed)
func get_energy_used() -> int:
return 1
@@ -28,22 +62,15 @@ func get_usage_zone_radius() -> int:
func get_usage_object_affected(i : InspectableEntity) -> bool:
return i is Plant
func _init(
_plant_type : PlantType = null,
_parent_mutation : Array[PlantMutation] = []
):
plant_type = _plant_type
plant_mutations = Seed.mutate(_parent_mutation)
func use_text() -> String:
return tr("PLANT_%s") % plant_type.name
return tr("PLANT_%s") % plant_name
func is_one_time_use():
return true
func can_use(player : Player, zone : Player.ActionZone) -> bool:
if (
player.planet == null
player.region == null
):
return false
@@ -54,21 +81,17 @@ func can_use(player : Player, zone : Player.ActionZone) -> bool:
var is_there_contamination_in_zone = false
for tile in zone.get_tiles():
if not player.planet.decontamination_layer.is_decontamined(tile):
if not player.region.decontamination_layer.is_decontamined(tile):
is_there_contamination_in_zone = true
return not is_there_a_plant_here and not is_there_contamination_in_zone
func use(player : Player, zone : Player.ActionZone) -> bool:
if player.planet == null:
if player.region == null:
return false
AudioManager.play_sfx("Dig")
return player.planet.plant(
plant_type,
zone.get_global_position(),
plant_mutations
)
return player.region.plant(self,zone.get_global_position())
func card_info() -> CardInfo:
var info = CardInfo.new(
@@ -113,7 +136,6 @@ func card_info() -> CardInfo:
return info
func get_particles() -> Array[Particles.Parameters]:
var param : Array[Particles.Parameters] = []
@@ -129,73 +151,67 @@ func get_particles() -> Array[Particles.Parameters]:
static func mutate(parent_mutation : Array[PlantMutation] = []) -> Array[PlantMutation]:
if randf() > MUTATION_PROBABILITY:
return parent_mutation
# TODO
# var possible_mutations_change : Array[MutationPossibility] = [
# AddMutation.new()
# ]
var possible_mutations : Array[MutationPossibility] = [
AddMutation.new()
]
if (
len(parent_mutation) >= 2
):
possible_mutations = [
UpgradeMutation.new(),
RemoveMutation.new(),
]
elif len(parent_mutation) > 0:
possible_mutations = [
AddMutation.new(),
UpgradeMutation.new(),
RemoveMutation.new(),
]
# if (
# len(parent_mutation) >= 2
# ):
# possible_mutations_change = [
# UpgradeMutation.new(),
# RemoveMutation.new(),
# ]
# elif len(parent_mutation) > 0:
# possible_mutations_change = [
# AddMutation.new(),
# UpgradeMutation.new(),
# RemoveMutation.new(),
# ]
var chosen_mutation = possible_mutations.pick_random()
# var chosen_mutation = possible_mutations_change.pick_random()
return chosen_mutation.mutate(parent_mutation)
return parent_mutation
class MutationPossibility:
func mutate(_parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
return []
# class MutationPossibility:
# func mutate(_parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
# return []
class DontMutate extends MutationPossibility:
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
return parent_mutation
# class AddMutation extends MutationPossibility:
# func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
# var new_mutations = parent_mutation.duplicate_deep()
# var mut = PlantMutation.random_mutation(parent_mutation)
class AddMutation extends MutationPossibility:
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
var new_mutations = parent_mutation.duplicate_deep()
var mut = PlantMutation.random_mutation(parent_mutation)
if mut:
var existing_mut_id = new_mutations.find_custom(func(m:PlantMutation): return m.get_mutation_name() == mut.get_mutation_name())
# if mut:
# var existing_mut_id = new_mutations.find_custom(func(m:PlantMutation): return m.get_mutation_name() == mut.get_mutation_name())
if existing_mut_id >= 0:
new_mutations[existing_mut_id].level += 1
else :
new_mutations.append(mut)
# if existing_mut_id >= 0:
# new_mutations[existing_mut_id].level += 1
# else :
# new_mutations.append(mut)
return new_mutations
# return new_mutations
class UpgradeMutation extends MutationPossibility:
func mutate(
parent_mutation : Array[PlantMutation] = []
) -> Array[PlantMutation]:
var new_mutations = parent_mutation.duplicate_deep()
# class UpgradeMutation extends MutationPossibility:
# func mutate(
# parent_mutation : Array[PlantMutation] = []
# ) -> Array[PlantMutation]:
# var new_mutations = parent_mutation.duplicate_deep()
new_mutations.pick_random().level += 1
# new_mutations.pick_random().level += 1
return new_mutations
# return new_mutations
class RemoveMutation extends MutationPossibility:
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
var new_mutations :Array[PlantMutation] = parent_mutation.duplicate_deep()
# class RemoveMutation extends MutationPossibility:
# func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
# var new_mutations :Array[PlantMutation] = parent_mutation.duplicate_deep()
var mut_to_remove = new_mutations.pick_random()
if mut_to_remove.level > 1:
mut_to_remove.level -= 1
else:
new_mutations.remove_at(new_mutations.find(mut_to_remove))
# var mut_to_remove = new_mutations.pick_random()
# if mut_to_remove.level > 1:
# mut_to_remove.level -= 1
# else:
# new_mutations.remove_at(new_mutations.find(mut_to_remove))
return new_mutations
# return new_mutations

View File

@@ -9,8 +9,8 @@ signal player_updated(player: Player)
signal upgraded
var terrain : Terrain
var planet : Planet :
get(): return terrain if terrain is Planet else null
var region : Region :
get(): return terrain if terrain is Region else null
@export var speed = 350
var data : PlayerData
@@ -42,16 +42,16 @@ func _input(_event) -> void:
if Input.is_action_pressed("item_" + str(i)):
data.inventory.set_current_item(i - 1)
# Méthode déclenchée par la classe planet
# Méthode déclenchée par la classe region
func _start_pass_day():
controlling_player = false
instruction = null
# Méthode déclenchée par la classe planet
# Méthode déclenchée par la classe region
func _pass_day():
full_recharge()
# Méthode déclenchée par la classe planet
# Méthode déclenchée par la classe region
func _end_pass_day():
controlling_player = true

View File

@@ -2,8 +2,8 @@ extends Area2D
class_name Entity
var terrain : Terrain
var planet : Planet :
get(): return terrain if terrain is Planet else null
var region : Region :
get(): return terrain if terrain is Region else null
func save() -> EntityData:
return null

View File

@@ -1,3 +1,4 @@
@abstract
extends Resource
class_name EntityData
@@ -9,5 +10,4 @@ func _init(e : Entity):
func get_position() -> Vector2:
return position
func load() -> Entity:
return null
@abstract func load_entity() -> Entity