aboutsummaryrefslogtreecommitdiff
path: root/client/scripts/player.gd
blob: 6e07c3aa7bd4cafcca8b4f1669326b850e9ba11b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class_name Player
extends Node3D

const PLAYER_SIZE: float = 0.4
const SPEED: float = 25.

var game: Game
var position_ = Vector2(0, 0)

var mesh = preload("res://scenes/player.tscn").instantiate()

var hand: Node3D = null

func _init(id: int, new_name: String, pos: Vector2, _character: int):
	add_child(mesh)
	position_ = pos
	name = new_name
	game = new_game

func update_position(new_position: Vector2, new_rotation: float):
	position_ = new_position
	rotation.y = new_rotation

func take_item(tile: FullTile):
	if hand != null:
		push_error("already holding an item")
	var i = tile.take_item()
	if i == null:
		push_error("tile is null")
	hand = i

func put_item(tile: FullTile):
	var i = hand
	if i == null:
		push_error("holding nothing")
	i = null
	tile.put_item(hand)