32 lines
1.1 KiB
GDScript
32 lines
1.1 KiB
GDScript
class_name Avatar
|
|
extends RefCounted
|
|
## One scarecrow in play and everything that acts for it: its body, its kit (health, fear,
|
|
## patching), its gun, and its hands (Interactions). Solo there is one (player 1). In co-op
|
|
## FarmSim holds two: slot 0 is player 1 (the host's), slot 1 player 2 (the partner's). The one
|
|
## this machine plays is local; on the host the partner's reads RemoteControls (remote), and on
|
|
## the partner's machine player 1's is moved by the network.
|
|
|
|
const NAMES: Array[String] = ["P1", "P2"]
|
|
const COLORS: Array[Color] = [Color(1.0, 0.85, 0.35), Color(0.45, 0.8, 1.0)]
|
|
|
|
var slot: int = 0
|
|
var body: PlayerCharacter
|
|
var kit: Scarecrow
|
|
var combat: ScarecrowCombat
|
|
var interactions: Interactions
|
|
var remote: RemoteControls
|
|
var is_local := true
|
|
## The player's name (co-op), shown on the tag over the head and the partner HUD.
|
|
var player_name := ""
|
|
|
|
|
|
func position() -> Vector2:
|
|
return Vector2(body.global_position.x, body.global_position.z)
|
|
|
|
|
|
func label() -> String:
|
|
return "%s %s" % [NAMES[slot], player_name] if player_name != "" else NAMES[slot]
|
|
|
|
|
|
func color() -> Color:
|
|
return COLORS[slot]
|