This commit is contained in:
2025-04-18 11:36:40 +02:00
parent cc0441e7ea
commit 62d340853d
180 changed files with 1387 additions and 1467 deletions

View File

@@ -0,0 +1,87 @@
using System;
using System.Threading;
using Cysharp.Threading.Tasks;
using RebootKit.Engine;
using RebootKit.Engine.Foundation;
using RebootKit.Engine.Services.Input;
using RebootKit.FPPKit;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
using Object = UnityEngine.Object;
namespace RealityReboot.jelycho.Player {
public class PlayerController : IController {
readonly Config m_Config;
PlayerActor m_FPPActor;
[Inject] InputService m_InputService;
public PlayerController(Config config) {
m_Config = config;
}
public void Dispose() {
}
public async UniTask OnStart(CancellationToken cancellationToken) {
m_InputService.LockCursor();
m_InputService.EnableControls();
m_FPPActor = await RR.World.SpawnActor<PlayerActor>(m_Config.playerActorPrefab, cancellationToken);
m_FPPActor.Simulate = true;
await Awaitable.NextFrameAsync(cancellationToken);
}
public void OnStop() {
m_InputService.DisableControls();
m_InputService.UnlockCursor();
Object.Destroy(m_FPPActor);
RR.World.KillActor(m_FPPActor);
}
public void OnTick() {
if (m_FPPActor == null) {
return;
}
if (!Application.isFocused) {
return;
}
Vector2 lookInput = SensitivityReader.Read(m_Config.lookActionReference.action);
m_FPPActor.Look(lookInput * FPPConfig.s_MouseSensitivity.FloatValue);
Vector2 moveInput = m_Config.moveActionReference.action.ReadValue<Vector2>();
m_FPPActor.MoveRight(moveInput.x);
m_FPPActor.MoveForward(moveInput.y);
if (m_Config.jumpActionReference.action.WasPerformedThisFrame()) {
m_FPPActor.Jump();
}
if (m_Config.dragObjectActionReference.action.WasPressedThisFrame()) {
m_FPPActor.StartDrag();
}
if (m_Config.dragObjectActionReference.action.WasReleasedThisFrame()) {
m_FPPActor.StopDrag();
}
}
[Serializable]
public class Config {
[FormerlySerializedAs("fppActorPrefab")] public AssetReferenceT<GameObject> playerActorPrefab;
public InputActionReference moveActionReference;
public InputActionReference lookActionReference;
public InputActionReference jumpActionReference;
public InputActionReference dragObjectActionReference;
public InputActionReference primaryActionReference;
public InputActionReference secondaryActionReference;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b37cddcc047346c18521710d64a2ec39
timeCreated: 1744662625

View File

@@ -0,0 +1,14 @@
using RebootKit.Engine.Foundation;
using UnityEngine;
namespace RealityReboot.jelycho.Player {
[CreateAssetMenu(menuName = GameConsts.k_CreateAssetMenu + "Player/Player Controller")]
public class PlayerControllerAsset : ControllerAsset {
[SerializeField] PlayerController.Config m_Config;
public override IController Create(DIContext context) {
PlayerController controller = context.Create<PlayerController>(m_Config);
return controller;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a96eb98c0051478f95c5ee18399ec93f
timeCreated: 1744662807