24 lines
793 B
GDScript
24 lines
793 B
GDScript
extends StaticBody3D
|
|
## The wreck's sea chest (wreck.gd): what you look at and press E on. Online,
|
|
## your game asks the server, which gives you your share once.
|
|
|
|
var wreck: Node3D
|
|
|
|
func interact_prompt(player: Node) -> String:
|
|
if wreck.had(_id(player)):
|
|
return "The captain's sea chest (empty: you've had what was in it)"
|
|
return "[E] Open the captain's sea chest"
|
|
|
|
func interact(player: Node) -> void:
|
|
if wreck.world.is_online():
|
|
PlayerNet.ask("wreck_chest", [])
|
|
return
|
|
wreck.open_for(player, _id(player))
|
|
|
|
## Whose share: the player's id (a server's character, or, at home, yours).
|
|
static func _id(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)
|