Dev pour la béta 1

* ajout des artefacts avec la pile et l'emplacement de graine
* affichage des artefacts dans le vaisseau sur une étagère
* ajout des distributeurs d'artefacts dans les régions
* affichage des attributs de bases de plantes dans le vaisseau
* changement de l'affichage du choix des régions
* changement des icônes du détecteur
This commit is contained in:
2026-04-10 16:16:54 +02:00
parent 84a2eafe57
commit 8062c42e7b
154 changed files with 2780 additions and 1772 deletions

View File

@@ -1,140 +1,142 @@
@tool
extends Resource
class_name Inventory
signal updated(inventory: Inventory)
signal tool_added(item: Item)
@export var items: Array[Item] = []
@export var tools: Array[Item] = []
@export var seeds: Array[Item] = []
@export var current_item_ind: int = 0 # over both tools and items
@export var n_tools: int = 0
func _init(inventory_size: int = 1):
set_size(inventory_size)
func get_n_item_slots() -> int:
return items.size() - n_tools
func set_size(new_size: int):
if new_size >= 0:
items.resize(n_tools + new_size)
updated.emit(self )
func change_size(size_mod: int):
set_size(items.size() - n_tools + size_mod)
@export var seeds_size : int :
set(v):
seeds_size = v
update_seeds_size(v)
func _init(size : int = 1):
seeds_size = size
func current_is_tool() -> bool:
return current_item_ind >= 0 && current_item_ind < n_tools
func get_best_available_slot_ind():
if !current_is_tool() && items[current_item_ind] == null:
return current_item_ind
for i in range(n_tools, items.size()):
if items[i] == null:
return i
# it's full
if !current_is_tool():
return current_item_ind
else:
return n_tools
return current_item_ind <= len(tools)
func set_current_item(new_ind: int):
if new_ind >= items.size():
return
if new_ind != current_item_ind:
current_item_ind = new_ind
updated.emit(self )
current_item_ind = new_ind % (len(tools) + len(seeds))
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)
set_current_item(current_item_ind + ind_mod)
func add_item(item: Item) -> bool:
if item.type != Item.ItemType.TOOL_ITEM:
var best_ind = get_best_available_slot_ind()
return set_item(item, best_ind)
return add_seed(item)
elif item.type == Item.ItemType.TOOL_ITEM and not has_item_with_name(item.get_item_name()):
items.insert(n_tools, item)
if current_item_ind >= n_tools:
current_item_ind += 1
n_tools += 1
tool_added.emit(item)
updated.emit(self )
add_tool(item)
return true
else:
return false
func set_item(item: Item, ind: int = 0) -> bool:
if ind < 0 || ind >= items.size():
func add_tool(tool: Item) -> bool:
if not has_item_with_name(tool.get_item_name()):
tools.append(tool)
updated.emit(self)
tool_added.emit(tool)
return true
else:
return false
items[ind] = item
updated.emit(self )
return true
func add_seed(s: Item) -> bool:
update_seeds_size()
if not is_full():
var ind = (
current_item_ind - len(tools) if current_item_ind > len(tools)
else 0
)
while seeds[ind] != null:
ind = (ind+1) % len(seeds)
seeds[ind] = s
updated.emit(self)
return true
else:
return false
func update_seeds_size(size = seeds_size):
while size > len(seeds):
seeds.append(null)
while len(seeds) > size and seeds.find(null) != -1:
seeds.pop_at(seeds.find(null))
func get_all_items() -> Array[Item]:
return tools + seeds
func get_item(ind: int = current_item_ind) -> Item:
if ind < 0 || ind > items.size():
if ind < 0 || ind > len(get_all_items()):
return null
return items[ind]
return get_all_items()[ind]
func has_item(item: Item) -> bool:
return items.has(item)
return get_all_items().has(item)
func has_item_with_name(name: String) -> bool:
var id = items.find_custom(
var id = get_all_items().find_custom(
(func (i : Item):
return i and i.get_item_name() == name)
)
return id != -1
func remove_item(item: Item):
if item.type == Item.ItemType.TOOL_ITEM:
printerr("trying to remove a tool")
func remove_tool(ind : int):
if ind != -1:
tools.pop_at(ind)
updated.emit(self)
func remove_seed(ind : int):
if ind != -1:
seeds[ind] = null
updated.emit(self)
update_seeds_size(seeds_size)
func remove_item(item: Item) -> bool:
if tools.find(item) != -1:
remove_tool(tools.find(item))
elif seeds.find(item) != -1:
remove_seed(seeds.find(item))
else:
var ind = items.find(item)
if ind >= 0:
items[ind] = null
updated.emit(self )
return false
return true
func remove_item_at(ind: int = current_item_ind):
if ind < 0 || ind > items.size():
return
func remove_item_at(ind: int = current_item_ind) -> bool:
if ind < 0 || ind > len(seeds) + len(tools):
return false
if ind < n_tools:
printerr("trying to remove a tool")
return
items[ind] = null
updated.emit(self )
if ind < len(tools):
remove_tool(ind)
else:
remove_seed(ind - len(tools))
return true
func remove_current_item():
remove_item_at()
func pop_item(ind: int = current_item_ind) -> Item:
if ind < 0 || ind > items.size():
return
if ind < 0 || ind > len(seeds) + len(tools):
return null
if ind < n_tools:
printerr("trying to remove a tool")
return
var item_removed = get_item(ind)
remove_item_at(ind)
var item_removed: Item = items[ind]
items[ind] = null
updated.emit(self )
return item_removed
func is_full():
for i in range(n_tools, items.size()):
if items[i] == null:
for i in range(len(seeds)):
if seeds[i] == null:
return false
return true
func clear_items():
for i in range(n_tools, items.size()):
items[i] = null
updated.emit(self )
func current_ind_on_tools() -> bool:
return current_item_ind < len(tools)

View File

@@ -10,18 +10,15 @@ const SCORE_ICON = preload("res://common/icons/growth.svg")
const RARITY_POOL : Array[int] = [0,0,0,0,0,0,0,1,1,1]
@export var plant_name : String
@export var plant_archetype: PlantArchetype
@export var plant_mutations: Array[PlantMutation]
@export var random_seed : int
var stored_icon : Texture
func _init(
_plant_name : String = "",
_plant_archetype : PlantArchetype = PlantArchetype.get_random(),
_plant_mutations : Array[PlantMutation] = [],
):
plant_name = _plant_name
plant_archetype = _plant_archetype
plant_mutations = _plant_mutations
random_seed = randi()
@@ -29,23 +26,18 @@ static func generate_from_parent(plant_data : PlantData) -> Seed:
if randf() < MUTATION_PROBABILITY:
return Seed.new(
plant_data.plant_name,
plant_data.archetype,
mutate_mutations(plant_data)
)
else :
return Seed.new(
plant_data.plant_name,
plant_data.archetype,
plant_data.mutations.duplicate_deep()
)
static func generate_random() -> Seed:
var archetype = PlantArchetype.get_random()
var new_seed = Seed.new(
Random.generate_random_word(),
PlantArchetype.get_random(),
[generate_first_mutation(archetype)]
[generate_first_mutation()]
)
return new_seed
@@ -142,10 +134,10 @@ func get_particles() -> Array[EffectParticles.Parameters]:
return param
static func generate_first_mutation(archetype : PlantArchetype) -> PlantMutation:
static func generate_first_mutation() -> PlantMutation:
var rarity : int = RARITY_POOL.pick_random()
var possible_mutation : PlantMutation = archetype.available_mutations.filter(
var possible_mutation : PlantMutation = GameInfo.game_data.progression_data.available_mutations.filter(
func (m : PlantMutation): return m.get_base_rarity() <= rarity
).pick_random().duplicate_deep()
@@ -162,7 +154,7 @@ static func mutate_mutations(parent : PlantData) -> Array[PlantMutation]:
]
if (
len(parent.mutations) >= GameInfo.game_data.max_mutations_by_plant
len(parent.mutations) >= GameInfo.game_data.progression_data.max_mutations_by_plant
):
mutation_possibility = [
UpgradeMutation.new(),
@@ -184,7 +176,7 @@ class MutationPossibility:
class AddMutation extends MutationPossibility:
func mutate(parent : PlantData)-> Array[PlantMutation]:
var new_mutations = parent.mutations.duplicate_deep()
var possible_new_mutations = parent.archetype.available_mutations.duplicate_deep()
var possible_new_mutations = GameInfo.game_data.progression_data.available_mutations.duplicate_deep()
possible_new_mutations = possible_new_mutations.filter(
func (m : PlantMutation):

View File

@@ -33,17 +33,17 @@ func _init(region : Region, pos : Vector2):
signals.append(
DetectorSignalIndividual.new(
(pos - e.global_position).normalized().angle(),
DOOR_ICON,
(e as Door).icon,
Color("ffa617ff")
),
)
if e is Plant:
signals.append(
DetectorSignalIndividual.new(
(pos - e.global_position).normalized().angle(),
PLANT_ICON
)
)
# if e is Plant:
# signals.append(
# DetectorSignalIndividual.new(
# (pos - e.global_position).normalized().angle(),
# PLANT_ICON
# )
# )
func _draw():
if started_time < SIGNAL_DURATION:

View File

@@ -157,8 +157,8 @@ func pick_item(item : Item):
func drop_item():
var ind_to_drop := data.inventory.current_item_ind
while (
(data.inventory.get_item(ind_to_drop) == null or ind_to_drop < data.inventory.n_tools)
and ind_to_drop < len(data.inventory.items) - 1
(data.inventory.get_item(ind_to_drop) == null or ind_to_drop < len(data.inventory.tools))
and ind_to_drop < len(data.inventory.get_all_items()) - 1
):
ind_to_drop += 1
var item_to_drop = data.inventory.pop_item(ind_to_drop)
@@ -167,10 +167,6 @@ func drop_item():
AudioManager.play_sfx("Drop")
region.save()
func delete_item(item: Item):
if !data.inventory.current_is_tool():
data.inventory.remove_item(item)
func try_use_item(item : Item, use_position : Vector2):
await setup_action_zone(use_position, item)
instruction = ItemActionInstruction.new(

View File

@@ -6,12 +6,36 @@ signal updated(player_data : PlayerData)
const DEFAULT_MAX_ENERGY = 3
const DEFAULT_INVENTORY_SIZE = 3
@export var max_energy : int = DEFAULT_MAX_ENERGY :
set(v):
max_energy = v
updated.emit(self)
@export var max_energy : int = DEFAULT_MAX_ENERGY
@export var energy : int = DEFAULT_MAX_ENERGY :
set(v):
energy = v
updated.emit(self)
@export var inventory := Inventory.new(DEFAULT_INVENTORY_SIZE)
@export var inventory := Inventory.new(DEFAULT_INVENTORY_SIZE)
func get_artefacts() -> Array[Artefact]:
if GameInfo and GameInfo.game_data and GameInfo.game_data.current_run:
return GameInfo.game_data.current_run.artefacts
return []
func _on_artefacts_updated(artefacts : Array[Artefact]):
inventory.seeds_size = calculate_inventory_size(artefacts)
max_energy = calculate_max_energy(artefacts)
updated.emit()
func calculate_max_energy(artefacts : Array[Artefact]) -> int:
var v = DEFAULT_MAX_ENERGY
for a in artefacts:
v = a.modify_player_max_energy(v)
return v
func calculate_inventory_size(artefacts : Array[Artefact]) -> int:
var v = DEFAULT_INVENTORY_SIZE
for a in artefacts:
v = a.modify_player_inventory_size(v)
return v
func clear_inventory():
inventory = Inventory.new(DEFAULT_INVENTORY_SIZE)