BallanceStalker/scripts/GameRoot.cs

38 lines
1.0 KiB
C#
Raw Normal View History

2022-07-02 21:23:45 +08:00
using Godot;
using System;
public class GameRoot : Node {
MenuManager mMenuManager;
StalkerCore mStalkerCore;
public override void _Ready() {
mMenuManager = GetNode<MenuManager>("UILayer/MenuManager");
mStalkerCore = GetNode<StalkerCore>("StalkerCore");
mMenuManager.Connect(nameof(MenuManager.SetMouseCapture), this, nameof(Proc_MenuManager_SetMouseCapture));
mMenuManager.Connect(nameof(MenuManager.ExitGame), this, nameof(Proc_MenuManager_ExitGame));
// raw executing this func
// to set proper status
Proc_MenuManager_SetMouseCapture();
}
public override void _Input(InputEvent @event) {
}
private void Proc_MenuManager_SetMouseCapture() {
if (mMenuManager.Visible) {
Input.SetMouseMode(Input.MouseMode.Visible);
} else {
Input.SetMouseMode(Input.MouseMode.Captured);
}
}
private void Proc_MenuManager_ExitGame() {
GetTree().Notification(MainLoop.NotificationWmQuitRequest);
}
}