refactor: moved a lot of player related scripts to the Reset.Units namespace

This commit is contained in:
Chris
2025-10-07 21:30:32 -04:00
parent 6c0163090b
commit 5886c9783b
19 changed files with 518 additions and 401 deletions

View File

@@ -4,32 +4,33 @@ using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UIElements;
public class InputFinder : MonoBehaviour{
public InputActionMap actionMap;
void Start(){
actionMap.actions[0].performed += ctx => { InputPressed(ctx); };
GetComponent<UIDocument>().enabled = false;
}
namespace Reset.Units{
public class InputFinder : MonoBehaviour{
public InputActionMap actionMap;
public void AwaitNewInput(){
GameManager.ClearCurrentController();
GetComponent<UIDocument>().enabled = true;
actionMap.Enable();
}
void Start(){
actionMap.actions[0].performed += ctx => { InputPressed(ctx); };
void InputPressed(InputAction.CallbackContext context){
try {
GameManager.AttachControllerToPlayer(context.control.device);
Debug.Log(context.control.device);
} catch (Exception e) {
Debug.LogError($"Failed to set the new device to the player: {e.Message}");
return;
GetComponent<UIDocument>().enabled = false;
}
GetComponent<UIDocument>().enabled = false;
actionMap.Disable();
public void AwaitNewInput(){
PlayerManager.ClearCurrentController();
GetComponent<UIDocument>().enabled = true;
actionMap.Enable();
}
void InputPressed(InputAction.CallbackContext context){
try {
PlayerManager.AttachControllerToPlayer(context.control.device);
} catch (Exception e) {
Debug.LogError($"Failed to set the new device to the player: {e.Message}");
return;
}
GetComponent<UIDocument>().enabled = false;
actionMap.Disable();
}
}
}