Skip to content

Commit 69f21e1

Browse files
committed
SuressCancellationThrow
1 parent 82bffba commit 69f21e1

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

Runtime/AsyncStateMachine.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Cysharp.Threading.Tasks.Linq;
66
using UnityEngine;
77

8-
namespace LD.AI.AsyncFSM
8+
namespace LD.StateMachine
99
{
1010
[Serializable]
1111
public class AsyncStateMachine<TStateKey> : IDisposable
@@ -261,18 +261,19 @@ async UniTask LogicAsync()
261261

262262
async UniTask UpdateTransitionAsync()
263263
{
264-
if (Transitions == null) return;
264+
if (Transitions == null) return;
265265
if (this.Transitions.ContainsKey(this.CurState.Value))
266-
{
266+
{
267267
var link = this.Transitions[CurState.Value];
268268
for (var index = 0; index < link.Callbacks.Count; index++)
269269
{
270270
var callback = link.Callbacks[index];
271271
var shouldTransition = await callback.ShouldTransition();
272272
if (shouldTransition)
273273
{
274-
await UniTask.WaitUntil(() => currentTask == null);
275-
// 현재는 트랜지션이 가능한 상태더라도 현재 state의 task가 종료 되어야만 호출 됨.
274+
275+
await UniTask.WaitUntil(() => { return currentTask == null; });
276+
// 현재는 트랜지션이 가능한 상태더라도 현재 state의 task가 종료 되어야만 호출 됨.
276277
await ChangeStateAsync(link.To);
277278
}
278279
}
@@ -296,18 +297,17 @@ private async UniTask UpdateState()
296297
private async UniTaskVoid StartUpdateLoopAsync(CancellationToken token)
297298
{
298299
await foreach (var _ in UniTaskAsyncEnumerable.EveryUpdate().WithCancellation(token))
299-
{
300-
300+
{
301301
if (_monoBehaviourObject != null)
302302
{
303303
if (_monoBehaviourObject.gameObject.activeSelf && _monoBehaviourObject.enabled)
304304
{
305-
await LogicAsync();
305+
await LogicAsync().SuppressCancellationThrow();
306306
}
307307
}
308308
else
309-
{
310-
await LogicAsync();
309+
{
310+
await LogicAsync().SuppressCancellationThrow();
311311
}
312312
}
313313
}

Runtime/IState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Cysharp.Threading.Tasks;
22

3-
namespace LD.AI.AsyncFSM
3+
namespace LD.StateMachine
44
{
55
/// <summary>
66
/// 상태 인터페이스

Runtime/IStateMachine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Cysharp.Threading.Tasks;
22

3-
namespace LD.AI.AsyncFSM
3+
namespace LD.StateMachine
44
{
55
public interface IStateMachine
66
{

Runtime/ITransition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Cysharp.Threading.Tasks;
22

3-
namespace LD.AI.AsyncFSM
3+
namespace LD.StateMachine
44
{
55
public interface ITransition
66
{

Runtime/StateBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Cysharp.Threading.Tasks;
22
using UnityEngine;
33

4-
namespace LD.AI.AsyncFSM
4+
namespace LD.StateMachine
55
{
66
public abstract class StateBase<TStateKey> : IState where TStateKey : struct
77
{

Runtime/TransitionFunctor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using Cysharp.Threading.Tasks;
33

4-
namespace LD.AI.AsyncFSM
4+
namespace LD.StateMachine
55
{
66
/// <summary>
77
/// ITransition의 콜백 클래스 구현

Tests/AsyncFSMPerformance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using Cysharp.Threading.Tasks;
5-
using LD.AI.AsyncFSM;
5+
using LD.StateMachine;
66
using UnityEngine;
77
using Random = UnityEngine.Random;
88

Tests/AsyncStateMachineTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Threading;
44
using System.Threading.Tasks;
55
using Cysharp.Threading.Tasks;
6-
using LD.AI.AsyncFSM;
6+
using LD.StateMachine;
77
using UnityEngine;
88
using UnityEngine.Assertions;
99
using UnityEngine.TestTools;

0 commit comments

Comments
 (0)