generated from krampus/template-godot4
50 lines
1.1 KiB
GDScript3
50 lines
1.1 KiB
GDScript3
|
class_name WorldPlayer extends Resource
|
||
|
## Container for the state of the player within the world.
|
||
|
|
||
|
# TODO character select
|
||
|
@export var name: String = "Gfolfer"
|
||
|
|
||
|
@export_category("Equipment")
|
||
|
@export var driver: Club
|
||
|
@export var iron: Club
|
||
|
@export var wedge: Club
|
||
|
@export var putter: Club
|
||
|
@export var special: Club
|
||
|
|
||
|
# TODO balls, pickups, etc
|
||
|
|
||
|
var shot_setup: ShotSetup:
|
||
|
get:
|
||
|
if not shot_setup:
|
||
|
shot_setup = ShotSetup.create(self)
|
||
|
return shot_setup
|
||
|
|
||
|
|
||
|
## Get the club equipped in the given slot.
|
||
|
##
|
||
|
## Returns `null` if the player has no club equipped in the given slot
|
||
|
func get_club(type: Club.Type) -> Club:
|
||
|
match type:
|
||
|
Club.Type.DRIVER:
|
||
|
return driver
|
||
|
Club.Type.IRON:
|
||
|
return iron
|
||
|
Club.Type.WEDGE:
|
||
|
return wedge
|
||
|
Club.Type.PUTTER:
|
||
|
return putter
|
||
|
Club.Type.SPECIAL:
|
||
|
return special
|
||
|
return null
|
||
|
|
||
|
|
||
|
## Create a debug player instance
|
||
|
static func create_debug() -> WorldPlayer:
|
||
|
var instance := WorldPlayer.new()
|
||
|
instance.driver = Club.catalog.debug_driver
|
||
|
instance.iron = Club.catalog.debug_iron
|
||
|
instance.wedge = Club.catalog.debug_wedge
|
||
|
instance.putter = Club.catalog.debug_wedge
|
||
|
|
||
|
return instance
|