WIP: Something

This commit is contained in:
Nikolai Rodionov 2025-02-17 17:34:47 +01:00
parent 1323dbf154
commit 37154955d6
No known key found for this signature in database
GPG Key ID: 0639A45505F3BFA6
6 changed files with 29 additions and 17 deletions

View File

@ -21,11 +21,11 @@ func player_data_into_dict(player_data: PlayerData) -> Dictionary:
var side: String
match player_data.side:
-1:
side = "undefined"
side = PlayerData.underfined
0:
side = "attack"
side = PlayerData.blue
1:
side = "defend"
side = PlayerData.red
result["side"] = side
return result

View File

@ -21,8 +21,8 @@ func _ready() -> void:
func _process(delta: float) -> void:
for player in server_node.players:
if not spawned_players.has(player):
logger.debug("Spawning a player with id: " + str(player))
if player.has("side"):
if server_node.players[player].has("side") and server_node.players[player].get("side") != PlayerData.underfined:
logger.debug("Spawning a player with id: " + str(player))
var err := spawn_players(server_node.players[player])
if err != OK:
logger.error("Couldn't spawn a player, err: " + str(err))

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=76 format=4 uid="uid://d3icis5se8wji"]
[gd_scene load_steps=77 format=4 uid="uid://d3icis5se8wji"]
[ext_resource type="Script" path="res://scenes/maps/base/map_controller.gd" id="1_emuvj"]
[ext_resource type="Script" path="res://scenes/maps/base/spawn_controller.gd" id="2_tngxn"]
[ext_resource type="Script" path="res://scenes/utils/camera_mount/camera_mount.gd" id="3_flfpw"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_twmpc"]
resource_name = "New_Material"
@ -970,5 +971,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -42.7716, 0, 5.30093)
[node name="3" type="Node3D" parent="SpawnLocations/Red"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -42.7716, 0, -11.2129)
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -0.164273, 0.986415, 0, -0.986415, -0.164273, 0, 21.2997, 0)
[node name="CameraMount" type="Node3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 32.813, 0)
script = ExtResource("3_flfpw")
active = true

View File

@ -4,6 +4,7 @@ class_name CameraMount
# -- When camera mount is not active, client shouldn't connect to it
@export var active: bool = false
@export var default: bool = false
@export var accept_input: bool = false
var camera: Camera3D
# Called when the node enters the scene tree for the first time.

View File

@ -1,16 +1,24 @@
extends Node3D
class_name ClientNode
@export var is_connected_to_camera: bool = false
var available_cameras: Array[CameraMount] = []
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
var game_root := helpers.get_root_node()
var available_cameras_raw: Array[Node] = game_root.find_children("*", "CameraMount", true, false)
for camera_raw in available_cameras_raw:
var camera: CameraMount = camera_raw as CameraMount
if camera.active:
camera.connect_to_camera()
available_cameras.append(camera)
if not is_connected_to_camera:
var game_root := helpers.get_root_node()
var available_cameras_raw: Array[Node] = game_root.find_children("*", "CameraMount", true, false)
for camera_raw in available_cameras_raw:
var camera: CameraMount = camera_raw as CameraMount
if camera.active:
if camera.accept_input:
camera.connect_to_camera()
break
camera.connect_to_camera()
available_cameras.append(camera)
@rpc("authority", "reliable", "call_local")
func force_camera_attachment(camera_mount: CameraMount) -> void:
camera_mount.connect_to_camera()

View File

@ -15,7 +15,7 @@ enum Side {
const blue = "attack"
const red = "defend"
const underfined = "unddefined"
const underfined = "undefined"
@export var side: PlayerData.Side = Side.UNDEFINED
@export var active: bool = false