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:
@@ -2,6 +2,7 @@ extends Area3D
|
||||
class_name Interactable3D
|
||||
|
||||
@export var interactable = true
|
||||
@export var inspectable = false
|
||||
|
||||
signal clicked
|
||||
|
||||
@@ -12,16 +13,6 @@ func click():
|
||||
if interactable:
|
||||
clicked.emit()
|
||||
|
||||
func _ready():
|
||||
if audio_player:
|
||||
var default_volume := audio_player.volume_db
|
||||
audio_player.volume_db += GameInfo.settings_data.sfx_volume
|
||||
GameInfo.settings_data.sound_changed.connect(
|
||||
func(settings : SettingsData):
|
||||
audio_player.volume_db = default_volume + settings.sfx_volume
|
||||
)
|
||||
|
||||
|
||||
func play_audio():
|
||||
if audio_player:
|
||||
audio_player.play()
|
||||
@@ -33,7 +24,14 @@ func stop_audio():
|
||||
func _on_mouse_entered():
|
||||
if hover_animation_player:
|
||||
hover_animation_player.play("hover")
|
||||
if inspectable:
|
||||
Pointer.inspect(self)
|
||||
|
||||
func _on_mouse_exited():
|
||||
if hover_animation_player:
|
||||
hover_animation_player.stop()
|
||||
if inspectable:
|
||||
Pointer.stop_inspect(self)
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
return null
|
||||
|
||||
@@ -4,6 +4,11 @@ class_name Door
|
||||
|
||||
@export var to_scene_id = ""
|
||||
@export var icon : Texture : set = set_icon
|
||||
@export var present : bool = false : set = set_present
|
||||
@export var door_id : int
|
||||
|
||||
func _init():
|
||||
default_interact_text = "ENTER"
|
||||
|
||||
func _ready():
|
||||
if available:
|
||||
@@ -11,10 +16,13 @@ func _ready():
|
||||
else:
|
||||
%AnimatedSprite2D.play("closed")
|
||||
set_icon()
|
||||
set_present()
|
||||
|
||||
func interact(_p : Player) -> bool:
|
||||
func interact(p : Player) -> bool:
|
||||
if available and to_scene_id:
|
||||
interacted.emit(_p)
|
||||
p.region.data.entered_door = name
|
||||
interacted.emit(p)
|
||||
p.region.save()
|
||||
SceneManager.change_to_scene_id(to_scene_id)
|
||||
|
||||
return available
|
||||
@@ -32,3 +40,11 @@ func set_icon(i: Texture = icon):
|
||||
icon = i
|
||||
if is_node_ready():
|
||||
%Icon.texture = icon
|
||||
|
||||
func set_present(p := present):
|
||||
present = p
|
||||
if present:
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
else:
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
visible = present
|
||||
@@ -3,19 +3,20 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cqecty3kl6yg6"
|
||||
path="res://.godot/imported/STW_Props_Batterie_V2.png-5149763f9e1dac76893ec05c148e8056.ctex"
|
||||
path.s3tc="res://.godot/imported/STW_Props_Batterie_V2.png-5149763f9e1dac76893ec05c148e8056.s3tc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/truck/recharge/STW_Props_Batterie_V2.png"
|
||||
dest_files=["res://.godot/imported/STW_Props_Batterie_V2.png-5149763f9e1dac76893ec05c148e8056.ctex"]
|
||||
dest_files=["res://.godot/imported/STW_Props_Batterie_V2.png-5149763f9e1dac76893ec05c148e8056.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
@@ -23,7 +24,7 @@ compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
@@ -37,4 +38,4 @@ 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
|
||||
detect_3d/compress_to=0
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="AncientMutation" format=3 uid="uid://dys1ehlg4kwh7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c7po0bstyg80u" path="res://entities/plants/scripts/plant_mutation/ancient_mutation.gd" id="1_5g2qg"]
|
||||
[ext_resource type="Script" uid="uid://b3jwglylqdqtw" path="res://entities/plants/scripts/texture_builder/plant_part.gd" id="1_yqbjv"]
|
||||
[ext_resource type="Resource" uid="uid://wxqxm6d5twdh" path="res://entities/plants/resources/plant_parts/Leaf8.tres" id="2_s2bpe"]
|
||||
[ext_resource type="Resource" uid="uid://uoikjpno37bi" path="res://entities/plants/resources/plant_parts/Leaf9.tres" id="3_wfusp"]
|
||||
[ext_resource type="Resource" uid="uid://c5gqwck2p5h5n" path="res://entities/plants/resources/plant_parts/Leaf10.tres" id="4_60d0x"]
|
||||
[ext_resource type="Resource" uid="uid://c5fj1cw0f4mu6" path="res://entities/plants/resources/plant_parts/Leaf11.tres" id="5_ooo8j"]
|
||||
[ext_resource type="Resource" uid="uid://dce788f0adauv" path="res://entities/plants/resources/plant_parts/Leaf12.tres" id="6_d0tr0"]
|
||||
[ext_resource type="Resource" uid="uid://dd34dikqoynp3" path="res://entities/plants/resources/plant_parts/Leaf13.tres" id="7_jsy7o"]
|
||||
[ext_resource type="Resource" uid="uid://bynje6g2wvuvl" path="res://entities/plants/resources/plant_parts/Leaf14.tres" id="8_m31fx"]
|
||||
[ext_resource type="Resource" uid="uid://bd2op6q1masjt" path="res://entities/plants/resources/plant_parts/Leaf15.tres" id="9_78ar7"]
|
||||
[ext_resource type="Resource" uid="uid://bvajuw0r47edw" path="res://entities/plants/resources/plant_parts/Leaf16.tres" id="10_dq1wt"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_5g2qg")
|
||||
possible_parts = Array[ExtResource("1_yqbjv")]([ExtResource("2_s2bpe"), ExtResource("3_wfusp"), ExtResource("4_60d0x"), ExtResource("5_ooo8j"), ExtResource("6_d0tr0"), ExtResource("7_jsy7o"), ExtResource("8_m31fx"), ExtResource("9_78ar7"), ExtResource("10_dq1wt")])
|
||||
part_amount = 3
|
||||
metadata/_custom_type_script = "uid://c7po0bstyg80u"
|
||||
@@ -1,6 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="ElitistMutation" load_steps=2 format=3 uid="uid://d38alhstybdtf"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bt1xh7ss13e5e" path="res://entities/plants/scripts/plant_mutation/elitist_mutation.gd" id="1_jevqj"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_jevqj")
|
||||
@@ -1,6 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="ErmitMutation" load_steps=2 format=3 uid="uid://dktlbpira5kxb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://domy822vgxfxs" path="res://entities/plants/scripts/plant_mutation/ermit_mutation.gd" id="1_yqhf5"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_yqhf5")
|
||||
@@ -1,7 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PrecociousMutation" format=3 uid="uid://c3am7s5bjy8qk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cx5mg5vf62bia" path="res://entities/plants/scripts/plant_mutation/precocious_mutation.gd" id="1_wjcm0"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_wjcm0")
|
||||
metadata/_custom_type_script = "uid://cx5mg5vf62bia"
|
||||
@@ -1,14 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="QualityMutation" format=3 uid="uid://uabbkvg1rciq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b3jwglylqdqtw" path="res://entities/plants/scripts/texture_builder/plant_part.gd" id="1_f2p7y"]
|
||||
[ext_resource type="Script" uid="uid://bdobyk2j625lb" path="res://entities/plants/scripts/plant_mutation/quality_mutation.gd" id="1_u0ku1"]
|
||||
[ext_resource type="Resource" uid="uid://crmvc77bqax1y" path="res://entities/plants/resources/plant_parts/Flower1.tres" id="2_1b5fn"]
|
||||
[ext_resource type="Resource" uid="uid://c0hr7icfkjkoi" path="res://entities/plants/resources/plant_parts/Flower2.tres" id="3_k2uo3"]
|
||||
[ext_resource type="Resource" uid="uid://clkoc1iccts2w" path="res://entities/plants/resources/plant_parts/Flower3.tres" id="4_ywc6r"]
|
||||
[ext_resource type="Resource" uid="uid://bd8yapi1pokj6" path="res://entities/plants/resources/plant_parts/Flower4.tres" id="5_fnfed"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_u0ku1")
|
||||
possible_parts = Array[ExtResource("1_f2p7y")]([ExtResource("2_1b5fn"), ExtResource("3_k2uo3"), ExtResource("4_ywc6r"), ExtResource("5_fnfed")])
|
||||
part_amount = 2
|
||||
metadata/_custom_type_script = "uid://bdobyk2j625lb"
|
||||
@@ -1,19 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="QuickMutation" format=3 uid="uid://b04gaipu237sx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b3jwglylqdqtw" path="res://entities/plants/scripts/texture_builder/plant_part.gd" id="1_68ssf"]
|
||||
[ext_resource type="Script" uid="uid://bhtq0cbrgu58v" path="res://entities/plants/scripts/plant_mutation/quick_mutation.gd" id="1_hr7tm"]
|
||||
[ext_resource type="Resource" uid="uid://brmd6d3l8trqs" path="res://entities/plants/resources/plant_parts/BottomLeaf1.tres" id="2_37ogi"]
|
||||
[ext_resource type="Resource" uid="uid://cfr33014u7ig5" path="res://entities/plants/resources/plant_parts/BottomLeaf2.tres" id="3_4wjrs"]
|
||||
[ext_resource type="Resource" uid="uid://cf70m1us8mfqp" path="res://entities/plants/resources/plant_parts/BottomLeaf3.tres" id="4_w4xgf"]
|
||||
[ext_resource type="Resource" uid="uid://ctlmah4ohqp25" path="res://entities/plants/resources/plant_parts/BottomLeaf4.tres" id="5_7gtu2"]
|
||||
[ext_resource type="Resource" uid="uid://b8o4q0hsm84ov" path="res://entities/plants/resources/plant_parts/BottomLeaf5.tres" id="6_yoj6x"]
|
||||
[ext_resource type="Resource" uid="uid://bb33v756anesy" path="res://entities/plants/resources/plant_parts/BottomLeaf6.tres" id="7_fuf4y"]
|
||||
[ext_resource type="Resource" uid="uid://cbqrl72y0d1yg" path="res://entities/plants/resources/plant_parts/BottomLeaf7.tres" id="8_25vee"]
|
||||
[ext_resource type="Resource" uid="uid://dwppani7gyjl5" path="res://entities/plants/resources/plant_parts/BottomLeaf8.tres" id="9_hqe0q"]
|
||||
[ext_resource type="Resource" uid="uid://dkta1u1u0efxk" path="res://entities/plants/resources/plant_parts/BottomLeaf9.tres" id="10_mxd37"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_hr7tm")
|
||||
possible_parts = Array[ExtResource("1_68ssf")]([ExtResource("2_37ogi"), ExtResource("3_4wjrs"), ExtResource("4_w4xgf"), ExtResource("5_7gtu2"), ExtResource("6_yoj6x"), ExtResource("7_fuf4y"), ExtResource("8_25vee"), ExtResource("9_hqe0q"), ExtResource("10_mxd37")])
|
||||
part_amount = 2
|
||||
metadata/_custom_type_script = "uid://bhtq0cbrgu58v"
|
||||
@@ -1,7 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="SociableMutation" load_steps=2 format=3 uid="uid://bpkvdvael2ojh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b8q5xgvy85qeb" path="res://entities/plants/scripts/plant_mutation/sociable_mutation.gd" id="1_7u0mw"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_7u0mw")
|
||||
metadata/_custom_type_script = "uid://b8q5xgvy85qeb"
|
||||
@@ -1,7 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="StrongMutation" load_steps=2 format=3 uid="uid://co2r0jnkf8hyb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cwj3k4p6ci5t4" path="res://entities/plants/scripts/plant_mutation/strong_mutation.gd" id="1_c0ieg"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_c0ieg")
|
||||
metadata/_custom_type_script = "uid://cwj3k4p6ci5t4"
|
||||
@@ -179,7 +179,7 @@ func save() -> EntityData:
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
data.plant_name,
|
||||
tr("MATURE") if data.is_mature() else tr("JUVENILE")# data.archetype.archetype_name
|
||||
tr("MATURE") if data.is_mature() else tr("JUVENILE")
|
||||
)
|
||||
|
||||
info.important_stat_icon = SCORE_ICON
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
extends Resource
|
||||
class_name PlantArchetype
|
||||
|
||||
@export var archetype_name := Random.generate_random_word()
|
||||
@export var plant_area_radius = 20
|
||||
@export var plant_influence_radius = 100
|
||||
@export var growing_time = 2
|
||||
@export var lifetime = 6
|
||||
@export var base_score = 1
|
||||
@export var seed_number = 2
|
||||
@export var seed_random_loose = 1
|
||||
@export var available_mutations: Array[PlantMutation] = [
|
||||
AncientMutation.new(),
|
||||
EphemeralMutation.new(),
|
||||
FertileMutation.new(),
|
||||
GenerousMutation.new(),
|
||||
HurriedMutation.new(),
|
||||
PrecociousMutation.new(),
|
||||
ProlificMutation.new(),
|
||||
ProtectiveMutation.new(),
|
||||
PureMutation.new(),
|
||||
PurificationMutation.new(),
|
||||
QualityMutation.new(),
|
||||
QuickMutation.new(),
|
||||
RobustMutation.new(),
|
||||
SocialMutation.new(),
|
||||
ToughMutation.new(),
|
||||
VivaciousMutation.new(),
|
||||
]
|
||||
|
||||
static func get_all() -> Array[PlantArchetype]:
|
||||
return [PlantArchetype.new()]
|
||||
|
||||
static func get_random() -> PlantArchetype:
|
||||
return get_all().pick_random()
|
||||
@@ -1 +0,0 @@
|
||||
uid://chdj832c0rrky
|
||||
@@ -7,7 +7,6 @@ signal nearby_plant_updated()
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
|
||||
@export var archetype: PlantArchetype
|
||||
@export var plant_name: String
|
||||
@export var mutations: Array[PlantMutation]
|
||||
@export var day: int:
|
||||
@@ -16,24 +15,17 @@ enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
updated.emit(self )
|
||||
@export var random_seed: int
|
||||
|
||||
@export var leafs = 0 # +1 score
|
||||
@export var roots = 0 # +1 lifetime
|
||||
|
||||
# var texture_builder: TextureBuilder = preload("res://entities/plants/scripts/texture_builder/texture_builder.tres")
|
||||
|
||||
var decontamination_area_factor = 0.
|
||||
var nearby_plants : Array[PlantData]
|
||||
|
||||
func _init(
|
||||
_position: Vector2 = Vector2.ZERO,
|
||||
_archetype: PlantArchetype = PlantArchetype.get_random(),
|
||||
_plant_name: String = Random.generate_random_word(),
|
||||
_mutations: Array[PlantMutation] = [],
|
||||
_day: int = 0,
|
||||
_random_seed = randi()
|
||||
):
|
||||
position = _position
|
||||
archetype = _archetype
|
||||
plant_name = _plant_name
|
||||
mutations = _mutations
|
||||
day = _day
|
||||
@@ -45,11 +37,13 @@ func _init(
|
||||
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
|
||||
)
|
||||
|
||||
func get_plant_info() -> RunDataPlantInfo:
|
||||
return GameInfo.game_data.current_run.plant_info
|
||||
|
||||
func load_entity() -> Entity:
|
||||
var plant = Plant.new(
|
||||
self
|
||||
@@ -57,7 +51,7 @@ func load_entity() -> Entity:
|
||||
return plant
|
||||
|
||||
func get_lifetime() -> int:
|
||||
var lifetime = archetype.lifetime + roots
|
||||
var lifetime = get_plant_info().get_lifetime()
|
||||
|
||||
for m in mutations:
|
||||
lifetime = m.mutate_lifetime(self , lifetime)
|
||||
@@ -68,7 +62,7 @@ func get_lifetime() -> int:
|
||||
return lifetime
|
||||
|
||||
func get_growing_time() -> int:
|
||||
var growing_time = archetype.growing_time
|
||||
var growing_time = get_plant_info().get_growing_time()
|
||||
|
||||
for m in mutations:
|
||||
growing_time = m.mutate_growing_time(self , growing_time)
|
||||
@@ -76,7 +70,7 @@ func get_growing_time() -> int:
|
||||
return growing_time
|
||||
|
||||
func get_score(state: State = get_state()) -> int:
|
||||
var score = archetype.base_score + leafs if state == State.MATURE else 0
|
||||
var score = get_plant_info().get_base_score() if state == State.MATURE else 0
|
||||
|
||||
var mult := 1
|
||||
|
||||
@@ -102,7 +96,7 @@ func is_mature() -> bool:
|
||||
return get_state() == State.MATURE
|
||||
|
||||
func get_seed_number(state = get_state()):
|
||||
var seed_number = archetype.seed_number if (state == State.MATURE or state == State.DEAD) else 0
|
||||
var seed_number = get_plant_info().get_seed_number() if (state == State.MATURE or state == State.DEAD) else 0
|
||||
|
||||
for m in mutations:
|
||||
seed_number = m.mutate_seed_number(self , seed_number)
|
||||
@@ -113,7 +107,7 @@ func get_seed_number(state = get_state()):
|
||||
return seed_number
|
||||
|
||||
func get_seed_random_loose():
|
||||
var seed_random_loose = archetype.seed_random_loose
|
||||
var seed_random_loose = get_plant_info().get_seed_random_loose()
|
||||
for m in mutations:
|
||||
seed_random_loose = m.mutate_seed_random_loose(self , seed_random_loose)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func generate_plants():
|
||||
elif plant_state == PlantData.State.DEAD:
|
||||
plant_data.day = plant_data.get_lifetime()
|
||||
for j in n_mutation_per_plant:
|
||||
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
||||
plant_data.mutations.append(GameInfo.game_data.progression_data.available_mutations.pick_random())
|
||||
var plant: Plant = Plant.new(plant_data)
|
||||
print(plant.data.plant_name)
|
||||
%Plants.add_child(plant)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -33,7 +33,7 @@ func _input(event):
|
||||
%Camera3D.rotate_x(-event.relative.y * MOUSE_SENSIVITY)
|
||||
%Camera3D.rotation.x = clampf($Camera3D.rotation.x, -deg_to_rad(70), deg_to_rad(70))
|
||||
query_mouse = true
|
||||
if event.is_action_pressed("action") and cockpit_action_hovered and cockpit_action_hovered:
|
||||
if event.is_action_pressed("action") and cockpit_action_hovered and cockpit_action_hovered.interactable:
|
||||
cockpit_action_hovered.click()
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ func _physics_process(delta):
|
||||
if query_mouse:
|
||||
update_mouse_hovered_cockpit_actions()
|
||||
%PointerTexture.texture = (
|
||||
POINTER_ACTION_TEXTURE if cockpit_action_hovered != null
|
||||
POINTER_ACTION_TEXTURE if cockpit_action_hovered != null and cockpit_action_hovered.interactable
|
||||
else POINTER_TEXTURE
|
||||
)
|
||||
query_mouse = false
|
||||
@@ -79,11 +79,12 @@ func update_mouse_hovered_cockpit_actions() -> void:
|
||||
query.collide_with_areas = true
|
||||
var result = space_state.intersect_ray(query)
|
||||
|
||||
if result and result.collider and result.collider is Interactable3D and result.collider.interactable:
|
||||
if cockpit_action_hovered and cockpit_action_hovered != result.collider:
|
||||
cockpit_action_hovered._on_mouse_exited()
|
||||
cockpit_action_hovered = result.collider
|
||||
cockpit_action_hovered._on_mouse_entered()
|
||||
if result and result.collider and result.collider is Interactable3D:
|
||||
if cockpit_action_hovered != result.collider:
|
||||
if cockpit_action_hovered and cockpit_action_hovered != result.collider:
|
||||
cockpit_action_hovered._on_mouse_exited()
|
||||
cockpit_action_hovered = result.collider
|
||||
cockpit_action_hovered._on_mouse_entered()
|
||||
else :
|
||||
if cockpit_action_hovered:
|
||||
cockpit_action_hovered._on_mouse_exited()
|
||||
|
||||
Reference in New Issue
Block a user