Add mount files
This commit is contained in:
parent
b4edeff685
commit
a923c1319b
27
scripts/mount/mount_profile.gd
Normal file
27
scripts/mount/mount_profile.gd
Normal file
|
|
@ -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
|
||||||
25
scripts/mount/mount_registry.gd
Normal file
25
scripts/mount/mount_registry.gd
Normal file
|
|
@ -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)
|
||||||
Loading…
Reference in a new issue