No liminal
This commit is contained in:
1 parent
a5ce0dbd6f
commit
a3cd3e86a1
229 files changed
+41
-13884
No files matched your search
@@ -30,18 +30,17 @@ namespace Code.Infrastructure.App
|
||||
|
||||
}
|
||||
|
||||
private Loading initialLoading;
|
||||
private Loading _initialLoading;
|
||||
private Container _thatRightContainer;
|
||||
private void Bootstrap(Container container)
|
||||
{
|
||||
_thatRightContainer = container;
|
||||
|
||||
container.Resolve<EventBus.EventBus>().Subscribe(this);
|
||||
// container.Resolve<SceneLoader.SceneLoader>();
|
||||
// container.Resolve<IInputService>();
|
||||
|
||||
container.Resolve<CameraFactory>().CreateCameraStateMachine(container.Resolve<CameraStateMachine>()).Forget();
|
||||
|
||||
initialLoading = new Loading(3, () => EssentialLoadEnded(container));
|
||||
_initialLoading = new Loading(3, () => EssentialLoadEnded(container));
|
||||
}
|
||||
|
||||
private void EssentialLoadEnded(Container container)
|
||||
@@ -52,12 +51,12 @@ namespace Code.Infrastructure.App
|
||||
|
||||
public void SceneConfigsLoaded()
|
||||
{
|
||||
initialLoading.DoProgress();
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void InputServiceInitialized()
|
||||
{
|
||||
initialLoading.DoProgress();
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void CameraInitialized(CameraStateMachineContext.CameraLoadedData data)
|
||||
@@ -65,7 +64,7 @@ namespace Code.Infrastructure.App
|
||||
_thatRightContainer.Resolve<CameraStateMachineContext>().cameraLoadedData = data;
|
||||
_thatRightContainer.Resolve<CameraStateMachine>().SwitchState(CameraMode.None)
|
||||
.AllowStateTransition(CameraMode.FirstPerson);
|
||||
initialLoading.DoProgress();
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,7 @@ namespace Code.Infrastructure.App.States
|
||||
public override AppStates myState => AppStates.Bootstrap;
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
_eventBus.Subscribe(this);
|
||||
Context.Camera.SwitchState(CameraMode.FirstPerson).AllowStateTransition(CameraMode.None);
|
||||
_eventBus.Subscribe(this);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Gameplay, LoadSceneMode.Single).Forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Code.Infrastructure.App.States
|
||||
public override AppStates myState => AppStates.Gameplay;
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
Context.Camera.SwitchState(CameraMode.FirstPerson).AllowStateTransition(CameraMode.None);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnExitState()
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
using Code.Example.Liminal.Player;
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.Infrastructure.Input;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Code.Infrastructure.Camera.CameraStates
|
||||
{
|
||||
|
||||
[State(typeof(CameraMode),typeof(CameraStateMachineContext), true)]
|
||||
public partial class FirstPersonCameraState : BaseCameraState
|
||||
{
|
||||
private CameraSettingsConfig _settings;
|
||||
|
||||
public FirstPersonCameraState(CameraStateMachineContext context, EventBus.EventBus eventBus) : base(context, eventBus)
|
||||
{
|
||||
}
|
||||
|
||||
public override CameraMode myState => CameraMode.FirstPerson;
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
_settings = Context.cameraLoadedData.SettingsConfigs[myState];
|
||||
|
||||
Context.InputService.BindActionPerformed((int)ActionMappings.Gameplay, (int) GameplayActions.Look, OnLookPerformed);
|
||||
Context.InputService.BindActionCancel((int)ActionMappings.Gameplay, (int) GameplayActions.Look, OnLookCanceled);
|
||||
}
|
||||
protected override void HandleRotationInput(float deltaTime, Vector3 rotationInput, out Quaternion targetRotation)
|
||||
{
|
||||
// Вращение вокруг вертикальной оси (горизонтальный поворот)
|
||||
var rotationFromInput = Quaternion.Euler(Vector3.up * (rotationInput.x * _settings.rotationSpeed));
|
||||
PlanarDirection = rotationFromInput * PlanarDirection;
|
||||
var planarRotation = Quaternion.LookRotation(PlanarDirection, FollowTransform.up);
|
||||
|
||||
// Вращение вокруг горизонтальной оси (вертикальный наклон)
|
||||
TargetVerticalAngle -= rotationInput.y * _settings.rotationSpeed;
|
||||
TargetVerticalAngle = Mathf.Clamp(TargetVerticalAngle, _settings.minVerticalAngle, _settings.maxVerticalAngle);
|
||||
var verticalRotation = Quaternion.Euler(TargetVerticalAngle, 0, 0);
|
||||
|
||||
// Интерполяция к целевому вращению для плавности
|
||||
targetRotation = Quaternion.Slerp(Context.cameraLoadedData.Camera.transform.rotation, planarRotation * verticalRotation, deltaTime * _settings.rotationSharpness);
|
||||
|
||||
// Применение финального вращения
|
||||
Context.cameraLoadedData.Camera.transform.rotation = targetRotation;
|
||||
}
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void HandlePosition(float deltaTime, object targetRotation)
|
||||
{
|
||||
// Плавное следование за целью с использованием экспоненциального сглаживания
|
||||
// CurrentFollowPosition = Vector3.Lerp(CurrentFollowPosition, FollowTransform.position, 1f - Mathf.Exp(-_settings.followSharpness * deltaTime));
|
||||
|
||||
// В FirstPerson режиме камера находится прямо на позиции цели Да ну нахуй чё правда пиздец
|
||||
// var targetPosition = CurrentFollowPosition;
|
||||
|
||||
// Установка финальной позиции камеры Да ну нахуй чё правда пиздец
|
||||
Context.cameraLoadedData.Camera.transform.position = FollowTransform.position;
|
||||
}
|
||||
|
||||
private Vector2 _lookInput;
|
||||
|
||||
private void OnLookPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
_lookInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
private void OnLookCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
_lookInput = Vector2.zero;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public override void LateUpdate()
|
||||
{
|
||||
// Обновляем камеру только если есть цель для следования
|
||||
// if (FollowTransform)
|
||||
// {
|
||||
// UpdateWithInput(Time.deltaTime, _lookInput);
|
||||
// }
|
||||
if (_playerMovementController)
|
||||
{
|
||||
UpdateWithInput(Time.deltaTime, _lookInput);
|
||||
|
||||
_playerMovementController.SetCameraRotation(Context.cameraLoadedData.Camera.transform.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFollowTransform(Transform t)
|
||||
{
|
||||
FollowTransform = t;
|
||||
CurrentFollowPosition = t.position;
|
||||
PlanarDirection = t.forward; // Начальное направление совпадает с направлением цели
|
||||
}
|
||||
|
||||
private PlayerMovementController _playerMovementController;
|
||||
public void SetPlayer(PlayerMovementController playerMovementController)
|
||||
{
|
||||
_playerMovementController = playerMovementController;
|
||||
|
||||
FollowTransform = _playerMovementController.PlayerHeadPoint;
|
||||
CurrentFollowPosition = _playerMovementController.PlayerHeadPoint.position;
|
||||
PlanarDirection = _playerMovementController.PlayerHeadPoint.forward; // Начальное направление совпадает с направлением цели
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 850f6325ab66480e9f7d1c03dbb37030
|
||||
timeCreated: 1767346203
|
||||
@@ -31,8 +31,8 @@ namespace Code.Infrastructure.Input
|
||||
|
||||
inputActionAsset = _configHandle.Result.inputActionAsset;
|
||||
|
||||
inputActionAsset.actionMaps[(int)ActionMappings.Debug].Enable();
|
||||
inputActionAsset.actionMaps[(int)ActionMappings.Gameplay].Enable();
|
||||
// inputActionAsset.actionMaps[(int)ActionMappings.Debug].Enable();
|
||||
// inputActionAsset.actionMaps[(int)ActionMappings.Gameplay].Enable();
|
||||
|
||||
_eventBus.RaiseEvent<IInputServiceInitializedHandle>(h => h.InputServiceInitialized());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user