rename game manager

This commit is contained in:
anyreso 2024-05-07 22:57:53 -04:00
parent 32c80ea79a
commit f7fbbed014
7 changed files with 18 additions and 18 deletions

View file

@ -103,7 +103,7 @@ func _setup_pawn(_new_player_id : int) -> void:
func _is_pawn() -> bool: func _is_pawn() -> bool:
var peer_is_pawn : bool = multiplayer.get_unique_id() == match_participant_component.player_id var peer_is_pawn : bool = multiplayer.get_unique_id() == match_participant_component.player_id
return GameManager.mode is Singleplayer or peer_is_pawn return Game.mode is Singleplayer or peer_is_pawn
# @NOTE: this method works only because `tp_mesh` duplicates weapons meshes from the inventory # @NOTE: this method works only because `tp_mesh` duplicates weapons meshes from the inventory
func _on_inventory_selection_changed(_selected : Node3D, index : int) -> void: func _on_inventory_selection_changed(_selected : Node3D, index : int) -> void:

View file

@ -35,7 +35,7 @@ func trigger() -> void:
owner.match_participant_component owner.match_participant_component
) )
# add to owner of player for now # add to owner of player for now
GameManager.mode.add_child(projectile) Game.mode.add_child(projectile)
projectile.shape_cast.add_exception(owner) projectile.shape_cast.add_exception(owner)
func _on_visibility_changed() -> void: func _on_visibility_changed() -> void:

View file

@ -21,7 +21,7 @@ func trigger() -> void:
owner.match_participant_component owner.match_participant_component
) )
# add to owner of player for now # add to owner of player for now
GameManager.mode.add_child(projectile) Game.mode.add_child(projectile)
func _on_visibility_changed() -> void: func _on_visibility_changed() -> void:
if self.visible: if self.visible:

View file

@ -36,7 +36,7 @@ func trigger() -> void:
owner.match_participant_component owner.match_participant_component
) )
# add to owner of player for now # add to owner of player for now
GameManager.mode.add_child(projectile) Game.mode.add_child(projectile)
# ensure projectile does not collide with owner # ensure projectile does not collide with owner
var collider : ShapeCast3D = projectile.shape_cast var collider : ShapeCast3D = projectile.shape_cast
collider.add_exception(owner) collider.add_exception(owner)

View file

@ -19,7 +19,7 @@ script/source = "# This file is part of open-fpsz.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name Game extends Node3D extends Node3D
@export_category(\"Modes\") @export_category(\"Modes\")
@export var SINGLEPLAYER : PackedScene @export var SINGLEPLAYER : PackedScene
@ -28,8 +28,8 @@ class_name Game extends Node3D
func _ready() -> void: func _ready() -> void:
# only run server in headless # only run server in headless
if DisplayServer.get_name() == \"headless\": if DisplayServer.get_name() == \"headless\":
GameManager.mode = MULTIPLAYER.instantiate() Game.mode = MULTIPLAYER.instantiate()
GameManager.mode.start_server(9000, MapsManager.maps[MapsManager._rng.randi_range(0, len(MapsManager.maps) - 1)]) Game.mode.start_server(9000, MapsManager.maps[MapsManager._rng.randi_range(0, len(MapsManager.maps) - 1)])
return return
# connect boot menu signals # connect boot menu signals
$BootMenu.start_demo.connect(_start_demo) $BootMenu.start_demo.connect(_start_demo)
@ -41,12 +41,12 @@ func _ready() -> void:
func _unhandled_input(event : InputEvent) -> void: func _unhandled_input(event : InputEvent) -> void:
if event.is_action_pressed(\"exit\"): if event.is_action_pressed(\"exit\"):
if GameManager.mode is Multiplayer: if Game.mode is Multiplayer:
$BootMenu._on_multiplayer_pressed() $BootMenu._on_multiplayer_pressed()
else: else:
$BootMenu._on_main_menu_pressed() $BootMenu._on_main_menu_pressed()
# reset game mode and get back to main menu # reset game mode and get back to main menu
GameManager.mode = null Game.mode = null
if DisplayServer.get_name() != \"headless\": if DisplayServer.get_name() != \"headless\":
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
return return
@ -66,25 +66,25 @@ func _unhandled_input(event : InputEvent) -> void:
func _start_demo() -> void: func _start_demo() -> void:
GameManager.mode = SINGLEPLAYER.instantiate() Game.mode = SINGLEPLAYER.instantiate()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
$BootMenu.hide() $BootMenu.hide()
func _start_server(port : int, nickname : String) -> void: func _start_server(port : int, nickname : String) -> void:
GameManager.mode = MULTIPLAYER.instantiate() Game.mode = MULTIPLAYER.instantiate()
GameManager.mode.start_server(port, MapsManager.maps[$BootMenu/MultiplayerPanelContainer.map_selector.selected], nickname) Game.mode.start_server(port, MapsManager.maps[$BootMenu/MultiplayerPanelContainer.map_selector.selected], nickname)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
$BootMenu.hide() $BootMenu.hide()
func _join_server(host : String, port : int, nickname : String) -> void: func _join_server(host : String, port : int, nickname : String) -> void:
GameManager.mode = MULTIPLAYER.instantiate() Game.mode = MULTIPLAYER.instantiate()
GameManager.mode.connected_to_server.connect($BootMenu/MultiplayerPanelContainer._on_connected_to_server) Game.mode.connected_to_server.connect($BootMenu/MultiplayerPanelContainer._on_connected_to_server)
GameManager.mode.connection_failed.connect($BootMenu/MultiplayerPanelContainer._on_connection_failed) Game.mode.connection_failed.connect($BootMenu/MultiplayerPanelContainer._on_connection_failed)
GameManager.mode.join_server(host, port, nickname) Game.mode.join_server(host, port, nickname)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
" "
[node name="Game" type="Node3D"] [node name="Main" type="Node3D"]
script = SubResource("GDScript_e61dq") script = SubResource("GDScript_e61dq")
SINGLEPLAYER = ExtResource("1_vgk6g") SINGLEPLAYER = ExtResource("1_vgk6g")
MULTIPLAYER = ExtResource("2_iumx3") MULTIPLAYER = ExtResource("2_iumx3")

View file

@ -19,7 +19,7 @@ config/icon="res://icon.svg"
Settings="*res://systems/settings.gd" Settings="*res://systems/settings.gd"
MapsManager="*res://systems/maps_manager.gd" MapsManager="*res://systems/maps_manager.gd"
GameManager="*res://systems/game_manager.gd" Game="*res://systems/game.gd"
[debug] [debug]