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

@@ -66,10 +66,10 @@ namespace RebootReality.jelycho.Main {
public class JelychoGame : IGame {
[Serializable]
public class Config {
public WorldConfigAsset mainMenuWorldConfig;
public GameModeAsset standardGameMode;
public WorldConfigAsset worldAstek;
public string mainMenuWorld = "main_menu";
public string mainGameplayWorld = "dev";
public string standardGameMode = "gm_standard";
}
readonly Config m_Config;
@@ -90,7 +90,9 @@ namespace RebootReality.jelycho.Main {
RR.GameModes.ActiveGameMode.Subscribe(gameMode => {
if (gameMode == null) {
RR.Console.WriteToOutput("Game mode stopped, loading main menu world");
RR.World.LoadAsync(m_Config.mainMenuWorldConfig.Config, CancellationToken.None).Forget();
WorldConfigAsset mainMenuWorldConfigAsset = RR.GetWorldConfigAsset(m_Config.mainMenuWorld);
RR.World.LoadAsync(mainMenuWorldConfigAsset.Config, CancellationToken.None).Forget();
}
})
.AddTo(ref m_DisposableBag);
@@ -101,7 +103,10 @@ namespace RebootReality.jelycho.Main {
}
public void NewGame() {
RR.StartGameMode(m_Config.standardGameMode, m_Config.worldAstek.Config);
GameModeAsset gameModeAsset = RR.GetGameMode(m_Config.standardGameMode);
WorldConfigAsset worldConfigAsset = RR.GetWorldConfigAsset(m_Config.mainGameplayWorld);
RR.StartGameMode(gameModeAsset, worldConfigAsset.Config);
}
}
}

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;