refactor du code et ajouts des quotas, avec des récompense entre chaque quota #68

This commit is contained in:
2025-09-14 19:35:43 +02:00
parent 85cd832864
commit 43bdbc3581
44 changed files with 918 additions and 339 deletions

View File

@@ -1,15 +0,0 @@
[gd_resource type="Resource" script_class="Package" load_steps=4 format=3 uid="uid://bya8sm6rm6747"]
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/icons/package.svg" id="1_lhhdv"]
[ext_resource type="Script" uid="uid://b6kubqgq0k7vj" path="res://common/inventory/scripts/items/package.gd" id="1_x02bb"]
[ext_resource type="PackedScene" uid="uid://bkwh1ntvgkkrt" path="res://entities/interactables/machines/compost/compost.tscn" id="2_uulso"]
[resource]
script = ExtResource("1_x02bb")
scene = ExtResource("2_uulso")
name = "Compost"
description = "The compost allow you to generate one energy for a certain amount of seeds."
icon = ExtResource("1_lhhdv")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://b6kubqgq0k7vj"

View File

@@ -1,13 +0,0 @@
[gd_resource type="Resource" script_class="Seed" load_steps=3 format=3 uid="uid://lrl2okkhyxmx"]
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="1_dy25s"]
[ext_resource type="Script" uid="uid://bypjcvlc15gsm" path="res://common/inventory/scripts/items/seed.gd" id="2_mgcdi"]
[resource]
script = ExtResource("2_mgcdi")
name = "Boule"
description = ""
icon = ExtResource("1_dy25s")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://bypjcvlc15gsm"

View File

@@ -1,13 +0,0 @@
[gd_resource type="Resource" script_class="Shovel" load_steps=3 format=3 uid="uid://ddqalo1k30i5x"]
[ext_resource type="Texture2D" uid="uid://bf6nw4onkhavr" path="res://common/icons/shovel.svg" id="1_7g3xd"]
[ext_resource type="Script" uid="uid://dya38x1h1uiyg" path="res://common/inventory/scripts/items/shovel.gd" id="1_28h2r"]
[resource]
script = ExtResource("1_28h2r")
name = "Shovel"
description = "Can dig burried seed, and transform mature plants to seeds."
icon = ExtResource("1_7g3xd")
use_zone_radius = 50
use_energy = 1
metadata/_custom_type_script = "uid://dya38x1h1uiyg"

View File

@@ -1,11 +0,0 @@
[gd_resource type="Resource" script_class="Item" load_steps=3 format=3 uid="uid://dbja8xm7ehw1v"]
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/icons/scuba-diving-tank.svg" id="1_sy4rh"]
[ext_resource type="Script" uid="uid://bq7admu4ahs5r" path="res://common/inventory/scripts/item.gd" id="2_aikyk"]
[resource]
script = ExtResource("2_aikyk")
name = "Water Can"
description = "Water all plants"
icon = ExtResource("1_sy4rh")
metadata/_custom_type_script = "uid://bq7admu4ahs5r"

View File

@@ -1,11 +1,26 @@
extends Resource
class_name Item
@export var name: String
@export_multiline var description: String
@export var icon: Texture2D
@export var use_zone_radius: int = 5
@export var use_energy: int = 1
var name: String : get = get_item_name
var description: String : get = get_description
var icon: Texture2D : get = get_icon
var usage_zone_radius: int = 5 : get = get_usage_zone_radius
var energy_usage : int = 1 : get = get_energy_used
func get_item_name() -> String:
return name
func get_description() -> String:
return description
func get_icon() -> Texture2D:
return icon
func get_energy_used() -> int:
return energy_usage
func get_usage_zone_radius() -> int:
return usage_zone_radius
func is_one_time_use():
return false
@@ -16,8 +31,5 @@ func can_use(_player : Player, zone: Area2D) -> bool:
func use_text() -> String:
return ""
func use_requirement_text() -> String:
return ""
func use(_player : Player, zone: Area2D):
return false

View File

@@ -0,0 +1,39 @@
extends Item
class_name Blueprint
@export var machine_type: MachineType
@export var machine_level: int = 1
func _init(_machine_type : MachineType = null, _machine_level : int = 1):
machine_type = _machine_type
machine_level = _machine_level
func get_item_name() -> String:
if machine_type:
return machine_type.name + " level " + str(machine_level)
return ""
func get_description() -> String:
if machine_type:
return machine_type.description
return ""
func get_icon() -> Texture2D:
return preload("res://common/icons/cube-3d-sphere.svg")
func use_text() -> String:
if machine_type:
return "Build " + machine_type.name
return ""
func is_one_time_use():
return true
func can_use(player : Player, zone : Area2D) -> bool:
return player.planet.is_in_base(zone.global_position)
func use(player : Player, zone : Area2D) -> bool:
if machine_type and machine_level:
player.planet.instantiate_machine(machine_type, machine_level, zone.global_position)
return true
return false

View File

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

View File

@@ -2,18 +2,30 @@ extends Item
class_name Package
@export var scene: PackedScene
@export var package_name : String
@export_multiline var package_description : String
func _init(_scene : PackedScene = null):
scene = _scene
func get_item_name() -> String:
return package_name
func get_description() -> String:
return package_description
func get_icon() -> Texture2D:
return preload("res://common/icons/package.svg")
func use_text() -> String:
return "Build " + name
return "Open"
func is_one_time_use():
return true
func can_use(player : Player, zone : Area2D) -> bool:
return player.planet.is_in_zone(zone.global_position)
return true
func use(player : Player, zone : Area2D) -> bool:
player.planet.instantiate_entity(scene, zone.global_position)

View File

@@ -1,14 +1,19 @@
@tool
extends Item
class_name Seed
@export var plant_type: PlantType :
set(v):
plant_type = v
if plant_type:
name = plant_type.name
description = plant_type.description
icon = plant_type.seed_texture
@export var plant_type: PlantType
func get_item_name() -> String:
return plant_type.name
func get_description() -> String:
return plant_type.description
func get_icon() -> Texture2D:
return plant_type.seed_texture
func get_energy_used() -> int:
return 1
func _init(_plant_type : PlantType = null):
plant_type = _plant_type

View File

@@ -2,6 +2,22 @@ extends Item
class_name Shovel
const USE_INTERVAL = 0.15
const SHOVEL_ZONE_RADIUS = 50
func get_item_name() -> String:
return "Shovel"
func get_description() -> String:
return "Can dig up buried seeds and can be used to harvest mature plants."
func get_icon() -> Texture2D:
return preload("res://common/icons/shovel.svg")
func get_energy_used() -> int:
return 1
func get_usage_zone_radius() -> int:
return SHOVEL_ZONE_RADIUS
func use_text() -> String:
return "Dig"