TimelineImprovements
This commit is contained in:
1 parent
e312131725
commit
f927552adc
2211 files changed
+115416
-540944
No files matched your search
@@ -15,10 +15,10 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
};
|
||||
}
|
||||
|
||||
public override void UnmountDecider()
|
||||
{ }
|
||||
public override UniTask UnmountDecider()
|
||||
{ return UniTask.CompletedTask; }
|
||||
|
||||
public override void MountDecider(EntityProperties entityProperties)
|
||||
{ }
|
||||
public override UniTask MountDecider(EntityProperties entityProperties)
|
||||
{ return UniTask.CompletedTask; }
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
protected bool IsMounted;
|
||||
public abstract UniTask<BattleActionDecisionResult> GetDecision();
|
||||
|
||||
public abstract void UnmountDecider();
|
||||
public abstract UniTask UnmountDecider();
|
||||
|
||||
public abstract void MountDecider(EntityProperties entityProperties);
|
||||
public abstract UniTask MountDecider(EntityProperties entityProperties);
|
||||
}
|
||||
}
|
||||
@@ -63,15 +63,15 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
ResultCode = deciderResult.ResultCode;
|
||||
}
|
||||
}
|
||||
public class FrameBattleActionDeciderResult : BattleActionDecisionResult
|
||||
public class CountBattleActionDeciderResult : BattleActionDecisionResult
|
||||
{
|
||||
public int FrameCount;
|
||||
public int Count;
|
||||
|
||||
public override BattleActionDecisionResult GetSnapshot()
|
||||
{
|
||||
var snapshot = new FrameBattleActionDeciderResult
|
||||
var snapshot = new CountBattleActionDeciderResult
|
||||
{
|
||||
FrameCount = FrameCount,
|
||||
Count = Count,
|
||||
ActionType = ActionType,
|
||||
ResultCode = ResultCode
|
||||
};
|
||||
@@ -80,11 +80,11 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
public override void RestoreSnapshot(BattleActionDecisionResult snapshot)
|
||||
{
|
||||
if (snapshot is not FrameBattleActionDeciderResult) return;
|
||||
if (snapshot is not CountBattleActionDeciderResult) return;
|
||||
|
||||
var deciderResult = (FrameBattleActionDeciderResult)snapshot;
|
||||
var deciderResult = (CountBattleActionDeciderResult)snapshot;
|
||||
|
||||
FrameCount = deciderResult.FrameCount;
|
||||
Count = deciderResult.Count;
|
||||
ActionType = deciderResult.ActionType;
|
||||
ResultCode = deciderResult.ResultCode;
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
};
|
||||
}
|
||||
|
||||
public override void UnmountDecider()
|
||||
public override UniTask UnmountDecider()
|
||||
{
|
||||
if (!IsMounted) return;
|
||||
if (!IsMounted) return UniTask.CompletedTask;
|
||||
|
||||
_playerDecisionMarker.Toggle(false);
|
||||
_markerManager.ReleaseMarkerInstance(_playerDecisionMarker);
|
||||
@@ -79,6 +79,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
MarkPosition);
|
||||
|
||||
IsMounted = false;
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private bool _rotationChanging = false;
|
||||
@@ -91,9 +93,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
_rotationChanging = false;
|
||||
}
|
||||
|
||||
public override void MountDecider(EntityProperties entityProperties)
|
||||
public override UniTask MountDecider(EntityProperties entityProperties)
|
||||
{
|
||||
if (IsMounted) return;
|
||||
if (IsMounted) return UniTask.CompletedTask;
|
||||
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.RightClick,
|
||||
ActivateRotationChange);
|
||||
@@ -115,6 +117,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
_targetRotation = Quaternion.identity;
|
||||
|
||||
IsMounted = true;
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private MarkerManager _markerManager;
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.OfficeGame.BattleMode.Actions.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using R3;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
{
|
||||
public class CountBattleActionDecider : BattleActionDecider
|
||||
{
|
||||
private WaitActionCountSelectorPanel _countSelectorPanel;
|
||||
public override DeciderType DeciderType => DeciderType.Count;
|
||||
|
||||
private int _decidedCount;
|
||||
private BattleActionDecisionResultCode _resultCode;
|
||||
private CancellationTokenSource _waitForEnterTokenSource = new();
|
||||
|
||||
private IDisposable _sliderDisposable;
|
||||
private IInputService _inputService;
|
||||
|
||||
public CountBattleActionDecider(WaitActionCountSelectorPanel countSelectorPanel, IInputService inputService)
|
||||
{
|
||||
_inputService = inputService;
|
||||
_countSelectorPanel = countSelectorPanel;
|
||||
}
|
||||
|
||||
public override async UniTask<BattleActionDecisionResult> GetDecision()
|
||||
{
|
||||
if (!IsMounted) throw new Exception("Decider is not mounted");
|
||||
|
||||
_waitForEnterTokenSource = new CancellationTokenSource();
|
||||
_resultCode = BattleActionDecisionResultCode.Deciding;
|
||||
_countSelectorPanel.CountSlider.enabled = true;
|
||||
|
||||
await UniTask.WaitUntilCanceled(_waitForEnterTokenSource.Token).SuppressCancellationThrow();
|
||||
|
||||
_countSelectorPanel.CountSlider.enabled = false;
|
||||
|
||||
_waitForEnterTokenSource.Dispose();
|
||||
_waitForEnterTokenSource = null;
|
||||
|
||||
return new CountBattleActionDeciderResult()
|
||||
{
|
||||
Count = _decidedCount,
|
||||
ResultCode = _resultCode
|
||||
};
|
||||
}
|
||||
|
||||
private void Cancel(InputAction.CallbackContext obj)
|
||||
{
|
||||
_resultCode = BattleActionDecisionResultCode.CancelDecision;
|
||||
|
||||
_waitForEnterTokenSource.Cancel();
|
||||
}
|
||||
|
||||
private void Confirm(InputAction.CallbackContext obj)
|
||||
{
|
||||
_resultCode = BattleActionDecisionResultCode.Decided;
|
||||
|
||||
_waitForEnterTokenSource.Cancel();
|
||||
}
|
||||
|
||||
public override async UniTask UnmountDecider()
|
||||
{
|
||||
if (!IsMounted) return;
|
||||
|
||||
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
|
||||
Confirm);
|
||||
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
|
||||
Cancel);
|
||||
|
||||
_sliderDisposable.Dispose();
|
||||
|
||||
await _countSelectorPanel.Close();
|
||||
|
||||
IsMounted = false;
|
||||
}
|
||||
|
||||
public override async UniTask MountDecider(EntityProperties entityProperties)
|
||||
{
|
||||
if (IsMounted) return;
|
||||
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
|
||||
Confirm);
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
|
||||
Cancel);
|
||||
|
||||
_decidedCount = 0;
|
||||
|
||||
await _countSelectorPanel.Open();
|
||||
|
||||
_countSelectorPanel.SetRange(1, 150);
|
||||
|
||||
_sliderDisposable = _countSelectorPanel.CountSlider.OnValueChangedAsObservable()
|
||||
.Subscribe(val =>
|
||||
{
|
||||
// if (_suppressSliderCallback) return;
|
||||
_decidedCount = (int)val;
|
||||
_waitForEnterTokenSource.Cancel();
|
||||
});
|
||||
|
||||
IsMounted = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a6bb15289ef4ab1a8e2b62e883b988b
|
||||
timeCreated: 1795128743
|
||||
@@ -4,6 +4,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
{
|
||||
AsIs,
|
||||
Position,
|
||||
Rotation
|
||||
Rotation,
|
||||
Count
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
};
|
||||
}
|
||||
|
||||
public override void UnmountDecider()
|
||||
public override UniTask UnmountDecider()
|
||||
{
|
||||
if (!IsMounted) return;
|
||||
if (!IsMounted) return UniTask.CompletedTask;
|
||||
|
||||
_playerDecisionMarker.Toggle(false);
|
||||
_markerManager.ReleaseMarkerInstance(_playerDecisionMarker);
|
||||
@@ -76,11 +76,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
MarkPosition);
|
||||
|
||||
IsMounted = false;
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override void MountDecider(EntityProperties entityProperties)
|
||||
public override UniTask MountDecider(EntityProperties entityProperties)
|
||||
{
|
||||
if (IsMounted) return;
|
||||
if (IsMounted) return UniTask.CompletedTask;
|
||||
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Select,
|
||||
SelectRotation);
|
||||
@@ -101,6 +103,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
_entityPosition = entityProperties.KinematicCharacterMotor.TransientPosition;
|
||||
|
||||
IsMounted = true;
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private MarkerManager _markerManager;
|
||||
|
||||
Reference in new issue
Block a user