working on multiplayer

This commit is contained in:
2025-06-24 14:45:45 +02:00
parent b1050f627b
commit 5a813f212c
67 changed files with 499 additions and 127 deletions

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a6ee7382dba74afe84aaf53259b1cf8a
timeCreated: 1740769896

View 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;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8fcf71fe79ef1ed4cbfdefde09e708d9

View 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; }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e8d574cf0e024ec7bc4363a675dbb2c9
timeCreated: 1740768148