Tales-of-PKMN/game/mount/mount_registry.gd

26 lines
841 B
GDScript

# 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)