ajout de la porte et équilibrage des mutations

This commit is contained in:
2026-03-06 18:15:10 +01:00
parent 263f6c42a7
commit 2cd16acd6a
92 changed files with 1420 additions and 582 deletions

View File

@@ -8,6 +8,8 @@ const SEPARATOR_SIZE = 0.1
@export var inventory_item_scene: PackedScene
@export var bar: TextureRect
@export var no_tools : bool = false
@export var test_inventory : Inventory
var last_n_tools = -1
@@ -21,20 +23,26 @@ func _ready():
update(GameInfo.game_data.player_data.inventory)
func update(inventory : Inventory):
if len(inventory.items) != len(inventory_item_objects) or last_n_tools != inventory.n_tools:
var items = inventory.items
if no_tools:
items = items.slice(inventory.n_tools, len(items))
if len(items) != len(inventory_item_objects) or last_n_tools != inventory.n_tools:
create_inventory_objects(inventory)
for i in range(len(inventory.items)):
var item : Item= inventory.items[i]
for i in range(len(items)):
var item : Item= items[i]
var object : InventoryItem3D = inventory_item_objects[i]
object.item = inventory.items[i]
object.item = items[i]
if inventory.current_item_ind == i:
object.state = (
InventoryItem3D.State.TOOL if i < inventory.n_tools
else InventoryItem3D.State.ITEM
)
else:
object.state = InventoryItem3D.State.BLACK
if not no_tools:
if inventory.current_item_ind == i:
object.state = (
InventoryItem3D.State.TOOL if i < inventory.n_tools
else InventoryItem3D.State.ITEM
)
else:
object.state = InventoryItem3D.State.BLACK
func create_inventory_objects(inventory : Inventory):
@@ -44,19 +52,29 @@ func create_inventory_objects(inventory : Inventory):
inventory_item_objects = []
for i in range(len(inventory.items)):
var items = inventory.items
if no_tools:
items = items.slice(inventory.n_tools, len(items))
for i in range(len(items)):
var new_inventory_object := (inventory_item_scene.instantiate() as InventoryItem3D)
%Items3D.add_child(new_inventory_object)
new_inventory_object.position.x = -INVENTORY_OBJECT_SIZE * i
if i >= inventory.n_tools:
if i >= inventory.n_tools and not no_tools:
new_inventory_object.position.x -= SEPARATOR_SIZE
inventory_item_objects.append(new_inventory_object)
%Items3D.position.x = (
(len(inventory_item_objects) - 1) * INVENTORY_OBJECT_SIZE + SEPARATOR_SIZE
) / 2
%ItemSeparator.position.x = (
%Items3D.position.x
- (inventory.n_tools) * INVENTORY_OBJECT_SIZE
+ SEPARATOR_SIZE/2
)
%ItemSeparator.visible = not no_tools
if no_tools:
%Items3D.position.x = (
(len(inventory_item_objects) - 1) * INVENTORY_OBJECT_SIZE
) / 2
else:
%Items3D.position.x = (
(len(inventory_item_objects) - 1) * INVENTORY_OBJECT_SIZE + SEPARATOR_SIZE
) / 2
%ItemSeparator.position.x = (
%Items3D.position.x
- (inventory.n_tools) * INVENTORY_OBJECT_SIZE
+ SEPARATOR_SIZE/2
)