feat: add game bootstrap for mouse capture handling
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Game.Bootstrap;
|
|
||||||
|
|
||||||
public partial class GameBootstrap : Node
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using Game.Godot.Mappings;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Game.Godot.Bootstrap;
|
||||||
|
|
||||||
|
public partial class GameBootstrap : Node
|
||||||
|
{
|
||||||
|
private static void ToggleMouseCapture()
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseMode == Input.MouseModeEnum.Captured
|
||||||
|
? Input.MouseModeEnum.Visible
|
||||||
|
: Input.MouseModeEnum.Captured;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
|
{
|
||||||
|
if (@event.IsActionPressed(InputAction.Cancel.ActionName()))
|
||||||
|
{
|
||||||
|
ToggleMouseCapture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://b5i827vmueyei" path="res://assets/textures/skyboxes/skybox_emx_19.png" id="1_g4n7o"]
|
[ext_resource type="Texture2D" uid="uid://b5i827vmueyei" path="res://assets/textures/skyboxes/skybox_emx_19.png" id="1_g4n7o"]
|
||||||
[ext_resource type="PackedScene" uid="uid://curuqmbndymi6" path="res://src/Scenes/FloorCeilingHr42.tscn" id="2_1kpcd"]
|
[ext_resource type="PackedScene" uid="uid://curuqmbndymi6" path="res://src/Scenes/FloorCeilingHr42.tscn" id="2_1kpcd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bka1dmgdi5btd" path="res://src/Features/Player/Godot/PlayerNode.tscn" id="2_mvtit"]
|
[ext_resource type="PackedScene" uid="uid://bka1dmgdi5btd" path="res://src/Features/Player/Godot/PlayerNode.tscn" id="2_mvtit"]
|
||||||
|
[ext_resource type="Script" uid="uid://drctu5y21ey2y" path="res://src/Godot/Bootstrap/GameBootstrap.cs" id="3_bootstrap"]
|
||||||
|
|
||||||
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_epykj"]
|
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_epykj"]
|
||||||
panorama = ExtResource("1_g4n7o")
|
panorama = ExtResource("1_g4n7o")
|
||||||
@@ -16,6 +17,7 @@ sky = SubResource("Sky_1kpcd")
|
|||||||
glow_enabled = true
|
glow_enabled = true
|
||||||
|
|
||||||
[node name="GameWorld" type="Node" unique_id=222644234]
|
[node name="GameWorld" type="Node" unique_id=222644234]
|
||||||
|
script = ExtResource("3_bootstrap")
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1669211403]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1669211403]
|
||||||
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
|
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user