Multiple entities
This commit is contained in:
1 parent
ccc4c04234
commit
1de0e93ae0
5677 files changed
+364912
-919855
No files matched your search
@@ -1,11 +1,13 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public abstract class BattleAction
|
||||
public abstract class BattleAction : MonoBehaviour
|
||||
{
|
||||
public bool Finished { get; protected set; }
|
||||
public abstract void Tick(float tickDelta);
|
||||
public abstract UniTask<BattleActionDecisionResultCode> DecideAction();
|
||||
public abstract BattleActionType ActionType { get; }
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -19,5 +19,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
return BattleActionDecisionResultCode.Decided;
|
||||
}
|
||||
|
||||
public override BattleActionType ActionType => BattleActionType.Wait;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a301d248b3d4b3b8218e5e6d0bcb10a
|
||||
timeCreated: 1792768701
|
||||
@@ -0,0 +1,11 @@
|
||||
using TinyGoose.Tremble;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions.Companions
|
||||
{
|
||||
[PrefabEntity()]
|
||||
public class OnMapCompanion : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86667e70b64146cda8e1a79a88fb8d6d
|
||||
timeCreated: 1792774265
|
||||
@@ -15,5 +15,13 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
public Animator animator;
|
||||
|
||||
protected readonly Dictionary<BattleActionType, BattleAction> BattleActions = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
foreach (var action in GetComponents<BattleAction>())
|
||||
{
|
||||
BattleActions.Add(action.ActionType, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-19
@@ -1,7 +1,4 @@
|
||||
using System.Threading;
|
||||
using Code.Game.Gameplay.Player;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.OfficeGame.BattleMode.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Reflex.Attributes;
|
||||
@@ -9,21 +6,10 @@ using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions.Player
|
||||
{
|
||||
public class PlayerTimelineActor : EntityTimelineActor
|
||||
public class PlayerControlledTimelineActor : EntityTimelineActor
|
||||
{
|
||||
[Inject] private BattleActionDecisionPanel _battleActionDecisionPanel;
|
||||
|
||||
[Inject]
|
||||
private void Construct(
|
||||
CameraStateMachine cameraStateMachine,
|
||||
IInputService inputService,
|
||||
PlayerMovementController playerMovementController)
|
||||
{
|
||||
BattleActions.Add(BattleActionType.Wait, new BattleActionWait());
|
||||
BattleActions.Add(BattleActionType.Move,
|
||||
new BattleActionMove(cameraStateMachine, inputService, playerMovementController));
|
||||
}
|
||||
|
||||
public override async UniTask DecideAction(CancellationToken ctx)
|
||||
{
|
||||
BattleActionDecisionResultCode decision = BattleActionDecisionResultCode.Deciding;
|
||||
@@ -35,7 +21,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Player
|
||||
while (decidedAction == BattleActionType.None || ctx.IsCancellationRequested)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
|
||||
|
||||
await _battleActionDecisionPanel.Open(ctx);
|
||||
|
||||
decidedAction = await _battleActionDecisionPanel.GetDecision(ctx);
|
||||
@@ -45,10 +31,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Player
|
||||
&& !ctx.IsCancellationRequested)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
|
||||
await _battleActionDecisionPanel.Close(ctx);
|
||||
|
||||
// Панель UI здесь
|
||||
await _battleActionDecisionPanel.Close(ctx);
|
||||
|
||||
decision = await BattleActions[decidedAction].DecideAction();
|
||||
|
||||
Reference in new issue
Block a user