diff --git a/godot/maps/forgotten_desert.tres b/godot/maps/forgotten_desert.tres index 137a21e..ef8022a 100644 --- a/godot/maps/forgotten_desert.tres +++ b/godot/maps/forgotten_desert.tres @@ -5,11 +5,13 @@ [ext_resource type="AudioStream" uid="uid://n2sc18m7vmw4" path="res://raw_assets/music/desert_loop.mp3" id="3_djfrh"] [ext_resource type="PackedScene" uid="uid://dga2e132re8aj" path="res://maps/forgotten_desert/forgotten_desert.tscn" id="3_tp6of"] [ext_resource type="TeamResource" uid="uid://p2fqqnaejjn7" path="res://maps/teams/blue_team.tres" id="4_5mkdi"] +[ext_resource type="PackedScene" uid="uid://dkhy2flohg26a" path="res://maps/forgotten_desert/forgotten_desert_static.scn" id="5_djfrh"] [ext_resource type="TeamResource" uid="uid://db4b3sjsftg15" path="res://maps/teams/red_ream.tres" id="5_hd5qa"] [resource] name = "Forgotten Desert" scene = ExtResource("3_tp6of") +static_scene = ExtResource("5_djfrh") teams = Array[TeamResource]([ExtResource("4_5mkdi"), ExtResource("5_hd5qa")]) music = Array[AudioStream]([ExtResource("2_oda74"), ExtResource("3_djfrh")]) icon = ExtResource("1_tp6of") diff --git a/godot/maps/forgotten_desert/forgotten_desert_static.scn b/godot/maps/forgotten_desert/forgotten_desert_static.scn index 4b69e3c..5a8c980 100644 Binary files a/godot/maps/forgotten_desert/forgotten_desert_static.scn and b/godot/maps/forgotten_desert/forgotten_desert_static.scn differ diff --git a/godot/maps/grand_forge.tres b/godot/maps/grand_forge.tres index 5d66d9d..24e3adb 100644 --- a/godot/maps/grand_forge.tres +++ b/godot/maps/grand_forge.tres @@ -3,12 +3,14 @@ [ext_resource type="Texture2D" uid="uid://cdmjqr6rv0224" path="res://maps/grand_forge/icon.png" id="1_jsc2a"] [ext_resource type="AudioStream" uid="uid://vyfd1ojs3200" path="res://raw_assets/music/Act of War.mp3" id="2_byxos"] [ext_resource type="PackedScene" uid="uid://bbknih7aruq24" path="res://maps/grand_forge/grand_forge.tscn" id="4_5lu31"] +[ext_resource type="PackedScene" uid="uid://l71v3cjnnwj5" path="res://maps/grand_forge/grand_forge_static.scn" id="4_vo2c7"] [ext_resource type="TeamResource" uid="uid://p2fqqnaejjn7" path="res://maps/teams/blue_team.tres" id="5_vo2c7"] [ext_resource type="TeamResource" uid="uid://db4b3sjsftg15" path="res://maps/teams/red_ream.tres" id="6_jsc2a"] [resource] name = "Grand Forge" scene = ExtResource("4_5lu31") +static_scene = ExtResource("4_vo2c7") teams = Array[TeamResource]([ExtResource("5_vo2c7"), ExtResource("6_jsc2a")]) music = Array[AudioStream]([ExtResource("2_byxos")]) icon = ExtResource("1_jsc2a") diff --git a/godot/maps/grand_forge/grand_forge_static.scn b/godot/maps/grand_forge/grand_forge_static.scn index 1bc0bd0..390821f 100644 Binary files a/godot/maps/grand_forge/grand_forge_static.scn and b/godot/maps/grand_forge/grand_forge_static.scn differ diff --git a/godot/maps/precipice.tres b/godot/maps/precipice.tres index 3779314..7236269 100644 --- a/godot/maps/precipice.tres +++ b/godot/maps/precipice.tres @@ -4,6 +4,7 @@ [ext_resource type="PackedScene" uid="uid://ku0i1jwmgh78" path="res://maps/precipice/precipice.tscn" id="1_fwujm"] [ext_resource type="AudioStream" uid="uid://c1q565bmxqy4q" path="res://raw_assets/music/cyber_implant_in_my_butt.ogg" id="1_iftcq"] [ext_resource type="AudioStream" uid="uid://cnvikognjv8go" path="res://raw_assets/music/S31-Sewer Nightclub.ogg" id="2_5qcgm"] +[ext_resource type="PackedScene" uid="uid://c62c5iq0w72ka" path="res://maps/precipice/precipice_static.scn" id="5_7gl35"] [sub_resource type="TeamResource" id="TeamResource_w4gl8"] name = "Copper Team" @@ -18,6 +19,7 @@ alt_color = Color(0.12941177, 0.12941177, 0.8509804, 1) [resource] name = "Precipice" scene = ExtResource("1_fwujm") +static_scene = ExtResource("5_7gl35") teams = Array[TeamResource]([SubResource("TeamResource_w4gl8"), SubResource("TeamResource_iftcq")]) music = Array[AudioStream]([ExtResource("1_iftcq"), ExtResource("2_5qcgm")]) icon = ExtResource("1_5qcgm") diff --git a/godot/maps/precipice/precipice_static.scn b/godot/maps/precipice/precipice_static.scn index ec83137..05a221f 100644 Binary files a/godot/maps/precipice/precipice_static.scn and b/godot/maps/precipice/precipice_static.scn differ diff --git a/godot/maps/two_towers.tres b/godot/maps/two_towers.tres index 32cbce7..ba819b6 100644 --- a/godot/maps/two_towers.tres +++ b/godot/maps/two_towers.tres @@ -5,6 +5,7 @@ [ext_resource type="PackedScene" uid="uid://c5p0ft870i1sk" path="res://maps/two_towers/two_towers.tscn" id="1_yteo6"] [ext_resource type="AudioStream" uid="uid://dkgm7o8u0w550" path="res://raw_assets/music/Red Doors 2.0 (GameClosure Edition).mp3" id="2_te6yd"] [ext_resource type="AudioStream" uid="uid://dai8by348wqss" path="res://raw_assets/music/Thrust Sequence.mp3" id="3_fdiiq"] +[ext_resource type="PackedScene" uid="uid://dpqqe7hjktit8" path="res://maps/two_towers/two_towers_static.scn" id="6_fdiiq"] [sub_resource type="TeamResource" id="TeamResource_64qm8"] name = "Shadow Team" @@ -19,6 +20,7 @@ alt_color = Color(0.8509804, 0.12941177, 0.12941177, 1) [resource] name = "Two Towers" scene = ExtResource("1_yteo6") +static_scene = ExtResource("6_fdiiq") teams = Array[TeamResource]([SubResource("TeamResource_64qm8"), SubResource("TeamResource_47vax")]) music = Array[AudioStream]([ExtResource("1_my665"), ExtResource("2_te6yd"), ExtResource("3_fdiiq")]) icon = ExtResource("1_te6yd") diff --git a/godot/maps/two_towers/two_towers_static.scn b/godot/maps/two_towers/two_towers_static.scn index 4fdcac9..9608295 100644 Binary files a/godot/maps/two_towers/two_towers_static.scn and b/godot/maps/two_towers/two_towers_static.scn differ diff --git a/godot/maps/vessel.tres b/godot/maps/vessel.tres index c3c360b..abf0566 100644 --- a/godot/maps/vessel.tres +++ b/godot/maps/vessel.tres @@ -3,6 +3,7 @@ [ext_resource type="Texture2D" uid="uid://cumnvlhn48b3k" path="res://maps/vessel/icon.png" id="1_24862"] [ext_resource type="AudioStream" uid="uid://dganvwj0c183d" path="res://raw_assets/music/Battle_1.ogg" id="2_y6db0"] [ext_resource type="AudioStream" uid="uid://bt1ruoxb454tn" path="res://raw_assets/music/Brains.ogg" id="3_prdtt"] +[ext_resource type="PackedScene" uid="uid://cmai3tqkk3db3" path="res://maps/vessel/vessel_static.scn" id="5_prdtt"] [ext_resource type="PackedScene" uid="uid://dk36d2s5vlp8k" path="res://maps/vessel/vessel.tscn" id="5_y6db0"] [ext_resource type="TeamResource" uid="uid://db4b3sjsftg15" path="res://maps/teams/red_ream.tres" id="6_prdtt"] [ext_resource type="TeamResource" uid="uid://p2fqqnaejjn7" path="res://maps/teams/blue_team.tres" id="7_b6v3a"] @@ -10,6 +11,7 @@ [resource] name = "Vessel" scene = ExtResource("5_y6db0") +static_scene = ExtResource("5_prdtt") teams = Array[TeamResource]([ExtResource("6_prdtt"), ExtResource("7_b6v3a")]) music = Array[AudioStream]([ExtResource("2_y6db0"), ExtResource("3_prdtt")]) icon = ExtResource("1_24862") diff --git a/godot/maps/vessel/vessel_static.scn b/godot/maps/vessel/vessel_static.scn index 5863401..3fe1471 100644 Binary files a/godot/maps/vessel/vessel_static.scn and b/godot/maps/vessel/vessel_static.scn differ diff --git a/godot/scenes/lobby.tscn b/godot/scenes/lobby.tscn index 9dd0856..f895877 100644 --- a/godot/scenes/lobby.tscn +++ b/godot/scenes/lobby.tscn @@ -9,7 +9,6 @@ [ext_resource type="Texture2D" uid="uid://bs5jp73lrqmoe" path="res://raw_assets/icons/PNG/White/1x/checkmark.png" id="4_yad6j"] [ext_resource type="Texture2D" uid="uid://cm4dcnb3i0ybq" path="res://raw_assets/icons/PNG/White/1x/cross.png" id="5_ncsg4"] [ext_resource type="Texture2D" uid="uid://di82vf1k8xr1d" path="res://raw_assets/icons/PNG/White/1x/wrench.png" id="5_omrgh"] -[ext_resource type="PackedScene" uid="uid://dpqqe7hjktit8" path="res://maps/two_towers/two_towers_static.scn" id="6_apkv3"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7j863"] bg_color = Color(0.06469653, 0.064696535, 0.06469648, 0.34901962) @@ -17,9 +16,10 @@ bg_color = Color(0.06469653, 0.064696535, 0.06469648, 0.34901962) [sub_resource type="LabelSettings" id="LabelSettings_1cgct"] font_size = 32 -[node name="lobby_world" type="LobbyWorld" unique_id=129662054 node_paths=PackedStringArray("lobby")] +[node name="lobby_world" type="LobbyWorld" unique_id=129662054 node_paths=PackedStringArray("lobby", "pivot")] menu_player_scene = ExtResource("3_q60fs") lobby = NodePath("lobby") +pivot = NodePath("pivot") [node name="lobby" type="LobbyPanel" parent="." unique_id=915192272 node_paths=PackedStringArray("players_list", "name_field", "ready_button", "map_selection", "options_panel", "options_grid", "options_tabs", "alt_colors")] players_list = NodePath("v_box_container/players_list") @@ -219,15 +219,12 @@ offset_top = 46.0 offset_right = -325.0 offset_bottom = -102.0 -[node name="camera_3d" type="Camera3D" parent="." unique_id=131019329] -transform = Transform3D(0.69531304, -0.068955034, 0.7153915, 3.1173069e-09, 0.99538684, 0.09594317, -0.718707, -0.06671053, 0.6921054, 3.165125, 2.0609732, 2.7751796) +[node name="pivot" type="Node3D" parent="." unique_id=1000626629] + +[node name="camera_3d" type="Camera3D" parent="pivot" unique_id=131019329] +transform = Transform3D(-4.371139e-08, -0.09584575, 0.9953962, 0, 0.9953962, 0.09584575, -1, 4.189551e-09, -4.351015e-08, 3.7266705, 2.3217216, 0) current = true -[node name="background" type="Node3D" parent="." unique_id=1511017299] - -[node name="two_towers_static" parent="background" unique_id=86902040 instance=ExtResource("6_apkv3")] -transform = Transform3D(-0.1736482, 0, -0.9848077, 0, 1, 0, 0.9848077, 0, -0.1736482, -15.664, -7, -7.637) - [connection signal="pressed" from="lobby/options_panel/h_box_container/h_box_container/options_close" to="lobby" method="close_options"] [connection signal="pressed" from="lobby/v_box_container3/h_box_container/exit_button" to="lobby" method="exit"] [connection signal="pressed" from="lobby/v_box_container3/h_box_container/options_button" to="lobby" method="open_options"] diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 855e515..b31cec0 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -13,6 +13,7 @@ pub mod killbox; pub mod lobby_world; pub mod map; pub mod map_resource; +pub mod map_static; pub mod net; pub mod pickup; pub mod player; diff --git a/rust/src/lobby_world.rs b/rust/src/lobby_world.rs index 06a4674..1a73b9d 100644 --- a/rust/src/lobby_world.rs +++ b/rust/src/lobby_world.rs @@ -2,7 +2,14 @@ use std::{collections::HashMap, f32::consts::PI}; use godot::{classes::RandomNumberGenerator, prelude::*}; -use crate::{game::Game, player::menu_player::MenuPlayer, ui::lobby::LobbyPanel}; +use crate::{ + game::{Game, GameManager}, + map::Map, + map_resource::MapResource, + map_static::StaticMap, + player::menu_player::MenuPlayer, + ui::lobby::LobbyPanel, +}; #[derive(GodotClass)] #[class(base=Node3D, init)] @@ -11,11 +18,15 @@ pub struct LobbyWorld { menu_player_scene: Option>, #[export] lobby: Option>, + #[export] + pivot: Option>, rng: Gd, menu_players: HashMap>, + background: Option>, + base: Base, } @@ -36,6 +47,9 @@ impl INode3D for LobbyWorld { game.signals() .on_players_updated() .connect_other(self, Self::update_players); + game.signals() + .on_map_changed() + .connect_other(self, Self::change_map); } if let Some(lobby) = &self.lobby { @@ -48,6 +62,28 @@ impl INode3D for LobbyWorld { } impl LobbyWorld { + fn change_map(&mut self, map: u8) { + if let Some(mut background) = self.background.take() { + background.queue_free(); + } + + self.run_deferred(move |s| { + if let Some(map) = GameManager::singleton().bind().maps.get(map as usize) { + if let Some(scene) = &map.bind().static_scene { + let mut background = scene.instantiate_as::(); + if let Some(center) = &background.clone().bind().lobby_center { + background.set_position(-center.get_position()); + if let Some(camera_pivot) = &mut s.pivot { + camera_pivot.set_rotation(center.get_rotation()); + } + } + s.base_mut().add_child(&background); + s.background = Some(background); + } + } + }); + } + fn on_new_player(&mut self, player_id: u16) { self.spawn_player(player_id); } @@ -63,12 +99,14 @@ impl LobbyWorld { if let Some(scene) = s.menu_player_scene.clone() { let x = s.rng.randf_range(-2., 2.); let z = s.rng.randf_range(-2., 2.); - let rotation = s.rng.randf_range(PI / 4., PI / 2.); + let rotation = s.rng.randf_range(-PI / 4., PI / 4.); let mut menu_player = scene.instantiate_as::(); menu_player.bind_mut().player_id = Some(player_id); s.menu_players.insert(player_id, menu_player.clone()); - s.base_mut().add_child(&menu_player); + if let Some(pivot) = &mut s.pivot { + pivot.add_child(&menu_player); + } menu_player.bind_mut().update(); diff --git a/rust/src/map_resource.rs b/rust/src/map_resource.rs index e190c2e..4843fbe 100644 --- a/rust/src/map_resource.rs +++ b/rust/src/map_resource.rs @@ -13,6 +13,8 @@ pub struct MapResource { #[export] pub scene: Option>, #[export] + pub static_scene: Option>, + #[export] pub teams: Array>, #[export] pub music: Array>, diff --git a/rust/src/map_static.rs b/rust/src/map_static.rs new file mode 100644 index 0000000..7b6aefa --- /dev/null +++ b/rust/src/map_static.rs @@ -0,0 +1,10 @@ +use godot::prelude::*; + +#[derive(GodotClass)] +#[class(base=Node3D, init)] +pub struct StaticMap { + #[export] + pub lobby_center: Option>, + + base: Base, +}