working on multiplayer
This commit is contained in:
60
Runtime/Engine/Code/Input/InputService.cs
Normal file
60
Runtime/Engine/Code/Input/InputService.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
public class InputService : IService {
|
||||
readonly Config m_Config;
|
||||
|
||||
AsyncOperationHandle<InputActionAsset> m_Handle;
|
||||
InputActionAsset m_InputActionAsset;
|
||||
|
||||
public InputService(Config config) {
|
||||
m_Config = config;
|
||||
|
||||
m_Handle = Addressables.LoadAssetAsync<InputActionAsset>(m_Config.inputAssetReference);
|
||||
m_InputActionAsset = m_Handle.WaitForCompletion();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
m_InputActionAsset = null;
|
||||
|
||||
Addressables.Release(m_Handle);
|
||||
m_Handle = default;
|
||||
}
|
||||
|
||||
public void EnableControls() {
|
||||
m_InputActionAsset.Enable();
|
||||
}
|
||||
|
||||
public void DisableControls() {
|
||||
m_InputActionAsset.Disable();
|
||||
}
|
||||
|
||||
public bool AreControlsEnabled() {
|
||||
return m_InputActionAsset.enabled;
|
||||
}
|
||||
|
||||
public InputAction FindInputAction(string path) {
|
||||
return m_InputActionAsset.FindAction(path);
|
||||
}
|
||||
|
||||
public void LockCursor() {
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
public void UnlockCursor() {
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Config {
|
||||
public AssetReferenceT<InputActionAsset> inputAssetReference;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Input/InputService.cs.meta
Normal file
3
Runtime/Engine/Code/Input/InputService.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6ee7382dba74afe84aaf53259b1cf8a
|
||||
timeCreated: 1740769896
|
||||
14
Runtime/Engine/Code/Input/InputServiceAsset.cs
Normal file
14
Runtime/Engine/Code/Input/InputServiceAsset.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
[CreateAssetMenu(menuName = RConsts.k_ServiceAssetMenu + "Input")]
|
||||
public class InputServiceAsset : ServiceAsset<InputService> {
|
||||
[SerializeField] InputService.Config m_Config;
|
||||
|
||||
public override InputService Create() {
|
||||
InputService instance = new InputService(m_Config);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/Engine/Code/Input/InputServiceAsset.cs.meta
Normal file
2
Runtime/Engine/Code/Input/InputServiceAsset.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fcf71fe79ef1ed4cbfdefde09e708d9
|
||||
10
Runtime/Engine/Code/Input/ScriptableInputAction.cs
Normal file
10
Runtime/Engine/Code/Input/ScriptableInputAction.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace RebootKit.Engine.Services.Input {
|
||||
[CreateAssetMenu(menuName = RConsts.k_AddComponentMenu + "Input Action", fileName = "Input Action")]
|
||||
public class ScriptableInputAction : ScriptableObject {
|
||||
[field: SerializeField]
|
||||
public InputAction Action { get; private set; }
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Input/ScriptableInputAction.cs.meta
Normal file
3
Runtime/Engine/Code/Input/ScriptableInputAction.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8d574cf0e024ec7bc4363a675dbb2c9
|
||||
timeCreated: 1740768148
|
||||
Reference in New Issue
Block a user