From a923c1319b8bf1fce089723bec0785a23a251904 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Fri, 2 Oct 2026 21:39:00 +0200 Subject: [PATCH] Add mount files --- scripts/mount/mount_profile.gd | 27 +++++++++++++++++++++++++++ scripts/mount/mount_registry.gd | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/mount/mount_profile.gd create mode 100644 scripts/mount/mount_registry.gd diff --git a/scripts/mount/mount_profile.gd b/scripts/mount/mount_profile.gd new file mode 100644 index 0000000..b4f948d --- /dev/null +++ b/scripts/mount/mount_profile.gd @@ -0,0 +1,27 @@ +# res://scripts/mount/mount_profile.gd +@tool +class_name MountProfile +extends Resource + +enum Surface { + GROUND = 1, + WATER = 2, + AIR = 4, + LAVA = 8, +} + +@export var species : PokemonData +@export_flags("Terre:1", "Eau:2", "Ciel:4", "Lave:8") var surfaces : int = Surface.GROUND + +@export_group("Mouvement") +@export var mount_speed : float = 8.0 +@export var mount_accel : float = 6.0 +@export var mount_deccel : float = 7.0 +@export var mount_jump_height : float = 2.5 # ignoré si AIR est actif (vol libre plutôt que saut) + +@export_group("Attache") +@export var seat_offset : Vector3 = Vector3(0, 1.2, -0.3) +@export var mount_scene_override : PackedScene # sinon utilise species.model_scene + +func can_use_surface(surface : Surface) -> bool: + return (surfaces & surface) != 0 diff --git a/scripts/mount/mount_registry.gd b/scripts/mount/mount_registry.gd new file mode 100644 index 0000000..29078c8 --- /dev/null +++ b/scripts/mount/mount_registry.gd @@ -0,0 +1,25 @@ +# res://scripts/mount/mount_registry.gd (autoload) +extends Node + +const MOUNTS_DIR := "res://data/mounts/" + +var _by_species : Dictionary = {} # nom d'API -> MountProfile + +func _ready() -> void: + for file in ResourceLoader.list_directory(MOUNTS_DIR): + if file.ends_with("/"): continue + var profile := load(MOUNTS_DIR + file) as MountProfile + if profile and profile.species: + _by_species[profile.species.api_name] = profile + +func get_profile(d : PokemonData) -> MountProfile: + if d == null: return null + return _by_species.get(d.api_name) + +func is_mountable(d : PokemonData) -> bool: + return get_profile(d) != null + +## Le pokémon peut-il être monté sur CETTE surface précisément ? +func can_mount_on(d : PokemonData, surface : MountProfile.Surface) -> bool: + var p := get_profile(d) + return p != null and p.can_use_surface(surface)