Files
Cinderwild/scripts/world/mooring_post.gd

26 lines
914 B
GDScript

extends StaticBody3D
## The mooring post at the end of the pier (moorings.gd): E ties up the
## rowing boat in your bag. Online, your game asks the server.
var moorings: Node3D
## Whose boat: the player's id (a server's character, or, at home, yours).
static func id_of(player: Node) -> String:
var pid: Variant = player.get("player_id")
if pid != null and not String(pid).is_empty():
return String(pid)
return String(Net.get_identity().player_id)
func interact_prompt(player: Node) -> String:
if moorings.has_boat(id_of(player)):
return "Mooring post (your boat's tied up here)"
if player.inventory.count(moorings.BOAT_ITEM) > 0:
return "Mooring post [E] Tie up your boat"
return "Mooring post (build a rowing boat at a workbench, and tie it up here)"
func interact(player: Node) -> void:
if moorings.world.is_online():
PlayerNet.ask("moor", [])
return
moorings.moor(player, id_of(player))