HoloCop in progress
This commit is contained in:
1 parent
2697212f05
commit
430b250075
79 files changed
+120745
-45077
No files matched your search
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Camera.CameraStates;
|
||||
using Code.Infrastructure.Input;
|
||||
@@ -11,15 +10,18 @@ namespace Code.Game.OfficeGame.BattleMode
|
||||
[Infrastructure.Generators.State(typeof(CameraMode), typeof(CameraStateMachineContext), ManualInherit = true)]
|
||||
public partial class CameraBattleModeState : BaseCameraState
|
||||
{
|
||||
public bool battleDeciding = false;
|
||||
private bool _rightClickHold = false;
|
||||
|
||||
private Vector2 _mouseDelta;
|
||||
private Vector2 _rotation = Vector2.zero;
|
||||
private Vector2 _movement;
|
||||
private float _verticalMovement; // Если захотите добавить Space / Ctrl как в Minecraft
|
||||
|
||||
[Header("Look Settings")] private float _sensitivityX = 0.1f;
|
||||
private float _sensitivityX = 0.1f;
|
||||
private float _sensitivityY = 0.1f;
|
||||
|
||||
[Header("Spectator Flight Settings")] private float _moveSpeed = 12f;
|
||||
private float _moveSpeed = 12f;
|
||||
private float _cameraRadius = 0.25f; // Должен быть больше nearClipPlane камеры (обычно 0.05 - 0.1)
|
||||
private LayerMask _obstacleMask = ~0; // По умолчанию все слои (настройте, исключив триггеры/юнитов)
|
||||
|
||||
@@ -55,6 +57,15 @@ namespace Code.Game.OfficeGame.BattleMode
|
||||
(int)ActionMappings.BattleMode,
|
||||
(int)BattleModeActions.Watchment,
|
||||
LookCancelled);
|
||||
|
||||
Context.InputService.BindActionPerformed(
|
||||
(int)ActionMappings.BattleMode,
|
||||
(int)BattleModeActions.RightClick,
|
||||
RightClickPerformed);
|
||||
Context.InputService.BindActionCancelled(
|
||||
(int)ActionMappings.BattleMode,
|
||||
(int)BattleModeActions.RightClick,
|
||||
RightClickCancelled);
|
||||
|
||||
var camTransform = Context.cameraLoadedData.Camera.transform;
|
||||
|
||||
@@ -102,6 +113,9 @@ namespace Code.Game.OfficeGame.BattleMode
|
||||
|
||||
private void LookCancelled(InputAction.CallbackContext obj) => _mouseDelta = Vector2.zero;
|
||||
private void LookPerformed(InputAction.CallbackContext obj) => _mouseDelta = obj.ReadValue<Vector2>();
|
||||
|
||||
private void RightClickCancelled(InputAction.CallbackContext obj) => _rightClickHold = false;
|
||||
private void RightClickPerformed(InputAction.CallbackContext obj) => _rightClickHold = true;
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
@@ -112,15 +126,15 @@ namespace Code.Game.OfficeGame.BattleMode
|
||||
var camTransform = Context.cameraLoadedData.Camera.transform;
|
||||
float dt = Time.unscaledDeltaTime;
|
||||
|
||||
// --- 1. СВОБОДНЫЙ ОБЗОР ОТ ПЕРВОГО ЛИЦА (Yaw + Pitch) ---
|
||||
_rotation.x += _mouseDelta.x * _sensitivityX;
|
||||
_rotation.y -= _mouseDelta.y * _sensitivityY;
|
||||
_rotation.y = Mathf.Clamp(_rotation.y, -89.9f, 89.9f);
|
||||
if (!(battleDeciding && !_rightClickHold))
|
||||
{
|
||||
_rotation.x += _mouseDelta.x * _sensitivityX;
|
||||
_rotation.y -= _mouseDelta.y * _sensitivityY;
|
||||
_rotation.y = Mathf.Clamp(_rotation.y, -89.9f, 89.9f);
|
||||
|
||||
// Используем мировое вращение, чтобы камера всегда держала горизонт ровно (без завала Roll)
|
||||
camTransform.rotation = Quaternion.Euler(_rotation.y, _rotation.x, 0f);
|
||||
|
||||
// --- 2. ВЕКТОР ПОЛЁТА КАК В CS / MINECRAFT SPECTATOR ---
|
||||
camTransform.rotation = Quaternion.Euler(_rotation.y, _rotation.x, 0f);
|
||||
}
|
||||
|
||||
Vector3 wishDir = camTransform.forward * _movement.y + camTransform.right * _movement.x;
|
||||
|
||||
// Если добавите кнопки вверх/вниз (Space/Ctrl), раскомментируйте:
|
||||
@@ -131,10 +145,8 @@ namespace Code.Game.OfficeGame.BattleMode
|
||||
|
||||
Vector3 currentPos = camTransform.position;
|
||||
|
||||
// --- 3. ВЫТАЛКИВАНИЕ (Если камера начала кадр внутри стены или двери) ---
|
||||
currentPos = Depenetrate(currentPos);
|
||||
|
||||
// --- 4. ДВИЖЕНИЕ И СКОЛЬЖЕНИЕ ПО СТЕНАМ И УГЛАМ ---
|
||||
if (wishDir.sqrMagnitude > 0.0001f)
|
||||
{
|
||||
Vector3 displacement = wishDir * (_moveSpeed * dt);
|
||||
|
||||
Reference in new issue
Block a user