#58 ajout d'un item package servant à déployer des machines

This commit is contained in:
2025-09-05 17:01:59 +02:00
parent 165a4d129b
commit 18b48f5320
29 changed files with 149 additions and 62 deletions

View File

@@ -1,4 +1,3 @@
@tool
extends Interactable
class_name ItemObject
@@ -20,6 +19,9 @@ func _init(_item = null):
func _ready():
generate_collision(ITEM_AREA_WIDTH)
if item and object_sprite:
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
func inspected_text():
return item.name + (" Seed" if item is Seed else "")

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://f2rte5jc0psp"
path="res://.godot/imported/compost.svg-503fc2423ba701b15edd51da5ab01164.ctex"
path="res://.godot/imported/compost.svg-f43ad0f7b40754d19aa7d5ea88e80cb8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/compost/assets/sprites/compost.svg"
dest_files=["res://.godot/imported/compost.svg-503fc2423ba701b15edd51da5ab01164.ctex"]
source_file="res://entities/interactables/machines/compost/assets/sprites/compost.svg"
dest_files=["res://.godot/imported/compost.svg-f43ad0f7b40754d19aa7d5ea88e80cb8.ctex"]
[params]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=10 format=3 uid="uid://bkwh1ntvgkkrt"]
[ext_resource type="Script" uid="uid://dw6jgsasb2fe1" path="res://entities/interactables/compost/scripts/compost.gd" id="1_1758a"]
[ext_resource type="Texture2D" uid="uid://f2rte5jc0psp" path="res://entities/interactables/compost/assets/sprites/compost.svg" id="2_r6435"]
[ext_resource type="Script" uid="uid://dw6jgsasb2fe1" path="res://entities/interactables/machines/compost/scripts/compost.gd" id="1_c0pig"]
[ext_resource type="Texture2D" uid="uid://f2rte5jc0psp" path="res://entities/interactables/machines/compost/assets/sprites/compost.svg" id="2_r6435"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_etofw"]
bg_color = Color(0.260098, 0.11665, 0.0419712, 0.231373)
@@ -17,9 +17,6 @@ corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="RectangleShape2D" id="RectangleShape2D_coj8m"]
size = Vector2(77, 92)
[sub_resource type="Animation" id="Animation_r6435"]
length = 0.001
tracks/0/type = "value"
@@ -98,8 +95,11 @@ _data = {
&"fill": SubResource("Animation_etofw")
}
[sub_resource type="RectangleShape2D" id="RectangleShape2D_akkx7"]
size = Vector2(66, 84)
[node name="Compost" type="Area2D"]
script = ExtResource("1_1758a")
script = ExtResource("1_c0pig")
[node name="Compost" type="Sprite2D" parent="."]
modulate = Color(0.615686, 0.501961, 0.270588, 1)
@@ -114,16 +114,13 @@ offset_right = 62.0
offset_bottom = 120.0
theme_override_styles/background = SubResource("StyleBoxFlat_etofw")
theme_override_styles/fill = SubResource("StyleBoxFlat_3ao1n")
value = 20.0
fill_mode = 3
show_percentage = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(-0.5, 2)
shape = SubResource("RectangleShape2D_coj8m")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_etofw")
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_akkx7")

View File

@@ -1,10 +1,8 @@
extends Interactable
extends Machine
class_name Compost
@export var value_per_seed : float = 0.5
@onready var fill_value : float = 0.
var value_per_seed : float = 0.5
var fill_value : float = 0.
func _process(_delta):
%ProgressBar.value = lerp(%ProgressBar.value, fill_value * 100, 0.5)
@@ -13,7 +11,7 @@ func inspected_text():
return "Compost"
func interact_text():
return "Put a seed"
return "Put a seed ("+str(roundi((1-fill_value)/value_per_seed))+" left)"
func can_interact(p : Player) -> bool:
return p.inventory.get_item() and p.inventory.get_item() is Seed

View File

@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://cjo6ea86rfqbe"
path="res://.godot/imported/compost_level_up.wav-d796efae9b651b45ecdda95fd157999a.sample"
path="res://.godot/imported/compost_level_up.wav-18f25f0720265f21705081af070ef8cd.sample"
[deps]
source_file="res://entities/interactables/compost/sounds/compost_level_up.wav"
dest_files=["res://.godot/imported/compost_level_up.wav-d796efae9b651b45ecdda95fd157999a.sample"]
source_file="res://entities/interactables/machines/compost/sounds/compost_level_up.wav"
dest_files=["res://.godot/imported/compost_level_up.wav-18f25f0720265f21705081af070ef8cd.sample"]
[params]

View File

@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://c82ljr3in67am"
path="res://.godot/imported/recharge_station.svg-e388da7bbc5335a093731cd3d5c6eb67.ctex"
path="res://.godot/imported/recharge_station.svg-b4dbe96f287bff2995b6160acd3f32ff.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://entities/interactables/recharge_station/assets/sprites/recharge_station.svg"
dest_files=["res://.godot/imported/recharge_station.svg-e388da7bbc5335a093731cd3d5c6eb67.ctex"]
source_file="res://entities/interactables/machines/recharge_station/assets/sprites/recharge_station.svg"
dest_files=["res://.godot/imported/recharge_station.svg-b4dbe96f287bff2995b6160acd3f32ff.ctex"]
[params]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://d324mlmgls4fs"]
[ext_resource type="Script" uid="uid://bsrn3gd2a532q" path="res://entities/interactables/recharge_station/scripts/recharge_station.gd" id="1_2ffjo"]
[ext_resource type="Texture2D" uid="uid://c82ljr3in67am" path="res://entities/interactables/recharge_station/assets/sprites/recharge_station.svg" id="2_58ax0"]
[ext_resource type="Script" uid="uid://bsrn3gd2a532q" path="res://entities/interactables/machines/recharge_station/scripts/recharge_station.gd" id="1_2ffjo"]
[ext_resource type="Texture2D" uid="uid://c82ljr3in67am" path="res://entities/interactables/machines/recharge_station/assets/sprites/recharge_station.svg" id="2_58ax0"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bjhct"]
radius = 15.0

View File

@@ -1,4 +1,4 @@
extends Interactable
extends Machine
class_name RechargeStation
var planet : Planet # mis à jour par la classe Planet

View File

@@ -0,0 +1,2 @@
extends Interactable
class_name Machine

View File

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

View File

@@ -6,11 +6,14 @@ var available : bool = true
func can_interact(_p : Player) -> bool:
return true
func interaction_cost(_p : Player) -> int:
return 0
func interact(_p : Player) -> bool:
printerr("Interact function called on abstract Interactable class")
return false
func generate_collision(area_width : float):
func generate_collision(area_width : float) -> CollisionShape2D:
var collision = CollisionShape2D.new()
var collision_shape = CircleShape2D.new()
collision_shape.radius = area_width
@@ -18,5 +21,7 @@ func generate_collision(area_width : float):
collision.shape = collision_shape
add_child(collision)
return collision
func interact_text():
return ""