broken_seals/game/player/NetworkedPlayer.gd

70 lines
2.4 KiB
GDScript3
Raw Normal View History

2019-11-20 14:05:35 +01:00
extends "PlayerGDBase.gd"
class_name NetworkedPlayerGD
# Copyright Péter Magyar relintai@gmail.com
# MIT License, functionality from this class needs to be protable to the entity spell system
2019-11-20 14:05:35 +01:00
2020-01-31 20:01:34 +01:00
# Copyright (c) 2019-2020 Péter Magyar
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
2019-11-20 14:05:35 +01:00
const ray_length = 1000
const ACCEL : float = 100.0
const DEACCEL : float = 100.0
const GRAVITY : float = -24.8
const JUMP_SPEED : float = 3.8
const MAX_SLOPE_ANGLE : float = 40.0
const MOUSE_TARGET_MAX_OFFSET : int = 10
var y_rot : float = 0.0
var animation_tree : AnimationTree
var anim_node_state_machine : AnimationNodeStateMachinePlayback = null
func _ready() -> void:
animation_tree = get_character_skeleton().get_animation_tree()
if animation_tree != null:
anim_node_state_machine = animation_tree["parameters/playback"]
func rotate_delta(x_delta : float) -> void:
y_rot += x_delta
if y_rot > 360:
y_rot = 0
if y_rot < 0:
y_rot = 360
2020-01-02 23:02:45 +01:00
get_body().rotation_degrees = Vector3(0.0, y_rot, 0.0)
2019-11-20 14:05:35 +01:00
remote func sset_position(position : Vector3, rotation : Vector3) -> void:
if multiplayer.network_peer and multiplayer.is_network_server():
cset_position(position, rotation)
2020-01-02 23:02:45 +01:00
vrpc("cset_position", position, rotation)
2019-11-20 14:05:35 +01:00
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
2020-01-02 23:02:45 +01:00
get_body().translation = position
get_body().rotation = rotation
2019-11-20 14:05:35 +01:00
func _moved() -> void:
if sis_casting():
sfail_cast()