-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvsk_player.gd
54 lines (45 loc) · 1.6 KB
/
vsk_player.gd
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright (c) 2018-present. This file is part of V-Sekai https://v-sekai.org/.
# SaracenOne & K. S. Ernest (Fire) Lee & Lyuma & MMMaellon & Contributors
# vsk_player.gd
# SPDX-License-Identifier: MIT
extends CharacterBody3D
@export var player_movement_controller: Node = null
@export var collision_shape: CollisionShape3D = null
@export var camera: Camera3D = null
@export var spawn_sync_node: MultiplayerSynchronizer = null
@export var update_sync_node: MultiplayerSynchronizer = null
##
## Assigns the correct authority ID based on the name of the
## node.
##
func _setup_authority() -> void:
# Modifiy the player's authority based on its name.
if name.begins_with("Player_"):
var id_string: String = name.lstrip("Player_")
if id_string.is_valid_int():
set_multiplayer_authority(id_string.to_int())
# The MultiplayerSynchronizerSpawn node show always have its authority
# owned by the host
if spawn_sync_node:
spawn_sync_node.set_multiplayer_authority(1)
func _enter_tree() -> void:
# This derives the correct authority for this node based on the node's name.
_setup_authority()
func _ready() -> void:
if collision_shape:
collision_shape.disabled = not is_multiplayer_authority()
else:
push_error("Collision shape not found!")
if is_multiplayer_authority():
pass
#Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
else:
if player_movement_controller:
player_movement_controller.queue_free()
else:
push_error("Player movement controller not found!")
if camera:
camera.queue_free()
camera.get_parent().remove_child(camera)
else:
push_error("Player camera controller not found!")