Introduce a map manager

This commit is contained in:
Squinty 2024-04-21 07:32:52 +00:00
parent 5c4cc1a6ce
commit ae58fb2d7e
3 changed files with 80 additions and 20 deletions

View file

@ -1,11 +1,21 @@
[gd_scene load_steps=5 format=3 uid="uid://chbno00ugl6te"]
[gd_scene load_steps=8 format=3 uid="uid://chbno00ugl6te"]
[ext_resource type="Environment" uid="uid://d2ahijqqspw5f" path="res://environments/default.tres" id="1_3nr12"]
[ext_resource type="Script" path="res://maps/map.gd" id="1_6ysiv"]
[ext_resource type="Terrain3DStorage" uid="uid://dyon4xda4k40d" path="res://maps/genesis/resources/storage.res" id="1_a88qe"]
[ext_resource type="Terrain3DMaterial" uid="uid://bd4lr5sxu8xu" path="res://maps/genesis/resources/material.res" id="2_o2y3d"]
[ext_resource type="Terrain3DTextureList" uid="uid://dnqa8kxgm3xuw" path="res://maps/genesis/resources/textures.res" id="3_1cww7"]
[node name="Terrain3D" type="Terrain3D"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_k2vhq"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_5ytwx"]
[node name="Map" type="Node" node_paths=PackedStringArray("_flagstand", "_player_spawns_root")]
script = ExtResource("1_6ysiv")
_flagstand = NodePath("Terrain3D/FlagPillar/CSGCylinder3D/FlagStand")
_player_spawns_root = NodePath("Terrain3D/PlayerSpawns")
[node name="Terrain3D" type="Terrain3D" parent="."]
storage = ExtResource("1_a88qe")
material = ExtResource("2_o2y3d")
texture_list = ExtResource("3_1cww7")
@ -13,8 +23,41 @@ collision_layer = 2147483648
collision_mask = 2147483648
mesh_size = 24
[node name="PlayerSpawns" type="Node" parent="Terrain3D"]
[node name="Spawn1" type="Marker3D" parent="Terrain3D/PlayerSpawns"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 95.5378, -32.735)
visible = false
[node name="MeshInstance3D" type="MeshInstance3D" parent="Terrain3D/PlayerSpawns/Spawn1"]
mesh = SubResource("CapsuleMesh_k2vhq")
[node name="Spawn2" type="Marker3D" parent="Terrain3D/PlayerSpawns"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9, 98.3078, 18.061)
visible = false
[node name="MeshInstance3D" type="MeshInstance3D" parent="Terrain3D/PlayerSpawns/Spawn2"]
mesh = SubResource("CapsuleMesh_5ytwx")
[node name="FlagPillar" type="CSGCombiner3D" parent="Terrain3D"]
transform = Transform3D(1, 0, 0, 0, 2.83726, 0, 0, 0, 1, 0, 94.6411, 0)
use_collision = true
collision_layer = 2147483648
collision_mask = 0
[node name="CSGBox3D" type="CSGBox3D" parent="Terrain3D/FlagPillar"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9311, 0)
size = Vector3(0.5, 6, 0.5)
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Terrain3D/FlagPillar"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42967, 0)
height = 5.0
[node name="FlagStand" type="Marker3D" parent="Terrain3D/FlagPillar/CSGCylinder3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.42315, 0)
[node name="Sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
transform = Transform3D(-0.866024, -0.433016, 0.25, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
shadow_enabled = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]

16
maps/map.gd Normal file
View file

@ -0,0 +1,16 @@
class_name Map extends Node
@export var _flagstand : Node3D
@export var _player_spawns_root : Node
var _rng : RandomNumberGenerator = RandomNumberGenerator.new()
func get_flagstand() -> Node3D:
return _flagstand
func get_player_spawn() -> Node3D:
var spawn_count : int = _player_spawns_root.get_child_count()
var spawn_index : int = _rng.randi_range(0, spawn_count - 1)
var spawn_selected : Node3D = _player_spawns_root.get_child(spawn_index)
return spawn_selected