Multiple entities
This commit is contained in:
1 parent
ccc4c04234
commit
1de0e93ae0
5677 files changed
+364912
-919855
No files matched your search
@@ -4,6 +4,7 @@ using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Input;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using KinematicCharacterController;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -14,9 +15,9 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
private CameraStateMachine _cameraStateMachine;
|
||||
private IInputService _inputService;
|
||||
private PlayerMovementController _playerMovementController;
|
||||
private MovementController _movementController;
|
||||
|
||||
private readonly NavMeshPath _path = new();
|
||||
private NavMeshPath _path;
|
||||
private Vector3[] _corners;
|
||||
private int _currentCornerIndex;
|
||||
|
||||
@@ -25,14 +26,14 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
private const float StoppingDistance = 0.15f;
|
||||
|
||||
public BattleActionMove(
|
||||
[Inject]
|
||||
public void Construct(
|
||||
CameraStateMachine cameraStateMachine,
|
||||
IInputService inputService,
|
||||
PlayerMovementController playerMovementController)
|
||||
IInputService inputService)
|
||||
{
|
||||
_cameraStateMachine = cameraStateMachine;
|
||||
_inputService = inputService;
|
||||
_playerMovementController = playerMovementController;
|
||||
_movementController = GetComponent<MovementController>();
|
||||
_navMeshMask = LayerMask.GetMask("Environment");
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 currentPos = _playerMovementController.Motor.TransientPosition;
|
||||
Vector3 currentPos = _movementController.Motor.TransientPosition;
|
||||
|
||||
while (_currentCornerIndex < _corners.Length)
|
||||
{
|
||||
@@ -81,7 +82,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
float distance = moveDirection.magnitude;
|
||||
Vector3 moveNormal = distance > 0.0001f ? moveDirection / distance : Vector3.zero;
|
||||
|
||||
float maxStep = _playerMovementController.MaxStableMoveSpeed * tickDelta;
|
||||
float maxStep = _movementController.MaxStableMoveSpeed * tickDelta;
|
||||
float inputMagnitude = (_currentCornerIndex == _corners.Length - 1 && distance < maxStep && maxStep > 0f)
|
||||
? distance / maxStep
|
||||
: 1f;
|
||||
@@ -90,11 +91,11 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
MoveVector = moveNormal * inputMagnitude,
|
||||
Look = moveNormal.sqrMagnitude > 0.0001f
|
||||
? Quaternion.LookRotation(moveNormal, _playerMovementController.Motor.CharacterUp)
|
||||
: _playerMovementController.Motor.TransientRotation
|
||||
? Quaternion.LookRotation(moveNormal, _movementController.Motor.CharacterUp)
|
||||
: _movementController.Motor.TransientRotation
|
||||
};
|
||||
|
||||
_playerMovementController.SetInputs(ref aiInputs);
|
||||
_movementController.SetInputs(ref aiInputs);
|
||||
|
||||
KinematicCharacterSystem.Simulate(
|
||||
tickDelta,
|
||||
@@ -102,7 +103,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
KinematicCharacterSystem.PhysicsMovers
|
||||
);
|
||||
|
||||
Vector3 postMovePos = _playerMovementController.Motor.TransientPosition;
|
||||
Vector3 postMovePos = _movementController.Motor.TransientPosition;
|
||||
Vector3 toFinal = _corners[^1] - postMovePos;
|
||||
toFinal.y = 0f;
|
||||
|
||||
@@ -117,10 +118,10 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
var emptyInputs = new AICharacterInputs
|
||||
{
|
||||
MoveVector = Vector3.zero,
|
||||
Look = _playerMovementController.Motor.TransientRotation
|
||||
Look = _movementController.Motor.TransientRotation
|
||||
};
|
||||
_playerMovementController.SetInputs(ref emptyInputs);
|
||||
_playerMovementController.Motor.BaseVelocity = Vector3.zero;
|
||||
_movementController.SetInputs(ref emptyInputs);
|
||||
_movementController.Motor.BaseVelocity = Vector3.zero;
|
||||
|
||||
Finished = true;
|
||||
}
|
||||
@@ -132,7 +133,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
_waitForEnterTokenSource = new CancellationTokenSource();
|
||||
_decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
|
||||
_targetPosition = _playerMovementController.transform.position;
|
||||
_targetPosition = _movementController.transform.position;
|
||||
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Select,
|
||||
SelectPosition);
|
||||
@@ -158,6 +159,8 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
return _decisionResultCode;
|
||||
}
|
||||
|
||||
public override BattleActionType ActionType => BattleActionType.Move;
|
||||
|
||||
private void CancelPosition(InputAction.CallbackContext obj)
|
||||
{
|
||||
_decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
|
||||
@@ -166,8 +169,10 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
private void ConfirmPosition(InputAction.CallbackContext input)
|
||||
{
|
||||
Vector3 startPos = _playerMovementController.Motor.TransientPosition;
|
||||
Vector3 startPos = _movementController.Motor.TransientPosition;
|
||||
|
||||
_path = new();
|
||||
|
||||
if ((_targetPosition - startPos).sqrMagnitude > StoppingDistance * StoppingDistance
|
||||
&& NavMesh.CalculatePath(startPos, _targetPosition, NavMesh.AllAreas, _path)
|
||||
&& _path.corners.Length > 0)
|
||||
|
||||
Reference in new issue
Block a user