Snapshots. Better actions
This commit is contained in:
1 parent
71bb4c3b5b
commit
31850e77bc
73 files changed
+31948
-80048
No files matched your search
@@ -6,17 +6,84 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public BattleActionType ActionType;
|
||||
public BattleActionDecisionResultCode ResultCode;
|
||||
|
||||
public abstract BattleActionDecisionResult GetSnapshot();
|
||||
public abstract void RestoreSnapshot(BattleActionDecisionResult snapshot);
|
||||
}
|
||||
|
||||
public class PositionBattleActionDeciderResult : BattleActionDecisionResult
|
||||
{
|
||||
public Vector3 Position;
|
||||
public Quaternion Rotation;
|
||||
|
||||
public override BattleActionDecisionResult GetSnapshot()
|
||||
{
|
||||
var snapshot = new PositionBattleActionDeciderResult
|
||||
{
|
||||
Position = Position,
|
||||
Rotation = Rotation,
|
||||
ActionType = ActionType,
|
||||
ResultCode = ResultCode
|
||||
};
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public override void RestoreSnapshot(BattleActionDecisionResult snapshot)
|
||||
{
|
||||
if (snapshot is not PositionBattleActionDeciderResult) return;
|
||||
|
||||
var deciderResult = (PositionBattleActionDeciderResult)snapshot;
|
||||
|
||||
Position = deciderResult.Position;
|
||||
Rotation = deciderResult.Rotation;
|
||||
ActionType = deciderResult.ActionType;
|
||||
ResultCode = deciderResult.ResultCode;
|
||||
}
|
||||
}
|
||||
|
||||
public class FrameBattleActionDeciderResult : BattleActionDecisionResult
|
||||
{
|
||||
public int FrameCount;
|
||||
|
||||
public override BattleActionDecisionResult GetSnapshot()
|
||||
{
|
||||
var snapshot = new FrameBattleActionDeciderResult
|
||||
{
|
||||
FrameCount = FrameCount,
|
||||
ActionType = ActionType,
|
||||
ResultCode = ResultCode
|
||||
};
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public override void RestoreSnapshot(BattleActionDecisionResult snapshot)
|
||||
{
|
||||
if (snapshot is not FrameBattleActionDeciderResult) return;
|
||||
|
||||
var deciderResult = (FrameBattleActionDeciderResult)snapshot;
|
||||
|
||||
FrameCount = deciderResult.FrameCount;
|
||||
ActionType = deciderResult.ActionType;
|
||||
ResultCode = deciderResult.ResultCode;
|
||||
}
|
||||
}
|
||||
|
||||
public class AsIsBattleActionDeciderResult : BattleActionDecisionResult
|
||||
{
|
||||
public override BattleActionDecisionResult GetSnapshot()
|
||||
{
|
||||
var snapshot = new AsIsBattleActionDeciderResult();
|
||||
|
||||
snapshot.ActionType = ActionType;
|
||||
snapshot.ResultCode = ResultCode;
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
public override void RestoreSnapshot(BattleActionDecisionResult snapshot)
|
||||
{
|
||||
ActionType = snapshot.ActionType;
|
||||
ResultCode = snapshot.ResultCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
if (!IsMounted) throw new Exception("Decider is not mounted"); // А почему бы и нет?
|
||||
|
||||
_waitForEnterTokenSource = new CancellationTokenSource();
|
||||
_decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
|
||||
_decisionResultCode = BattleActionDecisionResultCode.Deciding;
|
||||
|
||||
await UniTask.WaitUntilCanceled(_waitForEnterTokenSource.Token).SuppressCancellationThrow();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
return new PositionBattleActionDeciderResult()
|
||||
{
|
||||
ResultCode = _decisionResultCode,
|
||||
Position = _targetPosition,
|
||||
Position = _targetPosition
|
||||
};
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
|
||||
_playerLockedDecisionMarker.MoveMarker(_targetPosition);
|
||||
_playerLockedDecisionMarker.Toggle(true);
|
||||
|
||||
_waitForEnterTokenSource?.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user