changement du scene manager, amélioration du cockpit et autres
* refonte du scene manager * refonte du audio manager * premier rework des plantes * nettoyage des dossiers/fichiers * renommage de planète en region * fix des run
@@ -1,12 +1,11 @@
|
||||
[gd_scene load_steps=30 format=3 uid="uid://b6hscxcrj065q"]
|
||||
[gd_scene load_steps=28 format=3 uid="uid://b6hscxcrj065q"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://2p5d6vogtn82" path="res://common/audio_manager/scripts/audio_manager.gd" id="1_0tvca"]
|
||||
[ext_resource type="AudioStream" uid="uid://dipnmlprwfo12" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_1.ogg" id="2_a4u5m"]
|
||||
[ext_resource type="AudioStream" uid="uid://bm0tdi6bd2e65" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_2.ogg" id="3_8nsyr"]
|
||||
[ext_resource type="AudioStream" uid="uid://dftxjfdqgsbd3" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_3.ogg" id="4_athui"]
|
||||
[ext_resource type="AudioStream" uid="uid://dipnmlprwfo12" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_1.ogg" id="2_tuvql"]
|
||||
[ext_resource type="AudioStream" uid="uid://dcbuhtc085q2x" path="res://common/audio_manager/assets/morceaux/niveau_v2/mines_phase_1.ogg" id="5_ajci6"]
|
||||
[ext_resource type="AudioStream" uid="uid://bqwiaek5b5q00" path="res://common/audio_manager/assets/morceaux/niveau/forest_phase_2.ogg" id="6_ldyhq"]
|
||||
[ext_resource type="AudioStream" uid="uid://d4lqhgf0lhgge" path="res://common/audio_manager/assets/morceaux/niveau/forest_phase_3.ogg" id="7_ol34x"]
|
||||
[ext_resource type="AudioStream" uid="uid://bpf6witukorka" path="res://common/audio_manager/assets/morceaux/autres/main_menu.ogg" id="7_tuvql"]
|
||||
[ext_resource type="AudioStream" uid="uid://brtjlgjqnrvcb" path="res://common/audio_manager/assets/morceaux/autres/truck_music.ogg" id="8_0e5ja"]
|
||||
[ext_resource type="AudioStream" uid="uid://bnxsnege8qq6e" path="res://common/audio_manager/assets/morceaux/niveau/forest_phase_4.ogg" id="8_ajci6"]
|
||||
[ext_resource type="AudioStream" uid="uid://dfrp66a4isnt6" path="res://common/audio_manager/assets/sfx/dig/dig_1.wav" id="9_gv65y"]
|
||||
@@ -24,15 +23,6 @@
|
||||
[ext_resource type="AudioStream" uid="uid://d1cpi438ep0ys" path="res://common/audio_manager/assets/sfx/announce/annnounce.wav" id="22_btfwx"]
|
||||
[ext_resource type="AudioStream" uid="uid://ccq04ahrwr3bv" path="res://common/audio_manager/assets/sfx/alarm/alarm.wav" id="23_fwu3w"]
|
||||
|
||||
[sub_resource type="AudioStreamSynchronized" id="AudioStreamSynchronized_i5lxw"]
|
||||
stream_count = 3
|
||||
stream_0/stream = ExtResource("2_a4u5m")
|
||||
stream_0/volume = 0.0
|
||||
stream_1/stream = ExtResource("3_8nsyr")
|
||||
stream_1/volume = -60.0
|
||||
stream_2/stream = ExtResource("4_athui")
|
||||
stream_2/volume = -60.0
|
||||
|
||||
[sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_ajci6"]
|
||||
stream_count = 4
|
||||
stream_0 = ExtResource("5_ajci6")
|
||||
@@ -66,33 +56,32 @@ streams_count = 2
|
||||
stream_0/stream = ExtResource("20_pu6t4")
|
||||
stream_1/stream = ExtResource("21_dk5s6")
|
||||
|
||||
[node name="AudioManager" type="Node" node_paths=PackedStringArray("playing_soundtracks")]
|
||||
[node name="AudioManager" type="Node"]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_0tvca")
|
||||
default_fade_time = 2.0
|
||||
garden_phases_scores = Array[int]([0, 10, 30])
|
||||
playing_soundtracks = [NodePath("Ambiance/Default")]
|
||||
|
||||
[node name="Ambiance" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Default" type="AudioStreamPlayer" parent="Ambiance"]
|
||||
[node name="Exterior" type="AudioStreamPlayer" parent="Ambiance"]
|
||||
unique_name_in_owner = true
|
||||
stream = SubResource("AudioStreamSynchronized_i5lxw")
|
||||
autoplay = true
|
||||
stream = ExtResource("2_tuvql")
|
||||
|
||||
[node name="Musics" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Planet" type="AudioStreamPlayer" parent="Musics"]
|
||||
[node name="Region" type="AudioStreamPlayer" parent="Musics"]
|
||||
unique_name_in_owner = true
|
||||
stream = SubResource("AudioStreamPlaylist_ajci6")
|
||||
autoplay = true
|
||||
|
||||
[node name="Title" type="AudioStreamPlayer" parent="Musics"]
|
||||
unique_name_in_owner = true
|
||||
stream = ExtResource("7_tuvql")
|
||||
|
||||
[node name="Truck" type="AudioStreamPlayer" parent="Musics"]
|
||||
unique_name_in_owner = true
|
||||
stream = ExtResource("8_0e5ja")
|
||||
autoplay = true
|
||||
|
||||
[node name="Sfx" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -7,132 +7,115 @@ const MAX_VOLUME = 24.
|
||||
|
||||
@export var default_fade_time = 1.0
|
||||
|
||||
@export var garden_phase = 0
|
||||
@export var garden_phases_scores : Array[int]
|
||||
|
||||
@export var playing_soundtracks : Array[AudioStreamPlayer] = []
|
||||
@export var playing_music : AudioStreamPlayer = null
|
||||
@export var playing_ambiance : AudioStreamPlayer = null
|
||||
|
||||
var default_volumes := {}
|
||||
|
||||
func _ready():
|
||||
GameInfo.game_data.current_planet_data_updated.connect(_on_current_planet_data_updated)
|
||||
fetch_default_volumes()
|
||||
setup_volume()
|
||||
settings.sound_changed.connect(
|
||||
func(_s) : setup_volume()
|
||||
)
|
||||
for player in get_all_soundtrack_players():
|
||||
player.play()
|
||||
for player in get_all_players():
|
||||
player.stop()
|
||||
|
||||
fetch_default_volumes()
|
||||
setup_volume()
|
||||
settings.sound_changed.connect(
|
||||
func(_s) : setup_volume()
|
||||
)
|
||||
SceneManager.scene_loaded.connect(_on_change_scene)
|
||||
|
||||
func _on_change_scene(scene : Scene):
|
||||
play_ambiance()
|
||||
|
||||
match scene.scene_id:
|
||||
"TITLE":
|
||||
play_music("Title")
|
||||
"REGION":
|
||||
play_music("Region")
|
||||
play_ambiance("Exterior")
|
||||
"COCKPIT":
|
||||
play_music("Truck")
|
||||
|
||||
func fetch_default_volumes():
|
||||
var all_players := get_all_soundtrack_players()
|
||||
all_players.append_array(get_all_sfx_players())
|
||||
var all_players := get_all_players()
|
||||
|
||||
for player in all_players:
|
||||
default_volumes[player] = player.volume_db
|
||||
for player in all_players:
|
||||
default_volumes[player] = player.volume_db
|
||||
|
||||
func setup_volume():
|
||||
for player in get_all_soundtrack_players():
|
||||
player.volume_db = get_volume_from_parent(player) if (
|
||||
playing_soundtracks.find(player) != -1
|
||||
) else MIN_VOLUME
|
||||
setup_phase(player)
|
||||
for player in get_all_sfx_players():
|
||||
player.volume_db = get_volume_from_parent(player)
|
||||
for player in get_all_players():
|
||||
player.volume_db = get_volume_from_parent(player)
|
||||
|
||||
func get_volume_from_parent(player : AudioStreamPlayer) -> float:
|
||||
var settings_volume = 0.5
|
||||
var settings_volume = 0.5
|
||||
|
||||
if player.get_parent() == %Ambiance:
|
||||
settings_volume = settings.ambiance_volume
|
||||
elif player.get_parent() == %Sfx:
|
||||
settings_volume = settings.sfx_volume
|
||||
elif player.get_parent() == %Musics:
|
||||
settings_volume = settings.music_volume
|
||||
|
||||
return default_volumes[player] + lerp(MIN_VOLUME, MAX_VOLUME, settings_volume)
|
||||
if player.get_parent() == %Ambiance:
|
||||
settings_volume = settings.ambiance_volume
|
||||
elif player.get_parent() == %Sfx:
|
||||
settings_volume = settings.sfx_volume
|
||||
elif player.get_parent() == %Musics:
|
||||
settings_volume = settings.music_volume
|
||||
|
||||
return default_volumes[player] + lerp(MIN_VOLUME, MAX_VOLUME, settings_volume)
|
||||
|
||||
func update_phase():
|
||||
for player in get_all_soundtrack_players():
|
||||
var playing : bool = player.volume_db != MIN_VOLUME
|
||||
if playing:
|
||||
await set_volume(player, MIN_VOLUME).finished
|
||||
setup_phase(player)
|
||||
if playing:
|
||||
set_volume(player, get_volume_from_parent(player))
|
||||
func get_all_players() -> Array[AudioStreamPlayer]:
|
||||
var players : Array[AudioStreamPlayer] = []
|
||||
players.append_array(get_players_from_node(%Musics))
|
||||
players.append_array(get_players_from_node(%Ambiance))
|
||||
players.append_array(get_players_from_node(%Sfx))
|
||||
|
||||
func get_all_soundtrack_players() -> Array[AudioStreamPlayer]:
|
||||
var players : Array[AudioStreamPlayer] = []
|
||||
players.append_array(get_players_from_node(%Musics))
|
||||
players.append_array(get_players_from_node(%Ambiance))
|
||||
|
||||
return players
|
||||
|
||||
func get_all_sfx_players() -> Array[AudioStreamPlayer]:
|
||||
return get_players_from_node(%Sfx)
|
||||
return players
|
||||
|
||||
func get_players_from_node(node : Node) -> Array[AudioStreamPlayer]:
|
||||
var streams : Array[AudioStreamPlayer] = []
|
||||
var streams : Array[AudioStreamPlayer] = []
|
||||
|
||||
for c in node.get_children():
|
||||
if c is AudioStreamPlayer:
|
||||
streams.append(c)
|
||||
return streams
|
||||
for c in node.get_children():
|
||||
if c is AudioStreamPlayer:
|
||||
streams.append(c)
|
||||
return streams
|
||||
|
||||
func set_volume(player : AudioStreamPlayer, to : float, fade_time = default_fade_time) -> Tween:
|
||||
var fade_tween : Tween = get_tree().create_tween()
|
||||
|
||||
func _on_current_planet_data_updated(planet_data : PlanetData):
|
||||
if planet_data:
|
||||
update_garden_phase(planet_data)
|
||||
planet_data.updated.connect(update_garden_phase)
|
||||
|
||||
func update_garden_phase(planet_data : PlanetData):
|
||||
var phase : int = garden_phase
|
||||
for i in range(len(garden_phases_scores)):
|
||||
if planet_data.garden_score >= garden_phases_scores[i] and i > garden_phase:
|
||||
phase = i
|
||||
fade_tween.tween_property(player, "volume_db", to, fade_time)
|
||||
|
||||
if garden_phase != phase:
|
||||
update_phase()
|
||||
return fade_tween
|
||||
|
||||
garden_phase = phase
|
||||
func reset_volume(player : AudioStreamPlayer):
|
||||
player.volume_db = get_volume_from_parent(player)
|
||||
|
||||
func enter_planet():
|
||||
play_music(%Planet, true)
|
||||
stop_music(%Truck, true)
|
||||
func play_sfx(sfx_name : String):
|
||||
var player := %Sfx.find_child(sfx_name) as AudioStreamPlayer
|
||||
if player:
|
||||
player.play()
|
||||
else:
|
||||
printerr("Sfx %s not found" % sfx_name)
|
||||
|
||||
func enter_truck():
|
||||
play_music(%Truck, true)
|
||||
stop_music(%Planet, true)
|
||||
func play_music(music_name : String = ""):
|
||||
if playing_music:
|
||||
await set_volume(playing_music, MIN_VOLUME).finished
|
||||
if playing_music:
|
||||
playing_music.stop()
|
||||
reset_volume(playing_music)
|
||||
playing_music = null
|
||||
if music_name:
|
||||
var player := %Musics.find_child(music_name) as AudioStreamPlayer
|
||||
if player:
|
||||
playing_music = player
|
||||
player.play()
|
||||
else:
|
||||
printerr("Music %s not found" % music_name)
|
||||
|
||||
func stop_music(music : AudioStreamPlayer, with_fade = false):
|
||||
if playing_soundtracks.find(music) != -1:
|
||||
playing_soundtracks.remove_at(playing_soundtracks.find(music))
|
||||
set_volume(music, MIN_VOLUME, with_fade)
|
||||
|
||||
func play_music(player : AudioStreamPlayer, with_fade = false):
|
||||
playing_soundtracks.append(player)
|
||||
set_volume(player, get_volume_from_parent(player), with_fade)
|
||||
|
||||
func setup_phase(music : AudioStreamPlayer):
|
||||
if music.stream is AudioStreamSynchronized:
|
||||
var sync_stream = music.stream as AudioStreamSynchronized
|
||||
var phase_stream_id = min(garden_phase, sync_stream.stream_count - 1)
|
||||
for i in range(sync_stream.stream_count):
|
||||
sync_stream.set_sync_stream_volume(
|
||||
i,
|
||||
0. if i == phase_stream_id else MIN_VOLUME
|
||||
)
|
||||
|
||||
func set_volume(music : AudioStreamPlayer, to : float, fade_time = default_fade_time) -> Tween:
|
||||
var fade_tween : Tween = get_tree().create_tween()
|
||||
|
||||
fade_tween.tween_property(music, "volume_db", to, fade_time)
|
||||
|
||||
return fade_tween
|
||||
|
||||
func play_sfx(name : String):
|
||||
var player := %Sfx.find_child(name) as AudioStreamPlayer
|
||||
if player:
|
||||
player.play()
|
||||
else:
|
||||
printerr("Sfx %s not found" % name)
|
||||
func play_ambiance(ambiance_name : String = ""):
|
||||
if playing_ambiance:
|
||||
await set_volume(playing_ambiance, MIN_VOLUME).finished
|
||||
if playing_ambiance:
|
||||
playing_ambiance.stop()
|
||||
reset_volume(playing_ambiance)
|
||||
playing_ambiance = null
|
||||
if ambiance_name:
|
||||
var player := %Ambiance.find_child(ambiance_name) as AudioStreamPlayer
|
||||
if player:
|
||||
playing_ambiance = player
|
||||
player.play()
|
||||
else:
|
||||
printerr("Sfx %s not found" % ambiance_name)
|
||||
|
||||
@@ -1,100 +1,31 @@
|
||||
extends Resource
|
||||
class_name GameData
|
||||
|
||||
signal current_planet_data_updated(p : PlanetData)
|
||||
|
||||
func _init():
|
||||
set_default_unlocked()
|
||||
|
||||
@export var tutorial_done = false
|
||||
signal current_region_data_updated(p : RegionData)
|
||||
|
||||
@export var settings : SettingsData = SettingsData.new()
|
||||
|
||||
@export var current_run : RunData = RunData.new()
|
||||
@export var current_run : RunData = null
|
||||
|
||||
@export var current_planet_data : PlanetData : get = get_current_planet_data
|
||||
|
||||
@export var current_region_data : RegionData = null
|
||||
|
||||
@export var player_data : PlayerData = PlayerData.new()
|
||||
|
||||
@export var unlocked_plant_types : Array[PlantType] = []
|
||||
@export var unlocked_plant_mutations : Array[PlantMutation] = []
|
||||
@export var unlocked_machines : Array[MachineType] = []
|
||||
|
||||
@export var truck_data : TruckData = TruckData.new()
|
||||
|
||||
func _ready():
|
||||
current_run.run_point_changed.connect(
|
||||
func(): current_planet_data_updated.emit(get_current_planet_data)
|
||||
)
|
||||
|
||||
func set_default_unlocked():
|
||||
unlocked_plant_types = all_plant_types()
|
||||
unlocked_plant_mutations = all_plant_mutations()
|
||||
unlocked_machines = all_machines()
|
||||
|
||||
func reset_run():
|
||||
current_run = RunData.new()
|
||||
current_planet_data_updated.emit()
|
||||
func start_run():
|
||||
player_data.inventory.clear()
|
||||
current_run = RunData.new()
|
||||
current_run.current_run_point_changed.connect(
|
||||
func(rp : RunPoint):
|
||||
start_region(rp.region_parameter)
|
||||
)
|
||||
|
||||
func reset_player():
|
||||
player_data = PlayerData.new()
|
||||
|
||||
func reset_truck():
|
||||
truck_data = TruckData.new()
|
||||
player_data = PlayerData.new()
|
||||
|
||||
func reset_all():
|
||||
reset_run()
|
||||
reset_player()
|
||||
reset_truck()
|
||||
start_run()
|
||||
reset_player()
|
||||
|
||||
unlocked_plant_types = []
|
||||
|
||||
func unlock_plant_type(new_plant_type : PlantType):
|
||||
if not is_plant_type_unlocked(new_plant_type):
|
||||
unlocked_plant_types.append(new_plant_type.duplicate_deep())
|
||||
|
||||
func get_locked_plant_types() -> Array[PlantType]:
|
||||
var locked_plant_type : Array[PlantType] = []
|
||||
|
||||
for pt in GameInfo.game_data.all_plant_types():
|
||||
if not is_plant_type_unlocked(pt):
|
||||
locked_plant_type.append(pt)
|
||||
|
||||
return locked_plant_type
|
||||
|
||||
func get_current_planet_data():
|
||||
return current_run.get_current_planet_data()
|
||||
|
||||
func is_plant_type_unlocked(new_plant_type : PlantType):
|
||||
return unlocked_plant_types.find_custom(
|
||||
func (upt : PlantType): return new_plant_type.name == upt.name
|
||||
) != -1
|
||||
|
||||
|
||||
func all_plant_types() -> Array[PlantType]:
|
||||
return [
|
||||
preload("res://entities/plants/resources/plant_types/champ.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/chardi.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/ferno.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/maias.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/philea.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/pili.tres"),
|
||||
preload("res://entities/plants/resources/plant_types/solita.tres"),
|
||||
]
|
||||
|
||||
func all_machines() -> Array[MachineType]:
|
||||
return [
|
||||
preload("res://entities/interactables/machines/solar_pannel/solar_pannel.tres"),
|
||||
]
|
||||
|
||||
func all_plant_mutations() -> Array[PlantMutation]:
|
||||
return [
|
||||
preload("res://entities/plants/resources/plant_mutations/ancient_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/elitist_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/ermit_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/precocious_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/quality_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/quick_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/sociable_mutation.tres"),
|
||||
preload("res://entities/plants/resources/plant_mutations/strong_mutation.tres"),
|
||||
]
|
||||
func start_region(region_param : RegionParameter):
|
||||
current_region_data = RegionData.new(region_param)
|
||||
current_region_data_updated.emit(current_region_data)
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
extends Resource
|
||||
class_name RunData
|
||||
|
||||
const RUN_POINT_POSITION_DERIVATION = 70
|
||||
enum State {STARTED, IN_PROGRESS, FINISHED}
|
||||
|
||||
const RUN_POINT_POSITION_DERIVATION = 100
|
||||
const DIFFICULTY_INCREASE_BY_LEVEL = 1
|
||||
const RUN_POINTS_NEXT_NUMBER :Array[int] = [2,3]
|
||||
const RUN_POINT_MAX_LEVEL = 10
|
||||
|
||||
signal run_point_changed
|
||||
signal current_run_point_changed
|
||||
|
||||
var run_seed = randi()
|
||||
@export var next_run_points : Array[RunPoint] = [generate_first_run_point()]
|
||||
@export var current_run_point : RunPoint = null
|
||||
@export var current_run_point : RunPoint = null :
|
||||
set(v):
|
||||
current_run_point = v
|
||||
current_run_point_changed.emit(v)
|
||||
@export var visited_run_points : Array[RunPoint] = []
|
||||
|
||||
#region ------------------ Generation ------------------
|
||||
|
||||
func generate_first_run_point() -> RunPoint:
|
||||
return RunPoint.new(0, PlanetParameter.new())
|
||||
return RunPoint.new(0, RegionParameter.new())
|
||||
|
||||
func generate_next_run_points(run_point : RunPoint) -> Array[RunPoint]:
|
||||
var nb_next_run_points = RUN_POINTS_NEXT_NUMBER.pick_random()
|
||||
@@ -38,18 +43,18 @@ func generate_next_run_points(run_point : RunPoint) -> Array[RunPoint]:
|
||||
func generate_next_run_point(run_point : RunPoint) -> RunPoint:
|
||||
return RunPoint.new(
|
||||
run_point.level + 1,
|
||||
generate_difficulty_increased_planet_parameter(run_point.planet_parameter, DIFFICULTY_INCREASE_BY_LEVEL),
|
||||
generate_difficulty_increased_region_parameter(run_point.region_parameter, DIFFICULTY_INCREASE_BY_LEVEL),
|
||||
(run_point.position + randi_range(-RUN_POINT_POSITION_DERIVATION, RUN_POINT_POSITION_DERIVATION)) % 360
|
||||
)
|
||||
|
||||
func generate_difficulty_increased_planet_parameter(
|
||||
planet_parameter : PlanetParameter,
|
||||
func generate_difficulty_increased_region_parameter(
|
||||
region_parameter : RegionParameter,
|
||||
difficulty : int = 1
|
||||
) -> PlanetParameter:
|
||||
) -> RegionParameter:
|
||||
var i_diff := difficulty
|
||||
var new_planet_parameter = PlanetParameter.new(
|
||||
planet_parameter.charges,
|
||||
planet_parameter.objective
|
||||
var new_region_parameter = RegionParameter.new(
|
||||
region_parameter.charges,
|
||||
region_parameter.objective
|
||||
)
|
||||
while i_diff > 0:
|
||||
|
||||
@@ -58,26 +63,30 @@ func generate_difficulty_increased_planet_parameter(
|
||||
DifficultyIncreaseObjective.new()
|
||||
].filter(
|
||||
func (mod : DifficultyModifier):
|
||||
return mod.get_difficulty_cost() <= i_diff and mod.can_modifiy(new_planet_parameter)
|
||||
return mod.get_difficulty_cost() <= i_diff and mod.can_modifiy(new_region_parameter)
|
||||
)
|
||||
|
||||
var selected_difficulty_modifier = available_difficulty_modifier.pick_random()
|
||||
|
||||
selected_difficulty_modifier.modify(new_planet_parameter)
|
||||
selected_difficulty_modifier.modify(new_region_parameter)
|
||||
|
||||
i_diff -= max(1,selected_difficulty_modifier.get_difficulty_cost())
|
||||
return new_planet_parameter
|
||||
return new_region_parameter
|
||||
|
||||
#endregion
|
||||
|
||||
func get_next_run_points() -> Array[RunPoint]:
|
||||
return next_run_points
|
||||
func get_state() -> State:
|
||||
if not current_run_point:
|
||||
return State.STARTED
|
||||
elif current_run_point.level == RUN_POINT_MAX_LEVEL:
|
||||
return State.FINISHED
|
||||
else :
|
||||
return State.IN_PROGRESS
|
||||
|
||||
func get_current_planet_data() -> PlanetData:
|
||||
if current_run_point:
|
||||
return current_run_point.planet_data
|
||||
else:
|
||||
return null
|
||||
func get_next_run_points() -> Array[RunPoint]:
|
||||
if current_run_point and current_run_point.level == RUN_POINT_MAX_LEVEL:
|
||||
return []
|
||||
return next_run_points
|
||||
|
||||
func choose_next_run_point(run_point : RunPoint) -> RunPoint:
|
||||
if current_run_point:
|
||||
@@ -87,22 +96,22 @@ func choose_next_run_point(run_point : RunPoint) -> RunPoint:
|
||||
return current_run_point
|
||||
|
||||
class DifficultyModifier:
|
||||
func modify(_planet_parameter : PlanetParameter):
|
||||
func modify(_region_parameter : RegionParameter):
|
||||
pass
|
||||
|
||||
func can_modifiy(_planet_parameter : PlanetParameter) -> bool:
|
||||
func can_modifiy(_region_parameter : RegionParameter) -> bool:
|
||||
return true
|
||||
|
||||
func get_difficulty_cost() -> int:
|
||||
return 1
|
||||
|
||||
class DifficultyIncreaseObjective extends DifficultyModifier:
|
||||
func modify(planet_parameter : PlanetParameter):
|
||||
planet_parameter.objective += 1
|
||||
func modify(region_parameter : RegionParameter):
|
||||
region_parameter.objective += 1
|
||||
|
||||
class DifficultyDecreaseCharge extends DifficultyModifier:
|
||||
func modify(planet_parameter : PlanetParameter):
|
||||
planet_parameter.charges -= 1
|
||||
func modify(region_parameter : RegionParameter):
|
||||
region_parameter.charges -= 1
|
||||
|
||||
func can_modifiy(planet_parameter : PlanetParameter) -> bool:
|
||||
return planet_parameter.charges >= 3
|
||||
func can_modifiy(region_parameter : RegionParameter) -> bool:
|
||||
return region_parameter.charges >= 3
|
||||
@@ -8,53 +8,30 @@ const OBJECTIVE_ICON = preload("res://common/icons/dna.svg")
|
||||
const CHARGE_ICON = preload("res://common/icons/bolt.svg")
|
||||
|
||||
@export var level : int = 0 # X pos along the planet, and difficulty
|
||||
@export var planet_parameter : PlanetParameter = PlanetParameter.new() :
|
||||
@export var region_parameter : RegionParameter = RegionParameter.new() :
|
||||
set(v):
|
||||
planet_parameter = v
|
||||
planet_data = PlanetData.new(planet_parameter)
|
||||
@export var region_name : String = generate_region_name()
|
||||
region_parameter = v
|
||||
@export var position : int = 0 # Y pos along the planet, 0 to 360
|
||||
var planet_data : PlanetData
|
||||
|
||||
func _init(
|
||||
_level : int = 0,
|
||||
_planet_parameter : PlanetParameter = PlanetParameter.new(),
|
||||
_region_parameter : RegionParameter = RegionParameter.new(),
|
||||
_position : int = randi_range(0,360),
|
||||
_region_name : String = generate_region_name()
|
||||
):
|
||||
level = _level
|
||||
planet_parameter = _planet_parameter
|
||||
region_parameter = _region_parameter
|
||||
position = _position
|
||||
region_name = _region_name
|
||||
planet_data = PlanetData.new(planet_parameter)
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(region_name)
|
||||
var info = CardInfo.new(region_parameter.name)
|
||||
info.important_stat_icon = DANGER_ICON
|
||||
info.important_stat_text = "%d" % level
|
||||
|
||||
info.type_icon = TYPE_ICON
|
||||
|
||||
info.stats.append_array([
|
||||
CardStatInfo.new(tr("%d_GARDEN_POINTS") % planet_parameter.objective, OBJECTIVE_ICON),
|
||||
CardStatInfo.new(tr("%d_CHARGES_AVAILABLE") % planet_parameter.charges, CHARGE_ICON),
|
||||
CardStatInfo.new(tr("%d_GARDEN_POINTS") % region_parameter.objective, OBJECTIVE_ICON),
|
||||
CardStatInfo.new(tr("%d_CHARGES_AVAILABLE") % region_parameter.charges, CHARGE_ICON),
|
||||
])
|
||||
|
||||
return info
|
||||
|
||||
func generate_region_name() -> String:
|
||||
var vowel = ["a","e","i","o","u","y"]
|
||||
var consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z", "'"]
|
||||
|
||||
var word_len = randf_range(4,8)
|
||||
var word = ''
|
||||
var last_letter_is_vowel = false
|
||||
|
||||
for i in range(word_len):
|
||||
if last_letter_is_vowel:
|
||||
word += consonants.pick_random()
|
||||
else:
|
||||
word += vowel.pick_random()
|
||||
|
||||
last_letter_is_vowel = not last_letter_is_vowel
|
||||
return word.capitalize()
|
||||
return info
|
||||
1
common/icons/focus.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-focus"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11.5 12a.5 .5 0 1 0 1 0a.5 .5 0 1 0 -1 0" fill="#ffffff" /><path d="M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" /></svg>
|
||||
|
After Width: | Height: | Size: 415 B |
@@ -2,16 +2,16 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cqqlkm14lawpa"
|
||||
path="res://.godot/imported/panneau_solaire_1.png-b9a4049f295152380ed394a82c03b8e2.ctex"
|
||||
uid="uid://ba8vh5h3r6pr2"
|
||||
path="res://.godot/imported/focus.svg-cc30e969e976522254107343300a103b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_1.png"
|
||||
dest_files=["res://.godot/imported/panneau_solaire_1.png-b9a4049f295152380ed394a82c03b8e2.ctex"]
|
||||
source_file="res://common/icons/focus.svg"
|
||||
dest_files=["res://.godot/imported/focus.svg-cc30e969e976522254107343300a103b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -38,3 +38,6 @@ process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=2.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
1
common/icons/hand-stop.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-hand-stop"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5" /><path d="M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5" /><path d="M14 5.5a1.5 1.5 0 0 1 3 0v6.5" /><path d="M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47" /></svg>
|
||||
|
After Width: | Height: | Size: 651 B |
@@ -2,16 +2,16 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b1n8nad43usw4"
|
||||
path="res://.godot/imported/panneau_solaire_2.png-479b68803815c59c599ff8c3a78ca895.ctex"
|
||||
uid="uid://3slhocr5wy3w"
|
||||
path="res://.godot/imported/hand-stop.svg-bc0d0e986bcb4b50bdd5686b5bff814b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_2.png"
|
||||
dest_files=["res://.godot/imported/panneau_solaire_2.png-479b68803815c59c599ff8c3a78ca895.ctex"]
|
||||
source_file="res://common/icons/hand-stop.svg"
|
||||
dest_files=["res://.godot/imported/hand-stop.svg-bc0d0e986bcb4b50bdd5686b5bff814b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -38,3 +38,6 @@ process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=2.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
13
common/scene_manager/scene_manager.tscn
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://dac5wte80dwj0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bb44144ckt2w7" path="res://common/scene_manager/scripts/scene_manager.gd" id="1_1c0qu"]
|
||||
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="2_c1lr7"]
|
||||
[ext_resource type="Resource" uid="uid://bvksiaiocwob5" path="res://common/scene_manager/scenes/cockpit.tres" id="3_e28ni"]
|
||||
[ext_resource type="Resource" uid="uid://bvgdq43fpl1xs" path="res://common/scene_manager/scenes/intro.tres" id="4_msho1"]
|
||||
[ext_resource type="Resource" uid="uid://boqgwjyxyb45r" path="res://common/scene_manager/scenes/region.tres" id="5_ytog4"]
|
||||
[ext_resource type="Resource" uid="uid://c27wenetitwm" path="res://common/scene_manager/scenes/region_selection.tres" id="6_chs32"]
|
||||
[ext_resource type="Resource" uid="uid://diro74w272onp" path="res://common/scene_manager/scenes/title.tres" id="7_ol3d5"]
|
||||
|
||||
[node name="SceneManager" type="Node"]
|
||||
script = ExtResource("1_1c0qu")
|
||||
scenes = Array[ExtResource("2_c1lr7")]([ExtResource("3_e28ni"), ExtResource("4_msho1"), ExtResource("5_ytog4"), ExtResource("6_chs32"), ExtResource("7_ol3d5")])
|
||||
10
common/scene_manager/scenes/cockpit.tres
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://bvksiaiocwob5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_tkiq8"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_tkiq8")
|
||||
scene_id = "COCKPIT"
|
||||
scene_path = "res://stages/cockpit/cockpit.tscn"
|
||||
mouse_captured = true
|
||||
metadata/_custom_type_script = "uid://1ejbvr3431ac"
|
||||
9
common/scene_manager/scenes/intro.tres
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://bvgdq43fpl1xs"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_6ws88"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_6ws88")
|
||||
scene_id = "INTRO"
|
||||
scene_path = "res://stages/intro/intro.tscn"
|
||||
metadata/_custom_type_script = "uid://1ejbvr3431ac"
|
||||
10
common/scene_manager/scenes/region.tres
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://boqgwjyxyb45r"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_10qbh"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_10qbh")
|
||||
scene_id = "REGION"
|
||||
scene_path = "res://stages/terrain/region/region.tscn"
|
||||
need_terrain_generated = true
|
||||
metadata/_custom_type_script = "uid://1ejbvr3431ac"
|
||||
9
common/scene_manager/scenes/region_selection.tres
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://c27wenetitwm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_smjh0"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_smjh0")
|
||||
scene_id = "REGION_SELECTION"
|
||||
scene_path = "res://stages/region_selection/region_selection.tscn"
|
||||
metadata/_custom_type_script = "uid://1ejbvr3431ac"
|
||||
9
common/scene_manager/scenes/title.tres
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="Resource" script_class="Scene" load_steps=2 format=3 uid="uid://diro74w272onp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1ejbvr3431ac" path="res://common/scene_manager/scripts/scene.gd" id="1_48g2j"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_48g2j")
|
||||
scene_id = "TITLE"
|
||||
scene_path = "res://stages/title_screen/title_screen.tscn"
|
||||
metadata/_custom_type_script = "uid://1ejbvr3431ac"
|
||||
7
common/scene_manager/scripts/scene.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Resource
|
||||
class_name Scene
|
||||
|
||||
@export var scene_id : String
|
||||
@export_file_path() var scene_path : String
|
||||
@export var mouse_captured := false
|
||||
@export var need_terrain_generated := false
|
||||
1
common/scene_manager/scripts/scene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://1ejbvr3431ac
|
||||
@@ -1,25 +1,39 @@
|
||||
extends Node
|
||||
|
||||
const TITLE_SCREEN = "res://stages/title_screen/title_screen.tscn"
|
||||
const PLANET_SCENE = "res://stages/terrain/planet/planet.tscn"
|
||||
const TRUCK_SCENE = "res://stages/terrain/truck/truck.tscn"
|
||||
const INTRO_SCENE = "res://stages/intro/intro.tscn"
|
||||
const COCKPIT_SCENE = "res://stages/cockpit/cockpit.tscn"
|
||||
const REGION_SELECTION_SCREEN = "res://stages/region_selection/region_selection.tscn"
|
||||
@export var scenes : Array[Scene]
|
||||
|
||||
signal scene_loaded
|
||||
signal scene_node_ready
|
||||
signal scene_loaded(scene : Scene)
|
||||
signal scene_node_ready(scene : Scene)
|
||||
|
||||
var loading_scene = false
|
||||
var generating_node = false
|
||||
var scene_to_load := ""
|
||||
var actual_scene : Scene = null
|
||||
var next_scene_node : Node
|
||||
@onready var current_scene_node : Node = get_tree().root.get_children().back()
|
||||
|
||||
func change_scene(scene_path : String, with_loading = true):
|
||||
func search_scenes(scene_id : String) -> Scene:
|
||||
var scene_pos : int = scenes.find_custom(
|
||||
func (s : Scene):
|
||||
return s.scene_id == scene_id
|
||||
)
|
||||
if scene_pos == -1:
|
||||
return null
|
||||
else :
|
||||
return scenes[scene_pos]
|
||||
|
||||
func change_scene(scene_id : String, with_loading = true):
|
||||
|
||||
if loading_scene or generating_node:
|
||||
await scene_node_ready
|
||||
|
||||
var scene = search_scenes(scene_id)
|
||||
if not scene:
|
||||
printerr("Scene %s not found" % scene_id)
|
||||
return
|
||||
actual_scene = scene
|
||||
loading_scene = true
|
||||
scene_to_load = scene_path
|
||||
ResourceLoader.load_threaded_request(scene_to_load)
|
||||
var scene_path_to_load = scene.scene_path
|
||||
ResourceLoader.load_threaded_request(scene_path_to_load)
|
||||
LoadingScreen.loading_text = "LOADING_SCENE"
|
||||
var scene_to_hide = current_scene_node
|
||||
if with_loading:
|
||||
@@ -31,16 +45,16 @@ func change_scene(scene_path : String, with_loading = true):
|
||||
if loading_scene:
|
||||
await scene_loaded
|
||||
|
||||
next_scene_node = ResourceLoader.load_threaded_get(scene_to_load).instantiate()
|
||||
next_scene_node = ResourceLoader.load_threaded_get(scene_path_to_load).instantiate()
|
||||
if next_scene_node.has_method("hide"):
|
||||
next_scene_node.hide()
|
||||
get_tree().root.add_child(next_scene_node)
|
||||
|
||||
generating_node = true
|
||||
if next_scene_node is Planet:
|
||||
if scene.need_terrain_generated:
|
||||
LoadingScreen.loading_text = "GENERATING_TERRAIN"
|
||||
|
||||
if generating_node:
|
||||
await scene_node_ready
|
||||
|
||||
await scene_node_ready
|
||||
|
||||
if current_scene_node:
|
||||
current_scene_node.queue_free()
|
||||
@@ -48,23 +62,27 @@ func change_scene(scene_path : String, with_loading = true):
|
||||
if current_scene_node.has_method("show"):
|
||||
current_scene_node.show()
|
||||
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if scene.mouse_captured else Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
if with_loading:
|
||||
LoadingScreen.hide_loading_screen()
|
||||
|
||||
func _process(_delta):
|
||||
if loading_scene:
|
||||
var progress = []
|
||||
var load_status := ResourceLoader.load_threaded_get_status(scene_to_load, progress)
|
||||
var load_status := ResourceLoader.load_threaded_get_status(actual_scene.scene_path, progress)
|
||||
LoadingScreen.loading_value = progress[0]
|
||||
if load_status == ResourceLoader.THREAD_LOAD_LOADED:
|
||||
loading_scene = false
|
||||
scene_loaded.emit()
|
||||
scene_loaded.emit(actual_scene)
|
||||
if load_status == ResourceLoader.THREAD_LOAD_FAILED or load_status == ResourceLoader.THREAD_LOAD_INVALID_RESOURCE:
|
||||
printerr()
|
||||
elif generating_node:
|
||||
if next_scene_node is Planet:
|
||||
if next_scene_node is Region:
|
||||
LoadingScreen.loading_value = next_scene_node.generated_value
|
||||
if next_scene_node.is_generated:
|
||||
generating_node = false
|
||||
scene_node_ready.emit()
|
||||
elif next_scene_node.is_node_ready():
|
||||
generating_node = false
|
||||
scene_node_ready.emit()
|
||||
scene_node_ready.emit(actual_scene)
|
||||
@@ -2,33 +2,33 @@ class_name Math
|
||||
|
||||
static func get_chunk_from_pos(coord) -> Vector2i:
|
||||
return Vector2i(
|
||||
floori(coord.x / (Planet.CHUNK_TILE_SIZE * Planet.TILE_SIZE)),
|
||||
floori(coord.y / (Planet.CHUNK_TILE_SIZE * Planet.TILE_SIZE))
|
||||
floori(coord.x / (Region.CHUNK_TILE_SIZE * Region.TILE_SIZE)),
|
||||
floori(coord.y / (Region.CHUNK_TILE_SIZE * Region.TILE_SIZE))
|
||||
)
|
||||
|
||||
static func get_tile_from_pos(coord) -> Vector2i:
|
||||
return Vector2i(
|
||||
floori(coord.x / (Planet.TILE_SIZE)),
|
||||
floori(coord.y / (Planet.TILE_SIZE)),
|
||||
floori(coord.x / (Region.TILE_SIZE)),
|
||||
floori(coord.y / (Region.TILE_SIZE)),
|
||||
)
|
||||
|
||||
static func get_tiles_in_circle(center: Vector2, radius : float) -> Array[Vector2i]:
|
||||
var tiles : Array[Vector2i] = []
|
||||
|
||||
for x in range(
|
||||
floori((center.x - radius/2.) / Planet.TILE_SIZE),
|
||||
ceili((center.x + radius/2.) / Planet.TILE_SIZE),
|
||||
floori((center.x - radius/2.) / Region.TILE_SIZE),
|
||||
ceili((center.x + radius/2.) / Region.TILE_SIZE),
|
||||
):
|
||||
for y in range(
|
||||
floori((center.y - radius/2.) / Planet.TILE_SIZE),
|
||||
ceili((center.y + radius/2.) / Planet.TILE_SIZE),
|
||||
floori((center.y - radius/2.) / Region.TILE_SIZE),
|
||||
ceili((center.y + radius/2.) / Region.TILE_SIZE),
|
||||
):
|
||||
if is_tile_on_circle(Vector2i(x,y), center, radius):
|
||||
tiles.append(Vector2i(x,y))
|
||||
return tiles
|
||||
|
||||
static func is_tile_on_circle(tile_coord : Vector2i, circle_center: Vector2, circle_radius : float) -> bool:
|
||||
var absolute_tile_pos : Vector2 = tile_coord * Planet.TILE_SIZE
|
||||
var absolute_tile_pos : Vector2 = tile_coord * Region.TILE_SIZE
|
||||
|
||||
# Loop over tile corners to know if the area collide
|
||||
var corners : Array[Vector2] = []
|
||||
@@ -36,8 +36,8 @@ static func is_tile_on_circle(tile_coord : Vector2i, circle_center: Vector2, cir
|
||||
for y in [0,1]:
|
||||
corners.append(
|
||||
absolute_tile_pos
|
||||
+ Vector2.RIGHT * x * Planet.TILE_SIZE
|
||||
+ Vector2.DOWN * y * Planet.TILE_SIZE
|
||||
+ Vector2.RIGHT * x * Region.TILE_SIZE
|
||||
+ Vector2.DOWN * y * Region.TILE_SIZE
|
||||
)
|
||||
|
||||
# Check if segment touch area
|
||||
|
||||
45
common/tools/scripts/random.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
class_name Random
|
||||
|
||||
const MIN_WORD_LEN = 4
|
||||
const MAX_WORD_LEN = 8
|
||||
|
||||
const VOWEL = ["a","e","i","o","u","y"]
|
||||
const CONSONANTS = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z"]
|
||||
|
||||
|
||||
static func generate_random_name(random_seed = randi()) -> String:
|
||||
var word_len = randf_range(4,8)
|
||||
var word = ''
|
||||
var last_letter_is_vowel = false
|
||||
|
||||
for i in range(word_len):
|
||||
if last_letter_is_vowel:
|
||||
word += CONSONANTS.pick_random()
|
||||
else:
|
||||
word += VOWEL.pick_random()
|
||||
|
||||
last_letter_is_vowel = not last_letter_is_vowel
|
||||
return word.capitalize()
|
||||
|
||||
static func mutate_name(word : String) -> String:
|
||||
return word
|
||||
# TODO
|
||||
|
||||
|
||||
func shorten_name(word : String):
|
||||
if randi()%2 == 0:
|
||||
return word.left(len(word) - 1).capitalize()
|
||||
else :
|
||||
return word.right(len(word) - 1).capitalize()
|
||||
|
||||
func elongate_name(word : String):
|
||||
if randi()%2 == 0:
|
||||
var letter = CONSONANTS.pick_random() if word.left(1) in VOWEL else VOWEL.pick_random()
|
||||
return (letter + word).capitalize()
|
||||
else :
|
||||
var letter = CONSONANTS.pick_random() if word.right(1) in VOWEL else VOWEL.pick_random()
|
||||
return (word + letter).capitalize()
|
||||
|
||||
func replace_character(word : String):
|
||||
# TODO
|
||||
return word
|
||||
1
common/tools/scripts/random.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ukeanrcup7of
|
||||
272
common/vfx/materials/shaders/3d_outline.gdshader
Normal file
@@ -0,0 +1,272 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, blend_mix, depth_draw_never, depth_test_disabled;
|
||||
|
||||
/*
|
||||
AUTHOR: Hannah "EMBYR" Crawford
|
||||
ENGINE_VERSION: 4.0.3
|
||||
|
||||
HOW TO USE:
|
||||
1. Create a MeshInstance3D node and place it in your scene.
|
||||
2. Set it's size to 2x2.
|
||||
3. Enable the "Flip Faces" option.
|
||||
4. Create a new shader material with this shader.
|
||||
5. Assign the material to the MeshInstance3D
|
||||
|
||||
LIMITATIONS:
|
||||
Does not work well with TAA enabled.
|
||||
|
||||
MOBILE_NOTES:
|
||||
The mobile renderer does not have access to the normal_roughness texture
|
||||
so we must rely on techniques to reconstruct this information from the
|
||||
depth buffer.
|
||||
|
||||
If you require support on mobile please uncomment the SUPPORT_MOBILE line
|
||||
below. I have done my best to match the appearance between the two modes
|
||||
however, mobile does not take into account smooth-shaded faces.
|
||||
|
||||
The high-quality reconstruction method used on mobile is rather heavy on
|
||||
texture samples. If you would like to use the lower-quality recontruction
|
||||
method for better performance, please uncomment the NAIVE_NORMAL_RECONSTRUCTION
|
||||
line below.
|
||||
*/
|
||||
//#define SUPPORT_MOBILE
|
||||
//#define NAIVE_NORMAL_RECONSTRUCTION
|
||||
|
||||
group_uniforms outline;
|
||||
uniform vec4 outlineColor: source_color = vec4(0.0, 0.0, 0.0, 0.78);
|
||||
uniform float depth_threshold = 0.025;
|
||||
uniform float normal_threshold : hint_range(0.0, 1.5) = 0.5;
|
||||
uniform float normal_smoothing : hint_range(0.0, 1.0) = 0.25;
|
||||
|
||||
group_uniforms thickness;
|
||||
uniform float max_thickness: hint_range(0.0, 5.0) = 1.3;
|
||||
uniform float min_thickness = 0.5;
|
||||
uniform float max_distance = 75.0;
|
||||
uniform float min_distance = 2.0;
|
||||
|
||||
group_uniforms grazing_prevention;
|
||||
uniform float grazing_fresnel_power = 5.0;
|
||||
uniform float grazing_angle_mask_power = 1.0;
|
||||
uniform float grazing_angle_modulation_factor = 50.0;
|
||||
|
||||
uniform sampler2D DEPTH_TEXTURE : hint_depth_texture, filter_linear, repeat_disable;
|
||||
|
||||
#ifndef SUPPORT_MOBILE
|
||||
uniform sampler2D NORMR_TEXTURE : hint_normal_roughness_texture, filter_linear, repeat_disable;
|
||||
#else
|
||||
varying flat mat4 model_view_matrix;
|
||||
#endif// !SUPPORT_MOBILE
|
||||
|
||||
struct UVNeighbors {
|
||||
vec2 center;
|
||||
vec2 left; vec2 right; vec2 up; vec2 down;
|
||||
vec2 top_left; vec2 top_right; vec2 bottom_left; vec2 bottom_right;
|
||||
};
|
||||
|
||||
struct NeighborDepthSamples {
|
||||
float c_d;
|
||||
float l_d; float r_d; float u_d; float d_d;
|
||||
float tl_d; float tr_d; float bl_d; float br_d;
|
||||
};
|
||||
|
||||
UVNeighbors getNeighbors(vec2 center, float width, float aspect) {
|
||||
vec2 h_offset = vec2(width * aspect * 0.001, 0.0);
|
||||
vec2 v_offset = vec2(0.0, width * 0.001);
|
||||
UVNeighbors n;
|
||||
n.center = center;
|
||||
n.left = center - h_offset;
|
||||
n.right = center + h_offset;
|
||||
n.up = center - v_offset;
|
||||
n.down = center + v_offset;
|
||||
n.top_left = center - (h_offset - v_offset);
|
||||
n.top_right = center + (h_offset - v_offset);
|
||||
n.bottom_left = center - (h_offset + v_offset);
|
||||
n.bottom_right = center + (h_offset + v_offset);
|
||||
return n;
|
||||
}
|
||||
|
||||
float getMinimumDepth(NeighborDepthSamples ds){
|
||||
return min(ds.c_d, min(ds.l_d, min(ds.r_d, min(ds.u_d, min(ds.d_d, min(ds.tl_d, min(ds.tr_d, min(ds.bl_d, ds.br_d))))))));
|
||||
}
|
||||
|
||||
float getLinearDepth(float depth, vec2 uv, mat4 inv_proj) {
|
||||
vec3 ndc = vec3(uv * 2.0 - 1.0, depth);
|
||||
vec4 view = inv_proj * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
return -view.z;
|
||||
}
|
||||
|
||||
NeighborDepthSamples getLinearDepthSamples(UVNeighbors uvs, sampler2D depth_tex, mat4 invProjMat) {
|
||||
NeighborDepthSamples result;
|
||||
result.c_d = getLinearDepth(texture(depth_tex, uvs.center).r, uvs.center, invProjMat);
|
||||
result.l_d = getLinearDepth(texture(depth_tex, uvs.left).r , uvs.left , invProjMat);
|
||||
result.r_d = getLinearDepth(texture(depth_tex, uvs.right).r , uvs.right , invProjMat);
|
||||
result.u_d = getLinearDepth(texture(depth_tex, uvs.up).r , uvs.up , invProjMat);
|
||||
result.d_d = getLinearDepth(texture(depth_tex, uvs.down).r , uvs.down , invProjMat);
|
||||
result.tl_d = getLinearDepth(texture(depth_tex, uvs.top_left).r, uvs.top_left, invProjMat);
|
||||
result.tr_d = getLinearDepth(texture(depth_tex, uvs.top_right).r, uvs.top_right, invProjMat);
|
||||
result.bl_d = getLinearDepth(texture(depth_tex, uvs.bottom_left).r, uvs.bottom_left, invProjMat);
|
||||
result.br_d = getLinearDepth(texture(depth_tex, uvs.bottom_right).r, uvs.bottom_right, invProjMat);
|
||||
return result;
|
||||
}
|
||||
|
||||
float remap(float v, float from1, float to1, float from2, float to2) {
|
||||
return (v - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
|
||||
float fresnel(float amount, vec3 normal, vec3 view) {
|
||||
return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0 )), amount);
|
||||
}
|
||||
|
||||
float getGrazingAngleModulation(vec3 pixel_normal, vec3 view) {
|
||||
float x = clamp(((fresnel(grazing_fresnel_power, pixel_normal, view) - 1.0) / grazing_angle_mask_power) + 1.0, 0.0, 1.0);
|
||||
return (x + grazing_angle_modulation_factor) + 1.0;
|
||||
}
|
||||
|
||||
float detectEdgesDepth(NeighborDepthSamples depth_samples, vec3 pixel_normal, vec3 view) {
|
||||
float n_total =
|
||||
depth_samples.l_d +
|
||||
depth_samples.r_d +
|
||||
depth_samples.u_d +
|
||||
depth_samples.d_d +
|
||||
depth_samples.tl_d +
|
||||
depth_samples.tr_d +
|
||||
depth_samples.bl_d +
|
||||
depth_samples.br_d;
|
||||
|
||||
float t = depth_threshold * getGrazingAngleModulation(pixel_normal, view);
|
||||
return step(t, n_total - (depth_samples.c_d * 8.0));
|
||||
}
|
||||
|
||||
// Reconstruction helpers
|
||||
// Source: https://www.reddit.com/r/godot/comments/v70p2k/improved_normal_from_depth/
|
||||
#ifdef SUPPORT_MOBILE
|
||||
vec3 reconstructWorldPosition(float depth, mat4 model_view, mat4 inv_proj, vec2 screen_uv, mat4 world, mat4 inv_cam){
|
||||
vec4 pos = inverse(model_view) * inv_proj * vec4((screen_uv * 2.0 - 1.0), depth * 2.0 - 1.0, 1.0);
|
||||
pos.xyz /= (pos.w + 0.0001 * (1.-abs(sign(pos.w))));
|
||||
return (pos * inv_cam).xyz + world[3].xyz;
|
||||
}
|
||||
|
||||
#ifndef NAIVE_NORMAL_RECONSTRUCTION
|
||||
vec3 reconstructWorldNormal(sampler2D depth_tex, mat4 model_view, mat4 inv_proj, vec2 screen_uv, mat4 world, mat4 inv_cam, vec2 viewport_size) {
|
||||
vec2 e = vec2(1.0 / viewport_size);
|
||||
float c0 = texture(depth_tex, screen_uv ).r;
|
||||
float l2 = texture(depth_tex, screen_uv - vec2(2,0) * e).r;
|
||||
float l1 = texture(depth_tex, screen_uv - vec2(1,0) * e).r;
|
||||
float r1 = texture(depth_tex, screen_uv + vec2(1,0) * e).r;
|
||||
float r2 = texture(depth_tex, screen_uv + vec2(2,0) * e).r;
|
||||
float b2 = texture(depth_tex, screen_uv - vec2(0,2) * e).r;
|
||||
float b1 = texture(depth_tex, screen_uv - vec2(0,1) * e).r;
|
||||
float t1 = texture(depth_tex, screen_uv + vec2(0,1) * e).r;
|
||||
float t2 = texture(depth_tex, screen_uv + vec2(0,2) * e).r;
|
||||
|
||||
float dl = abs(l1 * l2 / (2.0 * l2 - l1) - c0);
|
||||
float dr = abs(r1 * r2 / (2.0 * r2 - r1) - c0);
|
||||
float db = abs(b1 * b2 / (2.0 * b2 - b1) - c0);
|
||||
float dt = abs(t1 * t2 / (2.0 * t2 - t1) - c0);
|
||||
|
||||
vec3 ce = reconstructWorldPosition(c0, model_view, inv_proj, screen_uv, world, inv_cam);
|
||||
|
||||
vec3 dpdx = (dl<dr) ? ce-reconstructWorldPosition(l1, model_view, inv_proj, screen_uv - vec2(1,0) * e, world, inv_cam) :
|
||||
-ce+reconstructWorldPosition(r1, model_view, inv_proj, screen_uv + vec2(1,0) * e, world, inv_cam) ;
|
||||
vec3 dpdy = (db<dt) ? ce-reconstructWorldPosition(b1, model_view, inv_proj, screen_uv - vec2(0,1) * e, world, inv_cam) :
|
||||
-ce+reconstructWorldPosition(t1, model_view, inv_proj, screen_uv + vec2(0,1) * e, world, inv_cam) ;
|
||||
|
||||
return normalize(cross(dpdx,dpdy));
|
||||
}
|
||||
#else
|
||||
vec3 reconstructWorldNormal(sampler2D depth_tex, mat4 model_view, mat4 inv_proj, vec2 screen_uv, mat4 world, mat4 inv_cam, vec2 viewport_size) {
|
||||
vec3 pos = reconstructWorldPosition(texture(depth_tex, screen_uv).x, model_view, inv_proj, screen_uv, world, inv_cam);
|
||||
return normalize(cross(dFdx(pos), dFdy(pos)));
|
||||
}
|
||||
#endif//!NAIVE_NORMAL_RECONSTRUCTION
|
||||
|
||||
float detectEdgesNormalReconstructed(UVNeighbors uvs, sampler2D depth_tex, mat4 model_view, mat4 inv_proj, vec2 screen_uv, mat4 world, mat4 inv_cam, vec2 viewport_size){
|
||||
vec3 n_u = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.up, world, inv_cam, viewport_size);
|
||||
vec3 n_d = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.down, world, inv_cam, viewport_size);
|
||||
vec3 n_l = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.left, world, inv_cam, viewport_size);
|
||||
vec3 n_r = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.right, world, inv_cam, viewport_size);
|
||||
vec3 n_tl = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.top_left, world, inv_cam, viewport_size);
|
||||
vec3 n_tr = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.top_right, world, inv_cam, viewport_size);
|
||||
vec3 n_bl = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.bottom_left, world, inv_cam, viewport_size);
|
||||
vec3 n_br = reconstructWorldNormal(depth_tex, model_view, inv_proj, uvs.bottom_right, world, inv_cam, viewport_size);
|
||||
|
||||
vec3 normalFiniteDifference0 = n_tr - n_bl;
|
||||
vec3 normalFiniteDifference1 = n_tl - n_br;
|
||||
vec3 normalFiniteDifference2 = n_l - n_r;
|
||||
vec3 normalFiniteDifference3 = n_u - n_d;
|
||||
|
||||
float edgeNormal = sqrt(
|
||||
dot(normalFiniteDifference0, normalFiniteDifference0) +
|
||||
dot(normalFiniteDifference1, normalFiniteDifference1) +
|
||||
dot(normalFiniteDifference2, normalFiniteDifference2) +
|
||||
dot(normalFiniteDifference3, normalFiniteDifference3)
|
||||
) * 0.5;
|
||||
|
||||
return smoothstep(normal_threshold - normal_smoothing, normal_threshold + normal_smoothing, edgeNormal);
|
||||
}
|
||||
#else
|
||||
float detectEdgesNormal(UVNeighbors uvs, sampler2D normTex, vec3 camDirWorld){
|
||||
vec3 n_u = texture(normTex, uvs.up).xyz;
|
||||
vec3 n_d = texture(normTex, uvs.down).xyz;
|
||||
vec3 n_l = texture(normTex, uvs.left).xyz;
|
||||
vec3 n_r = texture(normTex, uvs.right).xyz;
|
||||
vec3 n_tl = texture(normTex, uvs.top_left).xyz;
|
||||
vec3 n_tr = texture(normTex, uvs.top_right).xyz;
|
||||
vec3 n_bl = texture(normTex, uvs.bottom_left).xyz;
|
||||
vec3 n_br = texture(normTex, uvs.bottom_right).xyz;
|
||||
|
||||
vec3 normalFiniteDifference0 = n_tr - n_bl;
|
||||
vec3 normalFiniteDifference1 = n_tl - n_br;
|
||||
vec3 normalFiniteDifference2 = n_l - n_r;
|
||||
vec3 normalFiniteDifference3 = n_u - n_d;
|
||||
|
||||
float edgeNormal = sqrt(
|
||||
dot(normalFiniteDifference0, normalFiniteDifference0) +
|
||||
dot(normalFiniteDifference1, normalFiniteDifference1) +
|
||||
dot(normalFiniteDifference2, normalFiniteDifference2) +
|
||||
dot(normalFiniteDifference3, normalFiniteDifference3)
|
||||
);
|
||||
|
||||
return smoothstep(normal_threshold - normal_smoothing, normal_threshold + normal_smoothing, edgeNormal);
|
||||
}
|
||||
#endif//SUPPORT_MOBILE
|
||||
|
||||
void vertex() {
|
||||
POSITION = vec4(VERTEX, 1.0);
|
||||
|
||||
#ifdef SUPPORT_MOBILE
|
||||
model_view_matrix = INV_VIEW_MATRIX * mat4(VIEW_MATRIX[0],VIEW_MATRIX[1],VIEW_MATRIX[2],VIEW_MATRIX[3]);;
|
||||
#endif
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
float aspect = float(VIEWPORT_SIZE.y) / float(VIEWPORT_SIZE.x);
|
||||
|
||||
UVNeighbors n = getNeighbors(SCREEN_UV, max_thickness, aspect);
|
||||
NeighborDepthSamples depth_samples = getLinearDepthSamples(n, DEPTH_TEXTURE, INV_PROJECTION_MATRIX);
|
||||
|
||||
float min_d = getMinimumDepth(depth_samples);
|
||||
float thickness = clamp(remap(min_d, min_distance, max_distance, max_thickness, min_thickness), min_thickness, max_thickness);
|
||||
float fade_a = clamp(remap(min_d, min_distance, max_distance, 1.0, 0.0), 0.0, 1.0);
|
||||
|
||||
n = getNeighbors(SCREEN_UV, thickness, aspect);
|
||||
depth_samples = getLinearDepthSamples(n, DEPTH_TEXTURE, INV_PROJECTION_MATRIX);
|
||||
|
||||
#ifndef SUPPORT_MOBILE
|
||||
vec3 pixel_normal = texture(NORMR_TEXTURE, SCREEN_UV).xyz;
|
||||
#else
|
||||
vec3 pixel_normal = reconstructWorldNormal(DEPTH_TEXTURE, model_view_matrix, INV_PROJECTION_MATRIX, SCREEN_UV, MODEL_MATRIX, INV_VIEW_MATRIX, VIEWPORT_SIZE.xy);
|
||||
#endif
|
||||
|
||||
float depthEdges = detectEdgesDepth(depth_samples, pixel_normal, VIEW);
|
||||
|
||||
#ifndef SUPPORT_MOBILE
|
||||
float normEdges = min(detectEdgesNormal(n, NORMR_TEXTURE, CAMERA_DIRECTION_WORLD), 1.0);
|
||||
#else
|
||||
float normEdges = min(detectEdgesNormalReconstructed(n, DEPTH_TEXTURE, model_view_matrix, INV_PROJECTION_MATRIX, SCREEN_UV, MODEL_MATRIX, INV_VIEW_MATRIX, VIEWPORT_SIZE.xy), 1.0);
|
||||
#endif
|
||||
|
||||
ALBEDO.rgb = outlineColor.rgb;
|
||||
ALPHA = max(depthEdges, normEdges) * outlineColor.a * fade_a;
|
||||
}
|
||||
1
common/vfx/materials/shaders/3d_outline.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b14e5ju3o3bvs
|
||||
BIN
dialogs/characters/typing_sounds/baguera.wav
Normal file
24
dialogs/characters/typing_sounds/baguera.wav.import
Normal file
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://lajbj05iuxut"
|
||||
path="res://.godot/imported/baguera.wav-a0e2179506d9f51c2a553ff65014308b.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://dialogs/characters/typing_sounds/baguera.wav"
|
||||
dest_files=["res://.godot/imported/baguera.wav-a0e2179506d9f51c2a553ff65014308b.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
BIN
dialogs/characters/typing_sounds/sigourney_weaver.wav
Normal file
24
dialogs/characters/typing_sounds/sigourney_weaver.wav.import
Normal file
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://xkiwnglpsqi0"
|
||||
path="res://.godot/imported/sigourney_weaver.wav-045b3fe21e9c1474adb4b65507740115.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://dialogs/characters/typing_sounds/sigourney_weaver.wav"
|
||||
dest_files=["res://.godot/imported/sigourney_weaver.wav-045b3fe21e9c1474adb4b65507740115.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
@@ -6,71 +6,71 @@ const ITEM_SPRITE_SIZE = 40.
|
||||
const SPRITE_SCENE : PackedScene = preload("res://entities/interactables/item_object/item_object_sprite.tscn")
|
||||
|
||||
@export var item : Item :
|
||||
set(_item):
|
||||
item = _item
|
||||
if object_sprite:
|
||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||
object_sprite.generate_particles(item.get_particles())
|
||||
set(_item):
|
||||
item = _item
|
||||
if object_sprite:
|
||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||
object_sprite.generate_particles(item.get_particles())
|
||||
|
||||
@onready var object_sprite : ItemObjectSprite = generate_sprite()
|
||||
|
||||
func _init(_item = null):
|
||||
if _item:
|
||||
item = _item
|
||||
if _item:
|
||||
item = _item
|
||||
|
||||
func _ready():
|
||||
generate_collision(ITEM_AREA_WIDTH)
|
||||
if item and object_sprite:
|
||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||
object_sprite.generate_particles(item.get_particles())
|
||||
generate_collision(ITEM_AREA_WIDTH)
|
||||
if item and object_sprite:
|
||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||
object_sprite.generate_particles(item.get_particles())
|
||||
|
||||
func pointer_text() -> String:
|
||||
var name_suffix = ""
|
||||
var name_suffix = ""
|
||||
|
||||
if item is Seed:
|
||||
name_suffix = tr("SEED")
|
||||
if item is Package:
|
||||
name_suffix = tr("PACKAGE")
|
||||
if item is Seed:
|
||||
name_suffix = tr("SEED")
|
||||
if item is Package:
|
||||
name_suffix = tr("PACKAGE")
|
||||
|
||||
return item.name + (" " + name_suffix if name_suffix else "")
|
||||
return item.name + (" " + name_suffix if name_suffix else "")
|
||||
|
||||
func interact_text():
|
||||
return tr("TAKE")
|
||||
return tr("TAKE")
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
return item.card_info()
|
||||
return item.card_info()
|
||||
|
||||
func interact(player : Player) -> bool:
|
||||
player.pick_item(item)
|
||||
|
||||
pickup_animation(player)
|
||||
|
||||
return true
|
||||
player.pick_item(item)
|
||||
|
||||
pickup_animation(player)
|
||||
|
||||
return true
|
||||
|
||||
func pickup_animation(player : Player):
|
||||
available = false
|
||||
var tween : Tween = get_tree().create_tween()
|
||||
available = false
|
||||
var tween : Tween = get_tree().create_tween()
|
||||
|
||||
tween.tween_property(self, "position", player.position, 0.2)
|
||||
tween.tween_callback(
|
||||
func():
|
||||
Pointer.stop_inspect(self)
|
||||
queue_free()
|
||||
)
|
||||
if object_sprite:
|
||||
object_sprite.pickup_animation()
|
||||
tween.tween_property(self, "position", player.position, 0.2)
|
||||
tween.tween_callback(
|
||||
func():
|
||||
Pointer.stop_inspect(self)
|
||||
queue_free()
|
||||
)
|
||||
if object_sprite:
|
||||
object_sprite.pickup_animation()
|
||||
|
||||
func generate_sprite() -> ItemObjectSprite:
|
||||
var sprite_node = SPRITE_SCENE.instantiate() as ItemObjectSprite
|
||||
add_child(sprite_node)
|
||||
var sprite_node = SPRITE_SCENE.instantiate() as ItemObjectSprite
|
||||
add_child(sprite_node)
|
||||
|
||||
if item:
|
||||
sprite_node.apply_texture_to_sprite(
|
||||
item.icon,
|
||||
ITEM_SPRITE_SIZE
|
||||
)
|
||||
if item:
|
||||
sprite_node.apply_texture_to_sprite(
|
||||
item.icon,
|
||||
ITEM_SPRITE_SIZE
|
||||
)
|
||||
|
||||
return sprite_node
|
||||
return sprite_node
|
||||
|
||||
func save() -> EntityData:
|
||||
return ItemObjectData.new(self)
|
||||
return ItemObjectData.new(self)
|
||||
|
||||
@@ -7,5 +7,5 @@ func _init(e : ItemObject):
|
||||
position = e.global_position
|
||||
item = e.item
|
||||
|
||||
func load() -> Entity:
|
||||
func load_entity() -> Entity:
|
||||
return ItemObject.new(item)
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -3,15 +3,15 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dlrj7tyi5wfh8"
|
||||
path="res://.godot/imported/truck_ladder.png-00d93dc49c0cc6457febb75d7b82dec4.ctex"
|
||||
path="res://.godot/imported/truck_ladder.png-925870bf5fd0f6bfe7226189e1ff2e75.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/interactables/truck/assets/sprites/truck_ladder.png"
|
||||
dest_files=["res://.godot/imported/truck_ladder.png-00d93dc49c0cc6457febb75d7b82dec4.ctex"]
|
||||
source_file="res://entities/interactables/ladder/assets/truck_ladder.png"
|
||||
dest_files=["res://.godot/imported/truck_ladder.png-925870bf5fd0f6bfe7226189e1ff2e75.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
170
entities/interactables/ladder/ladder.tscn
Normal file
@@ -0,0 +1,170 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://cg1visg52i21a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://buimaomxu01wj" path="res://entities/interactables/ladder/scripts/ladder.gd" id="1_26qdk"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/ladder/assets/truck_ladder.png" id="2_xila4"]
|
||||
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="3_214ms"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hslnw"]
|
||||
radius = 26.0
|
||||
height = 112.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gmirm"]
|
||||
atlas = ExtResource("2_xila4")
|
||||
region = Rect2(205, 157, 87, 208)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4ixvu"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_214ms"]
|
||||
resource_name = "Pulse"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:scale")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.4, 0.8),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1.4, 1.4), Vector2(1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_px7p1"]
|
||||
_data = {
|
||||
&"Pulse": SubResource("Animation_214ms"),
|
||||
&"RESET": SubResource("Animation_4ixvu")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bgoyn"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("TruckLadder:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(-1.25, -30)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Icon:self_modulate:a")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("TruckLadder:modulate:a")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xvoyd"]
|
||||
resource_name = "appear"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("TruckLadder:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.7),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, -108), Vector2(-1.25, -30)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Icon:self_modulate:a")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.6666667, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 1.0]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("TruckLadder:modulate:a")
|
||||
tracks/2/interp = 2
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 1.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_orxxj"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_bgoyn"),
|
||||
&"appear": SubResource("Animation_xvoyd")
|
||||
}
|
||||
|
||||
[node name="Ladder" type="Area2D"]
|
||||
script = ExtResource("1_26qdk")
|
||||
default_interact_text = "ENTER_TRUCK"
|
||||
default_info_title = "TRUCK_ENTRANCE"
|
||||
default_info_desc = "LADDER_DESC_TEXT"
|
||||
metadata/_custom_type_script = "uid://dyprcd68fjstf"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-0.25, -28)
|
||||
shape = SubResource("CapsuleShape2D_hslnw")
|
||||
|
||||
[node name="TruckLadder" type="Sprite2D" parent="."]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
position = Vector2(-1.25, -30)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = SubResource("AtlasTexture_gmirm")
|
||||
|
||||
[node name="Icon" type="Sprite2D" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0)
|
||||
position = Vector2(0.75, -29.000004)
|
||||
texture = ExtResource("3_214ms")
|
||||
|
||||
[node name="IconAnimationPlayer" type="AnimationPlayer" parent="Icon"]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_px7p1")
|
||||
}
|
||||
autoplay = "RESET"
|
||||
|
||||
[node name="LadderAnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_orxxj")
|
||||
}
|
||||
20
entities/interactables/ladder/scripts/ladder.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends Interactable
|
||||
class_name Ladder
|
||||
|
||||
func _ready():
|
||||
appear()
|
||||
# hide()
|
||||
GameInfo.game_data.current_region_data.updated.connect(
|
||||
func (region_data : RegionData):
|
||||
if region_data.get_state() == RegionData.State.SUCCEEDED or region_data.get_state() == RegionData.State.FAILED:
|
||||
%IconAnimationPlayer.play("Pulse")
|
||||
)
|
||||
|
||||
func appear():
|
||||
show()
|
||||
%LadderAnimationPlayer.play("appear")
|
||||
|
||||
func interact(p : Player):
|
||||
p.region.save()
|
||||
SceneManager.change_scene("COCKPIT")
|
||||
return true
|
||||
@@ -1,27 +0,0 @@
|
||||
extends Interactable
|
||||
class_name Machine
|
||||
|
||||
const MAX_MACHINE_LEVEL = 3
|
||||
|
||||
var level : int = 1
|
||||
var type : MachineType
|
||||
|
||||
func pointer_text() -> String:
|
||||
return type.name
|
||||
|
||||
static func get_level_color(l : int) -> Color:
|
||||
match l:
|
||||
1: return Color("4ed38a")
|
||||
2: return Color("4ec6ee")
|
||||
3: return Color("bd70e2")
|
||||
_: return Color("bd70e2")
|
||||
|
||||
static func instantiate_machine(machine_type : MachineType, machine_level = 1) -> Machine:
|
||||
var new_machine : Machine = machine_type.scene.instantiate() as Machine
|
||||
new_machine.level = machine_level
|
||||
new_machine.type = machine_type
|
||||
|
||||
return new_machine
|
||||
|
||||
func save() -> EntityData:
|
||||
return MachineData.new(self)
|
||||
@@ -1 +0,0 @@
|
||||
uid://du7qppxobx5nd
|
||||
@@ -1,13 +0,0 @@
|
||||
extends EntityData
|
||||
class_name MachineData
|
||||
|
||||
@export var level : int
|
||||
@export var type : MachineType
|
||||
|
||||
func _init(m : Machine):
|
||||
position = m.global_position
|
||||
level = m.level
|
||||
type = m.type
|
||||
|
||||
func load() -> Entity:
|
||||
return Machine.instantiate_machine(type, level)
|
||||
@@ -1 +0,0 @@
|
||||
uid://b24o2jgqvfact
|
||||
@@ -1,6 +0,0 @@
|
||||
extends Resource
|
||||
class_name MachineType
|
||||
|
||||
@export var name : String
|
||||
@export var scene : PackedScene
|
||||
@export_multiline var description : String
|
||||
@@ -1 +0,0 @@
|
||||
uid://bepx311a3f0o
|
||||
|
Before Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 657 KiB |
|
Before Width: | Height: | Size: 369 KiB |
@@ -1,90 +0,0 @@
|
||||
extends Machine
|
||||
class_name SolarPanel
|
||||
|
||||
const ENERGY_ICON = preload("res://common/icons/bolt.svg")
|
||||
|
||||
var charged : bool = false
|
||||
var recharge_days : int = 0
|
||||
|
||||
func get_days_to_recharge(l : int = level) -> int:
|
||||
match l:
|
||||
1: return 2
|
||||
2: return 2
|
||||
3: return 2
|
||||
_: return 1
|
||||
|
||||
func get_energy_production(l : int = level) -> int:
|
||||
match l:
|
||||
1: return 1
|
||||
2: return 2
|
||||
3: return 3
|
||||
_: return 1
|
||||
|
||||
# Méthode déclenchée par la classe planet
|
||||
func _pass_day():
|
||||
if not charged:
|
||||
recharge_days += 1
|
||||
if recharge_days >= get_days_to_recharge():
|
||||
set_charged(true)
|
||||
|
||||
func set_charged(_charged = true, with_anim : bool = true):
|
||||
charged = _charged
|
||||
recharge_days = 0
|
||||
if with_anim:
|
||||
if charged:
|
||||
%AnimationPlayer.play("charged")
|
||||
else :
|
||||
%AnimationPlayer.play_backwards("charged")
|
||||
await %AnimationPlayer.animation_finished
|
||||
%Flair.modulate = Color.WHITE if charged else Color.TRANSPARENT
|
||||
%Pannels.modulate = Color.WHITE if charged else Color("6c6c6c")
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
if default_info_desc != "":
|
||||
var desc_section = CardSectionInfo.new(
|
||||
tr("DESCRIPTION"),
|
||||
default_info_desc
|
||||
)
|
||||
desc_section.title_icon = DESC_ICON
|
||||
info.sections.append(
|
||||
desc_section
|
||||
)
|
||||
|
||||
var charged_text = tr("CHARGED")
|
||||
|
||||
if not charged and (get_days_to_recharge() - recharge_days) == 1:
|
||||
charged_text = tr("1_DAY_BEFORE_CHARGE")
|
||||
elif not charged and (get_days_to_recharge() - recharge_days) > 1:
|
||||
charged_text = tr("%d_DAYS_BEFORE_CHARGE") % (get_days_to_recharge() - recharge_days)
|
||||
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
charged_text,
|
||||
ENERGY_ICON
|
||||
)
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
|
||||
func setup_machine_sprite():
|
||||
# %Base.self_modulate = Machine.get_level_color(level)
|
||||
pass
|
||||
|
||||
func interact_text():
|
||||
return tr("RECHARGE_%d_ENERGY") % get_energy_production()
|
||||
|
||||
func can_interact(_p : Player) -> bool:
|
||||
return charged
|
||||
|
||||
func interact(p : Player) -> bool:
|
||||
p.recharge(get_energy_production())
|
||||
set_charged(false)
|
||||
return true
|
||||
|
||||
func save() -> EntityData:
|
||||
return SolarPanelData.new(self)
|
||||
@@ -1 +0,0 @@
|
||||
uid://bjy8gc0eyl2ss
|
||||
@@ -1,19 +0,0 @@
|
||||
extends MachineData
|
||||
class_name SolarPanelData
|
||||
|
||||
@export var charged : bool = false
|
||||
@export var recharge_days : int = 0
|
||||
|
||||
func _init(m : SolarPanel):
|
||||
position = m.global_position
|
||||
level = m.level
|
||||
type = m.type
|
||||
charged = m.charged
|
||||
recharge_days = m.recharge_days
|
||||
|
||||
func load() -> Entity:
|
||||
var sp = Machine.instantiate_machine(type, level) as SolarPanel
|
||||
sp.set_charged(charged, false)
|
||||
sp.recharge_days = recharge_days
|
||||
|
||||
return sp
|
||||
@@ -1 +0,0 @@
|
||||
uid://dv1tok0civrpp
|
||||
@@ -1,11 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="MachineType" load_steps=3 format=3 uid="uid://dew3p4fffjryo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bepx311a3f0o" path="res://entities/interactables/machines/scripts/machine_type.gd" id="1_ctita"]
|
||||
[ext_resource type="PackedScene" uid="uid://gwq2oos6ljyp" path="res://entities/interactables/machines/solar_pannel/solar_pannel.tscn" id="1_naexs"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ctita")
|
||||
name = "SOLAR_PANNEL"
|
||||
scene = ExtResource("1_naexs")
|
||||
description = "SOLAR_PANNEL_DESCRIPTION_TEXT"
|
||||
metadata/_custom_type_script = "uid://bepx311a3f0o"
|
||||
@@ -1,104 +0,0 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://gwq2oos6ljyp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bjy8gc0eyl2ss" path="res://entities/interactables/machines/solar_pannel/scripts/solar_pannel.gd" id="1_t4vnu"]
|
||||
[ext_resource type="Texture2D" uid="uid://b1n8nad43usw4" path="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_2.png" id="2_ny3sb"]
|
||||
[ext_resource type="Texture2D" uid="uid://cqqlkm14lawpa" path="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_1.png" id="3_bml32"]
|
||||
[ext_resource type="Texture2D" uid="uid://c22re5wfsm1ax" path="res://entities/interactables/machines/solar_pannel/assets/sprites/panneau_solaire_3.png" id="4_ob8kj"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6utw7"]
|
||||
radius = 48.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_77hon"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprites/Pannels:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0.42352942, 0.42352942, 0.42352942, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprites/Flair:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_gal8b"]
|
||||
resource_name = "charged"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprites/Pannels:modulate")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.033333335, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.42365062, 0.42365065, 0.42365062, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Sprites/Flair:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5vw1f"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_77hon"),
|
||||
&"charged": SubResource("Animation_gal8b")
|
||||
}
|
||||
|
||||
[node name="SolarPannel" type="Area2D"]
|
||||
script = ExtResource("1_t4vnu")
|
||||
default_interact_text = "USE"
|
||||
default_info_title = "SOLAR_PANNEL"
|
||||
default_info_desc = "SOLAR_PANNEL_DESCRIPTION_TEXT"
|
||||
metadata/_custom_type_script = "uid://du7qppxobx5nd"
|
||||
|
||||
[node name="Sprites" type="Node2D" parent="."]
|
||||
position = Vector2(15.999999, -16.999998)
|
||||
scale = Vector2(0.09, 0.09)
|
||||
|
||||
[node name="Pannels" type="Sprite2D" parent="Sprites"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.42352942, 0.42352942, 0.42352942, 1)
|
||||
texture = ExtResource("2_ny3sb")
|
||||
|
||||
[node name="Base" type="Sprite2D" parent="Sprites"]
|
||||
unique_name_in_owner = true
|
||||
texture = ExtResource("3_bml32")
|
||||
|
||||
[node name="Flair" type="Sprite2D" parent="Sprites"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
texture = ExtResource("4_ob8kj")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(6, -23)
|
||||
shape = SubResource("CircleShape2D_6utw7")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_5vw1f")
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
extends Interactable
|
||||
class_name TruckLadder
|
||||
|
||||
func interact(p : Player):
|
||||
p.planet.save()
|
||||
SceneManager.change_scene(SceneManager.COCKPIT_SCENE)
|
||||
return true
|
||||
@@ -1,33 +0,0 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cg1visg52i21a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://buimaomxu01wj" path="res://entities/interactables/truck/ladder/scripts/truck_ladder.gd" id="1_26qdk"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/truck/assets/sprites/truck_ladder.png" id="2_xila4"]
|
||||
[ext_resource type="Texture2D" uid="uid://dex283rx00fjb" path="res://common/icons/logout.svg" id="3_214ms"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hslnw"]
|
||||
radius = 26.0
|
||||
height = 112.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gmirm"]
|
||||
atlas = ExtResource("2_xila4")
|
||||
region = Rect2(205, 157, 87, 208)
|
||||
|
||||
[node name="TruckLadder" type="Area2D"]
|
||||
script = ExtResource("1_26qdk")
|
||||
default_interact_text = "ENTER_TRUCK"
|
||||
default_info_title = "TRUCK_ENTRANCE"
|
||||
default_info_desc = "LADDER_DESC_TEXT"
|
||||
metadata/_custom_type_script = "uid://dyprcd68fjstf"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-0.25, -28)
|
||||
shape = SubResource("CapsuleShape2D_hslnw")
|
||||
|
||||
[node name="TruckLadder" type="Sprite2D" parent="."]
|
||||
position = Vector2(-1.25, -30)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = SubResource("AtlasTexture_gmirm")
|
||||
|
||||
[node name="Bolt" type="Sprite2D" parent="."]
|
||||
position = Vector2(0.75, -29.000004)
|
||||
texture = ExtResource("3_214ms")
|
||||
@@ -1,20 +1,24 @@
|
||||
extends Interactable
|
||||
class_name TruckRecharge
|
||||
|
||||
func _ready():
|
||||
if region:
|
||||
%Bolt.modulate = Color.WHITE if region.data.charges > 0 else Color.RED
|
||||
|
||||
func can_interact(_p : Player) -> bool:
|
||||
return (
|
||||
planet != null
|
||||
and planet.data
|
||||
and planet.data.charges > 0
|
||||
region != null
|
||||
and region.data
|
||||
and region.data.charges > 0
|
||||
)
|
||||
|
||||
func interact(_p: Player) -> bool:
|
||||
|
||||
if can_interact(_p):
|
||||
planet.data.charges -= 1
|
||||
planet.pass_day()
|
||||
region.data.charges -= 1
|
||||
region.pass_day()
|
||||
|
||||
%Bolt.modulate = Color.WHITE if planet.data.charges > 0 else Color.RED
|
||||
%Bolt.modulate = Color.WHITE if region.data.charges > 0 else Color.RED
|
||||
|
||||
return true
|
||||
return false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://d324mlmgls4fs"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bsrn3gd2a532q" path="res://entities/interactables/truck/recharge/scripts/truck_recharge.gd" id="1_ipgcv"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/truck/assets/sprites/truck_ladder.png" id="2_87dtp"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlrj7tyi5wfh8" path="res://entities/interactables/ladder/assets/truck_ladder.png" id="2_87dtp"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_jcfmm"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bjhct"]
|
||||
|
||||
BIN
entities/plants/assets/sprites/default/dead.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
@@ -2,16 +2,16 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d2p7h0aga85tn"
|
||||
path="res://.godot/imported/truck_interior.png-ff9bd2d0107d83f7c4209d959ee69f15.ctex"
|
||||
uid="uid://b0kllgnpxuh54"
|
||||
path="res://.godot/imported/dead.png-ef8b87be14a560f3ce6b4050f956f227.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://stages/terrain/truck/assets/sprite/truck_interior.png"
|
||||
dest_files=["res://.godot/imported/truck_interior.png-ff9bd2d0107d83f7c4209d959ee69f15.ctex"]
|
||||
source_file="res://entities/plants/assets/sprites/default/dead.png"
|
||||
dest_files=["res://.godot/imported/dead.png-ef8b87be14a560f3ce6b4050f956f227.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@@ -3,15 +3,15 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c00jac2jlgdfu"
|
||||
path="res://.godot/imported/growing.png-47abe743f83ddd7bdc16b98f9d66692f.ctex"
|
||||
path="res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/solita/growing.png"
|
||||
dest_files=["res://.godot/imported/growing.png-47abe743f83ddd7bdc16b98f9d66692f.ctex"]
|
||||
source_file="res://entities/plants/assets/sprites/default/growing.png"
|
||||
dest_files=["res://.godot/imported/growing.png-3f6fb3171589f3a22ebfeda1a4575199.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
@@ -3,15 +3,15 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b3wom2xu26g43"
|
||||
path="res://.godot/imported/mature.png-834a1cd5820fc22805f96d5019fd7c30.ctex"
|
||||
path="res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/solita/mature.png"
|
||||
dest_files=["res://.godot/imported/mature.png-834a1cd5820fc22805f96d5019fd7c30.ctex"]
|
||||
source_file="res://entities/plants/assets/sprites/default/mature.png"
|
||||
dest_files=["res://.godot/imported/mature.png-f8b2b72a84e90cfc6bf925d1d48f7f7e.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
BIN
entities/plants/assets/sprites/default/seed.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
40
entities/plants/assets/sprites/default/seed.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bruce7ds0u8i1"
|
||||
path="res://.godot/imported/seed.png-634c35552c5b52a8d7f2a15b4c2c65e4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://entities/plants/assets/sprites/default/seed.png"
|
||||
dest_files=["res://.godot/imported/seed.png-634c35552c5b52a8d7f2a15b4c2c65e4.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
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
|
||||
6
entities/plants/assets/sprites/seeds/seeds.tres
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://m48oo6cqbq37"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="1_v3qq7"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_v3qq7")
|
||||
@@ -1,28 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://cxrc5wchpqm18"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="1_cf34j"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_ipcpv"]
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_l2hi3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dmsls8siudy1u" path="res://entities/plants/assets/sprites/champ/growing.png" id="2_l2hi3"]
|
||||
[ext_resource type="Texture2D" uid="uid://crc4aop6ajiau" path="res://entities/plants/assets/sprites/champ/mature.png" id="3_y8qve"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_liopn"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_cf34j"]
|
||||
script = ExtResource("1_cf34j")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_my6by"]
|
||||
atlas = ExtResource("6_liopn")
|
||||
region = Rect2(610, 315, 124, 180)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ipcpv")
|
||||
name = "Champ"
|
||||
description = "A cool fluorescent mushroom that reproduce very fast."
|
||||
default_growing_time = 3
|
||||
seed_texture = SubResource("AtlasTexture_my6by")
|
||||
growing_texture = ExtResource("2_l2hi3")
|
||||
mature_texture = ExtResource("3_y8qve")
|
||||
mature_effects = Array[ExtResource("1_l2hi3")]([SubResource("Resource_cf34j")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,34 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://b04vho33bl52b"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_40c3e"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_moyj3"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7mp7tkkkk6o5" path="res://entities/plants/assets/sprites/chardi/growing.png" id="1_prk5s"]
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_prk5s"]
|
||||
[ext_resource type="Texture2D" uid="uid://bupl1y0cfj21q" path="res://entities/plants/assets/sprites/chardi/mature.png" id="3_40c3e"]
|
||||
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="3_ajihu"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_cky1j"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_40c3e"]
|
||||
script = ExtResource("2_prk5s")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ajihu"]
|
||||
script = ExtResource("3_ajihu")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qt76e"]
|
||||
atlas = ExtResource("6_cky1j")
|
||||
region = Rect2(1140, 345, 141, 128)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_moyj3")
|
||||
name = "Chardi"
|
||||
description = "This fern use the bas component of the ground to grow."
|
||||
seed_texture = SubResource("AtlasTexture_qt76e")
|
||||
growing_texture = ExtResource("1_prk5s")
|
||||
mature_texture = ExtResource("3_40c3e")
|
||||
harvest_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_40c3e")])
|
||||
mature_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_ajihu")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,33 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://djap3rggcdf3r"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_srjq6"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_72r72"]
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_rb4mq"]
|
||||
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="3_s6g12"]
|
||||
[ext_resource type="Texture2D" uid="uid://ds1nf2876m6bh" path="res://entities/plants/assets/sprites/ferno/growing.png" id="4_5qaoo"]
|
||||
[ext_resource type="Texture2D" uid="uid://bfj6wji21amgk" path="res://entities/plants/assets/sprites/ferno/mature.png" id="5_er4cp"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_0y7r8"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rb4mq"]
|
||||
script = ExtResource("2_rb4mq")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_s6g12"]
|
||||
script = ExtResource("3_s6g12")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g1td4"]
|
||||
atlas = ExtResource("7_0y7r8")
|
||||
region = Rect2(57, 620, 159, 99)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_72r72")
|
||||
name = "Ferno"
|
||||
description = "This mysterious flower emmit a strong signal in the ground when harvested."
|
||||
seed_texture = SubResource("AtlasTexture_g1td4")
|
||||
growing_texture = ExtResource("4_5qaoo")
|
||||
mature_texture = ExtResource("5_er4cp")
|
||||
harvest_effects = Array[ExtResource("1_srjq6")]([SubResource("Resource_rb4mq"), SubResource("Resource_s6g12")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,27 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://dsctivn1vrem2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_740j2"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_eqtut"]
|
||||
[ext_resource type="Texture2D" uid="uid://dwr3c6r6piwaa" path="res://entities/plants/assets/sprites/maias/growing.png" id="1_vyplc"]
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_740j2"]
|
||||
[ext_resource type="Texture2D" uid="uid://d3apfwbqsg5ha" path="res://entities/plants/assets/sprites/maias/mature.png" id="3_pi4ie"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_mwrj8"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_740j2"]
|
||||
script = ExtResource("2_740j2")
|
||||
level = 3
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3b"]
|
||||
atlas = ExtResource("6_mwrj8")
|
||||
region = Rect2(1697, 331, 125, 158)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_eqtut")
|
||||
name = "Maias"
|
||||
description = "This gorgeous flower produce a lot of seeds when harvested."
|
||||
seed_texture = SubResource("AtlasTexture_sri3b")
|
||||
growing_texture = ExtResource("1_vyplc")
|
||||
mature_texture = ExtResource("3_pi4ie")
|
||||
harvest_effects = Array[ExtResource("1_740j2")]([SubResource("Resource_740j2")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,29 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://dr4omh4gf85hl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_mi4ef"]
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_jyjjp"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_lqh06"]
|
||||
[ext_resource type="Texture2D" uid="uid://dna7x371cs0tu" path="res://entities/plants/assets/sprites/philea/growing.png" id="3_n0hvm"]
|
||||
[ext_resource type="Texture2D" uid="uid://bj801geprrhfu" path="res://entities/plants/assets/sprites/philea/mature.png" id="4_cafy4"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_oaspo"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jyjjp"]
|
||||
script = ExtResource("2_jyjjp")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ogrgq"]
|
||||
atlas = ExtResource("6_oaspo")
|
||||
region = Rect2(322, 598, 159, 136)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_lqh06")
|
||||
name = "Philea"
|
||||
description = "A very cool shurb that glow in the night."
|
||||
default_growing_time = 5
|
||||
default_plant_score = 3
|
||||
seed_texture = SubResource("AtlasTexture_ogrgq")
|
||||
growing_texture = ExtResource("3_n0hvm")
|
||||
mature_texture = ExtResource("4_cafy4")
|
||||
mature_effects = Array[ExtResource("1_mi4ef")]([SubResource("Resource_jyjjp")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,35 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=11 format=3 uid="uid://c5oxxif3h5yxo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_8fstu"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="1_vn146"]
|
||||
[ext_resource type="Script" uid="uid://cgscbuxe4dawb" path="res://entities/plants/scripts/plant_effects/decontaminate_terrain_effect.gd" id="2_8fstu"]
|
||||
[ext_resource type="Texture2D" uid="uid://xw47qw12d3dv" path="res://entities/plants/assets/sprites/pili/growing.png" id="2_k4b1k"]
|
||||
[ext_resource type="Texture2D" uid="uid://4mh1w1f4q2sa" path="res://entities/plants/assets/sprites/pili/mature.png" id="3_8fstu"]
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="3_26e4l"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="5_26e4l"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8fstu"]
|
||||
script = ExtResource("3_26e4l")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_26e4l"]
|
||||
script = ExtResource("2_8fstu")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kidty"]
|
||||
atlas = ExtResource("5_26e4l")
|
||||
region = Rect2(1415, 91, 149, 102)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_vn146")
|
||||
name = "Pili"
|
||||
description = "This cool plant produce softs and warms blue flames."
|
||||
default_growing_time = 3
|
||||
seed_texture = SubResource("AtlasTexture_kidty")
|
||||
growing_texture = ExtResource("2_k4b1k")
|
||||
mature_texture = ExtResource("3_8fstu")
|
||||
harvest_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_8fstu")])
|
||||
mature_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_26e4l")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,29 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlantType" load_steps=9 format=3 uid="uid://cuk3hl5tkjhmg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpycohqas4hff" path="res://entities/plants/scripts/plant_effect.gd" id="1_mksys"]
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_1q5bp"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_x4nie"]
|
||||
[ext_resource type="Texture2D" uid="uid://c00jac2jlgdfu" path="res://entities/plants/assets/sprites/solita/growing.png" id="3_j4n5p"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/solita/mature.png" id="4_njidq"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_yn0yu"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_j4n5p"]
|
||||
script = ExtResource("2_1q5bp")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_auuc2"]
|
||||
atlas = ExtResource("6_yn0yu")
|
||||
region = Rect2(335, 74, 134, 142)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_x4nie")
|
||||
name = "Solita"
|
||||
description = "A magnificient flower that reflect the light of nearest star."
|
||||
default_growing_time = 3
|
||||
default_plant_score = 2
|
||||
seed_texture = SubResource("AtlasTexture_auuc2")
|
||||
growing_texture = ExtResource("3_j4n5p")
|
||||
mature_texture = ExtResource("4_njidq")
|
||||
harvest_effects = Array[ExtResource("1_mksys")]([SubResource("Resource_j4n5p")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
@@ -1,205 +1,184 @@
|
||||
extends InspectableEntity
|
||||
class_name Plant
|
||||
|
||||
signal harvested(p: Plant)
|
||||
signal state_changed(p: Plant)
|
||||
|
||||
const PLANT_AREA_RADIUS = 20
|
||||
const PLANT_INFLUENCE_RADIUS = 100
|
||||
const HARVESTED_SEED_DISPLACEMENT_FACTOR = 100
|
||||
|
||||
const RANDOM_MAX_GROW_INTERVAL = Planet.MIN_PASS_DAY_ANIMATION_TIME/2. - 0.1
|
||||
const RANDOM_MAX_GROW_INTERVAL = Region.MIN_PASS_DAY_ANIMATION_TIME/2. - 0.1
|
||||
const PLANT_TYPE_ICON = preload("res://common/icons/seedling.svg")
|
||||
const PLANT_POINT_ICON = preload("res://common/icons/growth.svg")
|
||||
const LIFETIME_ICON = preload("res://common/icons/calendar-week.svg")
|
||||
const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
|
||||
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const DEATH_ICON = preload("res://common/icons/skull.svg")
|
||||
|
||||
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE}
|
||||
|
||||
@export var plant_type: PlantType
|
||||
|
||||
var state: State = State.PLANTED
|
||||
@export var day: int
|
||||
@export var data : PlantData
|
||||
|
||||
@onready var plant_sprite: PlantSprite
|
||||
@onready var collision_shape: CollisionShape2D
|
||||
@onready var influence_zone : PlantInfluenceZone
|
||||
|
||||
var plant_score = 0
|
||||
var plant_mutations : Array[PlantMutation] = []
|
||||
|
||||
func _init(
|
||||
_plant_type : PlantType,
|
||||
_plant_mutations : Array[PlantMutation] = [],
|
||||
_day = 0,
|
||||
_data : PlantData
|
||||
):
|
||||
plant_type = _plant_type
|
||||
|
||||
day = _day
|
||||
|
||||
plant_mutations = _plant_mutations
|
||||
data = _data
|
||||
|
||||
func _ready():
|
||||
plant_sprite = generate_sprite()
|
||||
collision_shape = generate_collision_shape()
|
||||
influence_zone = generate_influence_zone()
|
||||
plant_sprite = generate_sprite()
|
||||
collision_shape = generate_collision_shape()
|
||||
influence_zone = generate_influence_zone()
|
||||
|
||||
update_plant(false)
|
||||
plant_sprite.update_plant_sprite(self, false)
|
||||
plant_sprite.update_plant_sprite(data, false)
|
||||
|
||||
func pointer_text() -> String:
|
||||
return plant_type.name
|
||||
return data.plant_name
|
||||
|
||||
func inspect(is_inspected : bool = true):
|
||||
plant_sprite.modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
|
||||
influence_zone.show_influence = is_inspected
|
||||
plant_sprite.modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
|
||||
influence_zone.show_influence = is_inspected
|
||||
|
||||
func affect_preview(is_affected : bool = true):
|
||||
plant_sprite.modulate = MODULATE_AFFECTED_COLOR if is_affected else default_modulate
|
||||
plant_sprite.modulate = MODULATE_AFFECTED_COLOR if is_affected else default_modulate
|
||||
|
||||
func generate_sprite() -> PlantSprite:
|
||||
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
var sprite_object : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
|
||||
add_child(sprite_object)
|
||||
sprite_object.generate_mutation_effects(self)
|
||||
add_child(sprite_object)
|
||||
sprite_object.generate_mutation_effects(self)
|
||||
|
||||
return sprite_object
|
||||
return sprite_object
|
||||
|
||||
func generate_collision_shape() -> CollisionShape2D:
|
||||
var collision = CollisionShape2D.new()
|
||||
var shape = CircleShape2D.new()
|
||||
shape.radius = PLANT_AREA_RADIUS
|
||||
var collision = CollisionShape2D.new()
|
||||
var shape = CircleShape2D.new()
|
||||
shape.radius = PLANT_AREA_RADIUS
|
||||
|
||||
collision.shape = shape
|
||||
add_child(collision)
|
||||
collision.shape = shape
|
||||
add_child(collision)
|
||||
|
||||
return collision
|
||||
return collision
|
||||
|
||||
func generate_influence_zone() -> PlantInfluenceZone:
|
||||
var zone = PlantInfluenceZone.new(PLANT_INFLUENCE_RADIUS)
|
||||
var zone = PlantInfluenceZone.new(PLANT_INFLUENCE_RADIUS)
|
||||
|
||||
add_child(zone)
|
||||
add_child(zone)
|
||||
|
||||
return zone
|
||||
return zone
|
||||
|
||||
# Méthode déclenchée par la classe planet
|
||||
# Méthode déclenchée par la classe region
|
||||
func _pass_day():
|
||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||
|
||||
if state == State.MATURE and len(plant_type.cyclic_effects):
|
||||
for effect in plant_type.cyclic_effects:
|
||||
effect.effect(self)
|
||||
|
||||
var old_state = state
|
||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||
|
||||
var last_state = data.get_state()
|
||||
|
||||
day += 1
|
||||
update_plant()
|
||||
data.day += 1
|
||||
|
||||
for m in data.mutations:
|
||||
m._start_day_effect(self)
|
||||
|
||||
if old_state != state and state == State.MATURE:
|
||||
for effect in plant_type.mature_effects:
|
||||
if effect : effect.effect(self)
|
||||
for effect in plant_type.cyclic_effects:
|
||||
if effect : effect.effect(self)
|
||||
match data.get_state():
|
||||
PlantData.State.MATURE:
|
||||
if last_state != PlantData.State.MATURE:
|
||||
mature()
|
||||
PlantData.State.DEAD:
|
||||
die()
|
||||
|
||||
|
||||
plant_sprite.update_plant_sprite(data, last_state != data.get_state())
|
||||
|
||||
func update_plant(with_animation : bool = true):
|
||||
if day + 1 > calculate_grow_time():
|
||||
if state != State.MATURE:
|
||||
change_state(State.MATURE, with_animation)
|
||||
elif day == 0:
|
||||
change_state(State.PLANTED, with_animation)
|
||||
else:
|
||||
if state != State.GROWING:
|
||||
change_state(State.GROWING, with_animation)
|
||||
|
||||
func calculate_plant_score(
|
||||
overwite_state : State = state
|
||||
with_state : PlantData.State = data.get_state()
|
||||
) -> int:
|
||||
var mutated_plant_score = plant_type.default_plant_score if overwite_state == State.MATURE else 0
|
||||
|
||||
for m in plant_mutations:
|
||||
mutated_plant_score = m.mutate_score(overwite_state, self, mutated_plant_score)
|
||||
|
||||
return mutated_plant_score
|
||||
|
||||
func calculate_grow_time() -> int:
|
||||
var mutated_grow_time = plant_type.default_growing_time
|
||||
|
||||
for m in plant_mutations:
|
||||
mutated_grow_time = m.mutate_grow_time(self, mutated_grow_time)
|
||||
|
||||
return max(1, mutated_grow_time)
|
||||
|
||||
func change_state(_state: State, with_animation : bool = true):
|
||||
if state != _state:
|
||||
state = _state
|
||||
|
||||
plant_sprite.update_plant_sprite(self, with_animation)
|
||||
state_changed.emit(self)
|
||||
return data.get_score(with_state)
|
||||
|
||||
func harvest():
|
||||
if state == State.MATURE:
|
||||
for effect in plant_type.harvest_effects:
|
||||
if effect : effect.effect(self)
|
||||
for i in range(data.get_random_seed_income()):
|
||||
produce_seed()
|
||||
|
||||
plant_sprite.start_harvest_animation()
|
||||
await plant_sprite.harvest_animation_finished
|
||||
harvested.emit(self)
|
||||
queue_free()
|
||||
if data.get_state() == PlantData.State.MATURE:
|
||||
for m in data.mutations:
|
||||
m._start_harvested_effect(self)
|
||||
|
||||
plant_sprite.start_harvest_animation()
|
||||
await plant_sprite.harvest_animation_finished
|
||||
disappear()
|
||||
|
||||
func produce_seed():
|
||||
region.drop_item(
|
||||
Seed.generate_from_parent(data),
|
||||
global_position,
|
||||
HARVESTED_SEED_DISPLACEMENT_FACTOR,
|
||||
)
|
||||
|
||||
func mature():
|
||||
for m in data.mutations:
|
||||
m._start_maturation_effect(self)
|
||||
|
||||
func die():
|
||||
for m in data.mutations:
|
||||
m._start_dead_effect(self)
|
||||
disappear()
|
||||
|
||||
func disappear():
|
||||
data.disappear()
|
||||
queue_free()
|
||||
|
||||
func save() -> EntityData:
|
||||
return PlantData.new(self)
|
||||
return data
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
pointer_text()
|
||||
)
|
||||
var info = CardInfo.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
info.important_stat_icon = PLANT_POINT_ICON
|
||||
info.important_stat_text = "%d" % calculate_plant_score()
|
||||
info.texture = plant_type.mature_texture
|
||||
info.type_icon = PLANT_TYPE_ICON
|
||||
var state = data.get_state()
|
||||
|
||||
var state_text = tr("MATURE")
|
||||
if state != State.MATURE:
|
||||
state_text = tr("GROWING")
|
||||
info.important_stat_icon = PLANT_POINT_ICON
|
||||
info.important_stat_text = "%d" % calculate_plant_score()
|
||||
info.texture = null #TODO
|
||||
info.type_icon = PLANT_TYPE_ICON
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("DAY_%d") % day,
|
||||
LIFETIME_ICON
|
||||
))
|
||||
var state_text = tr("MATURE")
|
||||
if state != PlantData.State.MATURE:
|
||||
state_text = tr("GROWING")
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
state_text,
|
||||
PLANT_TYPE_ICON
|
||||
))
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("DAY_%d") % data.day,
|
||||
LIFETIME_ICON
|
||||
))
|
||||
|
||||
if state != State.MATURE:
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("MATURE_ON_DAY_%d") % calculate_grow_time(),
|
||||
GROWING_ICON
|
||||
))
|
||||
info.stats.append(CardStatInfo.new(
|
||||
state_text,
|
||||
PLANT_TYPE_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("%d_SCORE_WHEN_MATURE") % calculate_plant_score(State.MATURE),
|
||||
PLANT_POINT_ICON
|
||||
))
|
||||
if state != PlantData.State.MATURE:
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("MATURE_ON_DAY_%d") % data.get_growing_time(),
|
||||
GROWING_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("%d_SCORE_WHEN_MATURE") % data.get_score(PlantData.State.MATURE),
|
||||
PLANT_POINT_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("DIE_ON_DAY_%d") % (data.get_lifetime()),
|
||||
DEATH_ICON
|
||||
))
|
||||
|
||||
|
||||
if len(plant_mutations) != 0:
|
||||
var rarest : int = plant_mutations.map(
|
||||
func(m : PlantMutation) : return m.get_rarity()
|
||||
).max()
|
||||
info.bg_color = PlantMutation.get_rarity_color(rarest)
|
||||
for m in plant_mutations:
|
||||
info.sections.append(m.card_section())
|
||||
if len(data.mutations) != 0:
|
||||
var rarest : int = data.mutations.map(
|
||||
func(m : PlantMutation) : return m.get_rarity()
|
||||
).max()
|
||||
info.bg_color = PlantMutation.get_rarity_color(rarest)
|
||||
for m in data.mutations:
|
||||
info.sections.append(m.card_section())
|
||||
|
||||
info.sections.append_array(PlantEffect.card_effect_sections(
|
||||
plant_type.mature_effects,
|
||||
plant_type.harvest_effects,
|
||||
plant_type.cyclic_effects,
|
||||
))
|
||||
|
||||
return info
|
||||
return info
|
||||
|
||||
19
entities/plants/scripts/plant_archetype.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
@tool
|
||||
extends Resource
|
||||
class_name PlantArchetype
|
||||
|
||||
@export var archetype_name = Random.generate_random_name()
|
||||
@export var texture_builder = TextureBuilder.new()
|
||||
@export var plant_area_radius = 20
|
||||
@export var plant_influence_radius = 100
|
||||
@export var growing_time= 2
|
||||
@export var lifetime = 5
|
||||
@export var base_score = 1
|
||||
@export var seed_number = 2
|
||||
@export var seed_random_loose = 1
|
||||
@export var available_mutations : Array[PlantMutation] = [
|
||||
AncientMutation.new(),
|
||||
PrecociousMutation.new(),
|
||||
QualityMutation.new(),
|
||||
QuickMutation.new()
|
||||
]
|
||||
1
entities/plants/scripts/plant_archetype.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://chdj832c0rrky
|
||||
@@ -1,20 +1,114 @@
|
||||
extends EntityData
|
||||
class_name PlantData
|
||||
|
||||
var plant_type : PlantType
|
||||
var plant_mutations : Array[PlantMutation]
|
||||
var day : int
|
||||
signal updated(p : PlantData)
|
||||
signal disappeared(p : PlantData)
|
||||
|
||||
func _init(plant : Plant):
|
||||
position = plant.global_position
|
||||
plant_type = plant.plant_type
|
||||
plant_mutations = plant.plant_mutations
|
||||
day = plant.day
|
||||
enum State {PLANTED, GROWING, MATURE, DEAD}
|
||||
|
||||
func load() -> Entity:
|
||||
var plant = Plant.new(
|
||||
plant_type,
|
||||
plant_mutations,
|
||||
day
|
||||
@export var archetype: PlantArchetype
|
||||
@export var plant_name : String
|
||||
@export var mutations : Array[PlantMutation]
|
||||
@export var day : int :
|
||||
set(v):
|
||||
day = v
|
||||
updated.emit(self)
|
||||
@export var random_seed : int
|
||||
|
||||
@export var leafs = 0 # +1 score
|
||||
@export var roots = 0 # +1 lifetime
|
||||
|
||||
func _init(
|
||||
_position : Vector2,
|
||||
_archetype : PlantArchetype,
|
||||
_plant_name : String = Random.generate_random_name(),
|
||||
_mutations : Array[PlantMutation] = [],
|
||||
_day : int = 0,
|
||||
_random_seed = randi()
|
||||
):
|
||||
position = _position
|
||||
archetype = _archetype
|
||||
plant_name = _plant_name
|
||||
mutations = _mutations
|
||||
day = _day
|
||||
random_seed = _random_seed
|
||||
|
||||
for m in mutations:
|
||||
m.mutate_plant_data(self)
|
||||
|
||||
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
|
||||
)
|
||||
return plant
|
||||
|
||||
func load_entity() -> Entity:
|
||||
var plant = Plant.new(
|
||||
self
|
||||
)
|
||||
return plant
|
||||
|
||||
func get_lifetime() -> int:
|
||||
var lifetime = archetype.lifetime + roots
|
||||
|
||||
for m in mutations:
|
||||
lifetime = m.mutate_lifetime(self, lifetime)
|
||||
|
||||
return lifetime
|
||||
|
||||
func get_growing_time() -> int:
|
||||
var growing_time = archetype.growing_time
|
||||
|
||||
for m in mutations:
|
||||
growing_time = m.mutate_growing_time(self, growing_time)
|
||||
|
||||
return growing_time
|
||||
|
||||
func get_score(state : State = get_state()) -> int:
|
||||
var score = archetype.base_score + leafs if state == State.MATURE else 0
|
||||
|
||||
for m in mutations:
|
||||
score = m.mutate_score(self, score)
|
||||
|
||||
return score
|
||||
|
||||
func get_state() -> State:
|
||||
if day >= get_lifetime():
|
||||
return State.DEAD
|
||||
elif day == 0:
|
||||
return State.PLANTED
|
||||
elif day < archetype.growing_time:
|
||||
return State.GROWING
|
||||
return State.MATURE
|
||||
|
||||
func get_plant_texture() -> Texture:
|
||||
return archetype.texture_builder.build_plant_texture(self)
|
||||
|
||||
func get_seed_texture():
|
||||
return archetype.texture_builder.build_seed_texture(random_seed)
|
||||
|
||||
func get_seed_number(state = get_state()):
|
||||
var seed_number = archetype.seed_number if state == State.MATURE else 0
|
||||
|
||||
for m in mutations:
|
||||
seed_number = m.mutate_seed_number(self, seed_number)
|
||||
|
||||
return seed_number
|
||||
|
||||
func get_seed_random_loose():
|
||||
var seed_random_loose = archetype.seed_random_loose
|
||||
for m in mutations:
|
||||
seed_random_loose = m.mutate_seed_random_loose(self, seed_random_loose)
|
||||
|
||||
return seed_random_loose
|
||||
|
||||
func get_random_seed_income():
|
||||
return max(
|
||||
get_seed_number() - randi_range(0, get_seed_random_loose()),
|
||||
0
|
||||
)
|
||||
|
||||
func disappear():
|
||||
disappeared.emit(self)
|
||||
@@ -1,76 +0,0 @@
|
||||
# Classe abstraite permettant de développer divers effets de plantes
|
||||
extends Resource
|
||||
class_name PlantEffect
|
||||
|
||||
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
|
||||
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
|
||||
|
||||
@export var level : int
|
||||
|
||||
func _init(_level : int = 1):
|
||||
level = _level
|
||||
|
||||
func get_effect_name() -> String:
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
return ""
|
||||
|
||||
func get_effect_description() -> String:
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
return ""
|
||||
|
||||
func effect(_plant):
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
|
||||
func get_styled_effect_name():
|
||||
var levels_bbcode = [
|
||||
"[color=#2364AA]%s[/color]",
|
||||
"[color=#25C147]%s %d[/color]",
|
||||
"[color=#8B2DFF]%s %d[/color]",
|
||||
"[color=#FF006E]%s %d[/color]",
|
||||
"[color=#FFA617]%s %d[/color]",
|
||||
"[rainbow]%s %d[/rainbow]"
|
||||
]
|
||||
|
||||
if level == 1:
|
||||
return levels_bbcode[0] % get_effect_name()
|
||||
else :
|
||||
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
|
||||
|
||||
static func card_effect_sections(
|
||||
mature_effects : Array[PlantEffect],
|
||||
harvest_effects : Array[PlantEffect],
|
||||
cyclic_effects : Array[PlantEffect]
|
||||
) -> Array[CardSectionInfo]:
|
||||
var sections : Array[CardSectionInfo] = []
|
||||
var effects_category = [
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects
|
||||
]
|
||||
var effects_category_labels : Array[String] = [
|
||||
"ON_MATURE",
|
||||
"WHEN_HARVESTED",
|
||||
"EACH_DAY_WHEN_MATURE",
|
||||
]
|
||||
var effects_category_icon : Array[Texture] = [
|
||||
MATURE_EFFECT_ICON,
|
||||
HARVEST_EFFECT_ICON,
|
||||
CYCLIC_EFFECT_ICON,
|
||||
]
|
||||
|
||||
for i in range(len(effects_category)):
|
||||
var effects = effects_category[i]
|
||||
|
||||
if len(effects) > 0:
|
||||
var section = CardSectionInfo.new(
|
||||
effects_category_labels[i]
|
||||
)
|
||||
section.title_icon = effects_category_icon[i]
|
||||
var effects_text : Array = effects.map(
|
||||
func (e : PlantEffect): return "[b]%s[/b] %s" % [e.get_styled_effect_name() , e.get_effect_description()]
|
||||
)
|
||||
section.text = "\n".join(effects_text)
|
||||
sections.append(section)
|
||||
|
||||
return sections
|
||||
@@ -1 +0,0 @@
|
||||
uid://bpycohqas4hff
|
||||
@@ -1,20 +0,0 @@
|
||||
extends PlantEffect
|
||||
class_name DecontaminateTerrainEffect
|
||||
|
||||
func get_decontamination_radius():
|
||||
return (1 + level)
|
||||
|
||||
func get_effect_name() -> String:
|
||||
return tr("DECONTAMINATE")
|
||||
|
||||
func get_effect_description() -> String:
|
||||
var ret = tr("DECONTAMINATE_%d_UNIT_AROUND_IT") % [get_decontamination_radius()]
|
||||
return ret
|
||||
|
||||
func effect(plant):
|
||||
var tiles := Math.get_tiles_in_circle(
|
||||
plant.global_position,
|
||||
get_decontamination_radius() * Planet.TILE_SIZE + Planet.TILE_SIZE/2.
|
||||
)
|
||||
|
||||
plant.planet.decontamination_layer.place_decontaminations(tiles, true)
|
||||
@@ -1 +0,0 @@
|
||||
uid://cgscbuxe4dawb
|
||||
@@ -1,29 +0,0 @@
|
||||
extends PlantEffect
|
||||
class_name ProduceSeedsEffect
|
||||
|
||||
func get_produce_number():
|
||||
return [level - 1, level]
|
||||
|
||||
func get_effect_name() -> String:
|
||||
return tr("SEED_PRODUCTION")
|
||||
|
||||
func get_effect_description() -> String:
|
||||
var number_str = ""
|
||||
|
||||
for i in range(len(get_produce_number())):
|
||||
if i != 0:
|
||||
if i == len(get_produce_number()) - 1:
|
||||
number_str += tr("OR")
|
||||
else :
|
||||
number_str += tr("COMMA")
|
||||
number_str += str(get_produce_number()[i])
|
||||
|
||||
return tr("PRODUCE_%s_SEEDS") % [number_str]
|
||||
|
||||
func effect(plant):
|
||||
for _i in range(get_produce_number().pick_random()):
|
||||
plant.planet.drop_item(
|
||||
Seed.new(plant.plant_type, plant.plant_mutations),
|
||||
plant.global_position,
|
||||
plant.HARVESTED_SEED_DISPLACEMENT_FACTOR,
|
||||
)
|
||||
@@ -1 +0,0 @@
|
||||
uid://ceqx5va1ormau
|
||||
@@ -20,13 +20,37 @@ func get_mutation_description() -> String:
|
||||
printerr("Classe abstraite PlantMutation appelée")
|
||||
return ""
|
||||
|
||||
func mutate_score(_plant_state : Plant.State, _plant : Plant, score,) -> int:
|
||||
func mutate_plant_data(_plant_data : PlantData):
|
||||
pass
|
||||
|
||||
func mutate_score(_plant_data : PlantData, score : int) -> int:
|
||||
return score
|
||||
|
||||
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
|
||||
return grow_time
|
||||
func mutate_lifetime(_plant_data : PlantData, lifetime : int) -> int:
|
||||
return lifetime
|
||||
|
||||
func mutate_plant(_plant : Plant):
|
||||
func mutate_growing_time(_plant_data : PlantData, growing_time : int) -> int:
|
||||
return growing_time
|
||||
|
||||
func mutate_seed_number(_plant_data, seed_number):
|
||||
return seed_number
|
||||
|
||||
func mutate_seed_random_loose(_plant_data, seed_random_loose):
|
||||
return seed_random_loose
|
||||
|
||||
func _start_planted_effect(_plant : Plant):
|
||||
pass
|
||||
|
||||
func _start_day_effect(_plant : Plant):
|
||||
pass
|
||||
|
||||
func _start_maturation_effect(_plant : Plant):
|
||||
pass
|
||||
|
||||
func _start_dead_effect(_plant : Plant):
|
||||
pass
|
||||
|
||||
func _start_harvested_effect(_plant : Plant):
|
||||
pass
|
||||
|
||||
func get_level_for_rarity(rarity : int) -> int :
|
||||
@@ -70,16 +94,3 @@ static func get_rarity_color(rarity : int) -> Color:
|
||||
]
|
||||
|
||||
return rarity_colors[min(rarity, len(rarity_colors) - 1)]
|
||||
|
||||
static func random_mutation(except_mutations : Array[PlantMutation] = []) -> PlantMutation:
|
||||
var all_mutations = GameInfo.game_data.unlocked_plant_mutations.duplicate_deep()
|
||||
all_mutations = all_mutations.filter(
|
||||
func (f1 : PlantMutation):
|
||||
return except_mutations.find_custom(
|
||||
func (f2 : PlantMutation): return f2.get_mutation_name() == f1.get_mutation_name()
|
||||
) == -1
|
||||
)
|
||||
if len(all_mutations):
|
||||
return all_mutations.pick_random()
|
||||
else :
|
||||
return null
|
||||
|
||||
@@ -18,7 +18,7 @@ func get_mutation_description() -> String:
|
||||
func get_day_factor():
|
||||
return max(1, DEFAULT_DAY_FACTOR - level + 1)
|
||||
|
||||
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant_state != Plant.State.MATURE:
|
||||
func mutate_score(data : PlantData, score) -> int:
|
||||
if data.get_state() != PlantData.State.MATURE:
|
||||
return score
|
||||
return score + floori(plant.day / get_day_factor())
|
||||
return score + floori(data.day / get_day_factor())
|
||||
@@ -1,29 +0,0 @@
|
||||
extends PlantMutation
|
||||
class_name ElitistMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/copy.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("ELITIST")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("ELITIST_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant.influence_zone == null:
|
||||
return score
|
||||
if plant_state != Plant.State.MATURE:
|
||||
return score
|
||||
var plant_count = 0
|
||||
for area in plant.influence_zone.get_overlapping_areas():
|
||||
if area is Plant and area != plant and area.plant_type.name == plant.plant_type.name:
|
||||
plant_count += 1
|
||||
|
||||
if plant_count == 0:
|
||||
return 0
|
||||
else :
|
||||
return score + level * plant_count
|
||||
@@ -1 +0,0 @@
|
||||
uid://bt1xh7ss13e5e
|
||||
@@ -1,26 +0,0 @@
|
||||
extends PlantMutation
|
||||
class_name ErmitMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/seedling-off.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("ERMIT")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("ERMIT_EFFECT_TEXT_LEVEL_%d") % get_score_multiplier()
|
||||
|
||||
func get_score_multiplier():
|
||||
return level + 1
|
||||
|
||||
func mutate_score(_plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant.influence_zone == null:
|
||||
return score
|
||||
for area in plant.influence_zone.get_overlapping_areas():
|
||||
if area is Plant and area != plant:
|
||||
return 0
|
||||
|
||||
return score * get_score_multiplier()
|
||||
@@ -1 +0,0 @@
|
||||
uid://domy822vgxfxs
|
||||
@@ -13,5 +13,5 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return tr("PRECOCIOUS_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_score(plant_state : Plant.State, _plant : Plant, score) -> int:
|
||||
return score + (0 if plant_state == Plant.State.MATURE else level)
|
||||
func mutate_score(data : PlantData, score : int) -> int:
|
||||
return score + (0 if data.get_state() == PlantData.State.MATURE else level)
|
||||
@@ -13,5 +13,5 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return tr("QUALITY_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_score(plant_state : Plant.State, _plant : Plant, score : int) -> int:
|
||||
return score + (level if plant_state == Plant.State.MATURE else 0)
|
||||
func mutate_score(data : PlantData, score : int) -> int:
|
||||
return score + (level if data.get_state() == PlantData.State.MATURE else 0)
|
||||
@@ -13,5 +13,5 @@ func get_mutation_name() -> String:
|
||||
func get_mutation_description() -> String:
|
||||
return tr("QUICK_EFFECT_TEXT_LEVEL_%d") % level
|
||||
|
||||
func mutate_grow_time(_plant : Plant, grow_time : int) -> int:
|
||||
func mutate_grow_time(_data : PlantData, grow_time : int) -> int:
|
||||
return max(grow_time - level, 0)
|
||||
@@ -1,32 +0,0 @@
|
||||
extends PlantMutation
|
||||
class_name SociableMutation
|
||||
|
||||
const NEAR_PLANT_NEEDED = 2
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/seedling.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("SOCIABLE")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("SOCIABLE_EFFECT_TEXT_LEVEL_%d") % [get_score_bonus(), NEAR_PLANT_NEEDED]
|
||||
|
||||
func get_score_bonus():
|
||||
return (level + 2)
|
||||
|
||||
func mutate_score(plant_state : Plant.State, plant : Plant, score) -> int:
|
||||
if plant.influence_zone == null:
|
||||
return score
|
||||
if plant_state != Plant.State.MATURE:
|
||||
return score
|
||||
var plant_count = 0
|
||||
|
||||
for area in plant.influence_zone.get_overlapping_areas():
|
||||
if area is Plant and area != plant :
|
||||
plant_count += 1
|
||||
|
||||
return score + (get_score_bonus() if plant_count >= NEAR_PLANT_NEEDED else 0)
|
||||
@@ -1 +0,0 @@
|
||||
uid://b8q5xgvy85qeb
|
||||
@@ -1,20 +0,0 @@
|
||||
extends PlantMutation
|
||||
class_name StrongMutation
|
||||
|
||||
func get_icon() -> Texture:
|
||||
return preload("res://common/icons/dna.svg")
|
||||
|
||||
func get_base_rarity() -> int:
|
||||
return 0
|
||||
|
||||
func get_mutation_name() -> String:
|
||||
return tr("STRONG")
|
||||
|
||||
func get_mutation_description() -> String:
|
||||
return tr("STRONG_EFFECT_TEXT_LEVEL_%d") % [roundi(get_score_multiplier() * 100)]
|
||||
|
||||
func get_score_multiplier():
|
||||
return float(level)/2
|
||||
|
||||
func mutate_score(_plant_state : Plant.State, _plant : Plant, score: int) -> int:
|
||||
return score + roundi(score * get_score_multiplier())
|
||||
@@ -1 +0,0 @@
|
||||
uid://cwj3k4p6ci5t4
|
||||
@@ -8,47 +8,38 @@ const PARTICLES_SCENE : PackedScene = preload("res://common/vfx/particles/partic
|
||||
|
||||
signal harvest_animation_finished
|
||||
|
||||
func update_plant_sprite(plant : Plant, with_animation = false):
|
||||
if with_animation:
|
||||
%AnimationPlayer.play("bump")
|
||||
await %AnimationPlayer.animation_finished
|
||||
|
||||
%Sprite.flip_h = true if randi()%2 == 0 else false
|
||||
var last_updated_on_state : PlantData.State = PlantData.State.MATURE
|
||||
|
||||
%Sprite.texture = get_state_texture(plant.state, plant.plant_type)
|
||||
func update_plant_sprite(plant_data : PlantData, with_animation = false):
|
||||
if with_animation:
|
||||
%AnimationPlayer.play("bump")
|
||||
await %AnimationPlayer.animation_finished
|
||||
|
||||
%Sprite.flip_h = true if plant_data.random_seed%2 == 0 else false
|
||||
%Sprite.texture = plant_data.get_plant_texture()
|
||||
|
||||
%PlantedSeed.visible = plant.state == Plant.State.PLANTED
|
||||
%PlantedSeed.texture = plant.plant_type.seed_texture
|
||||
%PlantedSeed.texture = plant_data.get_seed_texture()
|
||||
%PlantedSeed.visible = plant_data.get_state() == PlantData.State.PLANTED
|
||||
|
||||
%PlantedSeed.region_rect = Rect2(
|
||||
0,
|
||||
PLANTED_SEED_POS_Y,
|
||||
plant.plant_type.seed_texture.get_width(),
|
||||
plant.plant_type.seed_texture.get_height() - PLANTED_SEED_CROP_WIDTH + -1 * PLANTED_SEED_POS_Y,
|
||||
)
|
||||
|
||||
func get_state_texture(s: Plant.State, plant_type : PlantType) -> Texture2D:
|
||||
match s:
|
||||
Plant.State.PLANTED:
|
||||
return null
|
||||
Plant.State.GROWING:
|
||||
return plant_type.growing_texture
|
||||
Plant.State.MATURE:
|
||||
return plant_type.mature_texture
|
||||
return null
|
||||
# %PlantedSeed.region_rect = Rect2(
|
||||
# 0,
|
||||
# PLANTED_SEED_POS_Y,
|
||||
# %PlantedSeed.texture.get_width(),
|
||||
# %PlantedSeed.texture.texture.get_height() - PLANTED_SEED_CROP_WIDTH + -1 * PLANTED_SEED_POS_Y,
|
||||
# )
|
||||
|
||||
func generate_mutation_effects(plant : Plant):
|
||||
for m in plant.plant_mutations:
|
||||
var particles_emitter : Particles = PARTICLES_SCENE.instantiate() as CPUParticles2D
|
||||
particles_emitter.setup_particles(
|
||||
Particles.Parameters.new(
|
||||
m.get_icon(),
|
||||
PlantMutation.get_rarity_color(m.get_rarity())
|
||||
)
|
||||
)
|
||||
add_child(particles_emitter)
|
||||
for m in plant.data.mutations:
|
||||
var particles_emitter : Particles = PARTICLES_SCENE.instantiate() as CPUParticles2D
|
||||
particles_emitter.setup_particles(
|
||||
Particles.Parameters.new(
|
||||
m.get_icon(),
|
||||
PlantMutation.get_rarity_color(m.get_rarity())
|
||||
)
|
||||
)
|
||||
add_child(particles_emitter)
|
||||
|
||||
func start_harvest_animation():
|
||||
$AnimationPlayer.play("harvest")
|
||||
await $AnimationPlayer.animation_finished
|
||||
harvest_animation_finished.emit()
|
||||
$AnimationPlayer.play("harvest")
|
||||
await $AnimationPlayer.animation_finished
|
||||
harvest_animation_finished.emit()
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
extends Resource
|
||||
class_name PlantType
|
||||
|
||||
@export var name : String
|
||||
@export_multiline var description : String
|
||||
|
||||
@export var default_growing_time : int = 2
|
||||
@export var default_plant_score : int = 1
|
||||
|
||||
@export var seed_texture : Texture
|
||||
@export var growing_texture : Texture
|
||||
@export var mature_texture : Texture
|
||||
|
||||
@export var harvest_effects : Array[PlantEffect] = []
|
||||
@export var mature_effects : Array[PlantEffect] = []
|
||||
@export var cyclic_effects : Array[PlantEffect] = []
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
name
|
||||
)
|
||||
|
||||
info.important_stat_icon = Plant.PLANT_POINT_ICON
|
||||
info.important_stat_text = "%d" % default_plant_score
|
||||
info.texture = mature_texture
|
||||
info.type_icon = Plant.PLANT_TYPE_ICON
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("GROW_IN_%d") % default_growing_time,
|
||||
Plant.GROWING_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
tr("%s_SCORE_WHEN_MATURE") % default_plant_score,
|
||||
Plant.PLANT_POINT_ICON
|
||||
))
|
||||
|
||||
info.sections.append_array(PlantEffect.card_effect_sections(
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects,
|
||||
))
|
||||
|
||||
return info
|
||||
|
||||
func get_available_evolution() -> Array[Evolution]:
|
||||
var evolutions : Array[Evolution] = [
|
||||
ScoreEvolution.new(self)
|
||||
]
|
||||
|
||||
if len(mature_effects) > 0:
|
||||
evolutions.append(MatureEffectEvolution.new(self))
|
||||
if len(harvest_effects) > 0:
|
||||
evolutions.append(HarvestEffectEvolution.new(self))
|
||||
if len(cyclic_effects) > 0:
|
||||
evolutions.append(CyclicEffectEvolution.new(self))
|
||||
|
||||
return evolutions
|
||||
|
||||
class Evolution:
|
||||
|
||||
var level : int
|
||||
var plant_type : PlantType
|
||||
|
||||
func _init(_type : PlantType, _l : int = 1):
|
||||
plant_type = _type
|
||||
level = _l
|
||||
|
||||
func get_title():
|
||||
return ""
|
||||
|
||||
func get_description():
|
||||
return ""
|
||||
|
||||
func evolve(_pt : PlantType = plant_type):
|
||||
pass
|
||||
|
||||
class ScoreEvolution extends Evolution:
|
||||
|
||||
func get_title():
|
||||
return tr("%s_SCORE_EVOLUTION") % plant_type.name
|
||||
|
||||
func get_description():
|
||||
return tr("ADD_%s_TO_THE_DEFAULT_SCORE_OF_THE_PLANT") % level
|
||||
|
||||
func evolve(pt : PlantType = plant_type):
|
||||
pt.default_plant_score += level
|
||||
|
||||
class MatureEffectEvolution extends Evolution:
|
||||
|
||||
var effect_index : int
|
||||
|
||||
func _init(_type : PlantType, _l : int = 1):
|
||||
plant_type = _type
|
||||
level = _l
|
||||
|
||||
pick_effect()
|
||||
|
||||
func pick_effect():
|
||||
effect_index = randi() % len(plant_type.mature_effects)
|
||||
|
||||
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
|
||||
return pt.mature_effects[effect_index]
|
||||
|
||||
func get_title():
|
||||
return tr("%s_EVOLUTION") % plant_type.name
|
||||
|
||||
func get_description():
|
||||
return tr("UPGRADE_THE_LEVEL_OF_%s_EFFECT_OF_%d_LEVEL") % [get_effect().get_effect_name(), level]
|
||||
|
||||
func evolve(pt : PlantType = plant_type):
|
||||
get_effect(pt).level += level
|
||||
|
||||
class HarvestEffectEvolution extends MatureEffectEvolution:
|
||||
|
||||
func pick_effect():
|
||||
effect_index = randi() % len(plant_type.harvest_effects)
|
||||
|
||||
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
|
||||
return pt.harvest_effects[effect_index]
|
||||
|
||||
class CyclicEffectEvolution extends MatureEffectEvolution:
|
||||
|
||||
func pick_effect():
|
||||
effect_index = randi() % len(plant_type.harvest_effects)
|
||||
|
||||
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
|
||||
return pt.harvest_effects[effect_index]
|
||||
@@ -1 +0,0 @@
|
||||
uid://jnye5pe1bgqw
|
||||
19
entities/plants/scripts/texture_builder/texture_builder.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Resource
|
||||
class_name TextureBuilder
|
||||
|
||||
const PLACEHOLDER_SEED_TEXTURE : Texture = preload("res://entities/plants/assets/sprites/default/seed.png")
|
||||
const PLACEHOLDER_MATURE_TEXTURE : Texture = preload("res://entities/plants/assets/sprites/default/mature.png")
|
||||
const PLACEHOLDER_GROWING_TEXTURE : Texture = preload("res://entities/plants/assets/sprites/default/growing.png")
|
||||
|
||||
|
||||
func build_seed_texture(_random_seed : int) -> Texture:
|
||||
return PLACEHOLDER_SEED_TEXTURE
|
||||
|
||||
func build_plant_texture(plant_data : PlantData) -> Texture:
|
||||
match plant_data.get_state():
|
||||
PlantData.State.MATURE:
|
||||
return PLACEHOLDER_MATURE_TEXTURE
|
||||
PlantData.State.GROWING:
|
||||
return PLACEHOLDER_GROWING_TEXTURE
|
||||
_:
|
||||
return null
|
||||
@@ -0,0 +1 @@
|
||||
uid://dt2ip3pw2cboy
|
||||
@@ -6,93 +6,97 @@ signal updated(inventory: Inventory)
|
||||
@export var items: Array[Item] = []
|
||||
@export var current_item_ind: int = 0
|
||||
@export var size = 0 :
|
||||
set(s):
|
||||
size = s
|
||||
items.resize(size)
|
||||
updated.emit(self)
|
||||
set(s):
|
||||
size = s
|
||||
items.resize(size)
|
||||
updated.emit(self)
|
||||
|
||||
func _init(inventory_size: int = 1):
|
||||
size = inventory_size
|
||||
|
||||
|
||||
size = inventory_size
|
||||
|
||||
func get_best_available_slot_ind():
|
||||
if items[current_item_ind] == null:
|
||||
return current_item_ind
|
||||
for i in items.size():
|
||||
if items[i] == null:
|
||||
return i
|
||||
return current_item_ind
|
||||
if items[current_item_ind] == null:
|
||||
return current_item_ind
|
||||
for i in items.size():
|
||||
if items[i] == null:
|
||||
return i
|
||||
return current_item_ind
|
||||
|
||||
func set_current_item(new_ind: int):
|
||||
if new_ind >= items.size():
|
||||
return
|
||||
if new_ind >= items.size():
|
||||
return
|
||||
|
||||
if new_ind != current_item_ind:
|
||||
current_item_ind = new_ind
|
||||
updated.emit(self)
|
||||
if new_ind != current_item_ind:
|
||||
current_item_ind = new_ind
|
||||
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)
|
||||
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)
|
||||
|
||||
func add_item(item: Item):
|
||||
var best_ind = get_best_available_slot_ind()
|
||||
if best_ind != current_item_ind:
|
||||
set_item(item, best_ind)
|
||||
updated.emit(self)
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
var best_ind = get_best_available_slot_ind()
|
||||
if best_ind != current_item_ind:
|
||||
set_item(item, best_ind)
|
||||
updated.emit(self)
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
func set_item(item: Item, ind: int = 0) -> bool:
|
||||
if ind < 0 || ind >= items.size():
|
||||
return false
|
||||
while len(items) <= ind:
|
||||
items.append(null)
|
||||
items[ind] = item
|
||||
updated.emit(self)
|
||||
return true
|
||||
if ind < 0 || ind >= items.size():
|
||||
return false
|
||||
while len(items) <= ind:
|
||||
items.append(null)
|
||||
items[ind] = item
|
||||
updated.emit(self)
|
||||
return true
|
||||
|
||||
func get_item(ind: int = current_item_ind) -> Item:
|
||||
if ind < 0 || items.size() <= ind:
|
||||
return null
|
||||
return items[ind]
|
||||
if ind < 0 || items.size() <= ind:
|
||||
return null
|
||||
return items[ind]
|
||||
|
||||
func has_item(item: Item) -> bool:
|
||||
return item in items
|
||||
return item in items
|
||||
|
||||
func remove_item(item: Item):
|
||||
var ind = items.find(item)
|
||||
if ind >= 0:
|
||||
items[ind] = null
|
||||
updated.emit(self)
|
||||
var ind = items.find(item)
|
||||
if ind >= 0:
|
||||
items[ind] = null
|
||||
updated.emit(self)
|
||||
|
||||
func remove_item_at(ind: int = current_item_ind):
|
||||
if items.size() <= ind:
|
||||
return
|
||||
if items.size() <= ind:
|
||||
return
|
||||
|
||||
items[ind] = null
|
||||
updated.emit(self)
|
||||
items[ind] = null
|
||||
updated.emit(self)
|
||||
|
||||
func remove_current_item():
|
||||
remove_item_at()
|
||||
remove_item_at()
|
||||
|
||||
func pop_item(ind: int = current_item_ind) -> Item:
|
||||
if items.size() == 0:
|
||||
return
|
||||
if items.size() == 0:
|
||||
return
|
||||
|
||||
var item_removed: Item = items[ind]
|
||||
items[ind] = null
|
||||
updated.emit(self)
|
||||
return item_removed
|
||||
var item_removed: Item = items[ind]
|
||||
items[ind] = null
|
||||
updated.emit(self)
|
||||
return item_removed
|
||||
|
||||
func is_full():
|
||||
for i in items:
|
||||
if i == null : return false
|
||||
return true
|
||||
for i in items:
|
||||
if i == null : return false
|
||||
return true
|
||||
|
||||
func clear():
|
||||
for i in range(len(items)):
|
||||
items[i] = null
|
||||
updated.emit(self)
|
||||
|
||||
@@ -33,11 +33,11 @@ func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, _zone : Player.ActionZone) -> bool:
|
||||
return player.terrain is Planet
|
||||
return player.terrain is Region
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
if machine_type and machine_level and player.planet:
|
||||
player.planet.add_entity(
|
||||
if machine_type and machine_level and player.region:
|
||||
player.region.add_entity(
|
||||
Machine.instantiate_machine(machine_type, machine_level),
|
||||
zone.get_global_position()
|
||||
)
|
||||
|
||||