fixed input controls asset duplication

This commit is contained in:
2025-06-18 17:23:50 +02:00
parent cd3c67419b
commit 7b9470598b
13 changed files with 233 additions and 47 deletions

View File

@@ -7,11 +7,14 @@ using Unity.Mathematics;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.InputSystem;
using Logger = RebootKit.Engine.Foundation.Logger;
using Object = UnityEngine.Object;
namespace RebootReality.jelycho.Player {
public class PlayerController : IController {
readonly Logger s_logger = new Logger(nameof(PlayerController));
readonly Config m_Config;
PlayerActor m_FPPActor;
public PlayerController(Config config) {
@@ -32,7 +35,7 @@ namespace RebootReality.jelycho.Player {
m_FPPActor.WarpTo(worldContext.PlayerSpawnPoint.position);
}
await Awaitable.NextFrameAsync(cancellationToken);
await UniTask.Yield(cancellationToken);
}
public void OnStop() {
@@ -44,11 +47,8 @@ namespace RebootReality.jelycho.Player {
}
public void OnTick() {
if (m_FPPActor == null) {
return;
}
if (!Application.isFocused) {
if (m_FPPActor is null) {
s_logger.Error("Player actor is not initialized. Make sure to call OnStart() before OnTick().");
return;
}
@@ -76,7 +76,7 @@ namespace RebootReality.jelycho.Player {
[Serializable]
public class Config {
public AssetReferenceT<GameObject> playerActorPrefab;
public InputActionReference moveActionReference;
public InputActionReference lookActionReference;
public InputActionReference jumpActionReference;
@@ -86,7 +86,7 @@ namespace RebootReality.jelycho.Player {
public InputActionReference secondaryActionReference;
}
}
public static class FPPConfig {
[ConfigVar("fpp.mouse.sens", 0.25f, "Mouse look sensitivity")] public static ConfigVar MouseSensitivity;
[ConfigVar("fpp.mouse.invert.y", 0, "Invert mouse look")] public static ConfigVar MouseInvertY;