Class TimeSystem
ITimeSystem 구현체. Unity Time API 래핑, 쿨타임, 지연/반복 예약을 통합 제공.
public class TimeSystem : ITimeSystem, ITickable
- Inheritance
-
objectTimeSystem
- Implements
Remarks
DeltaTime은 Pause 상태이면 0, 아니면 Time.deltaTime × TimeScale을 반환한다. Unity의 Time.timeScale은 건드리지 않고 자체 필드로 관리한다. RootScope에 Singleton으로 등록. TickRunner가 이 값을 읽어 TickSystem에 전달하고 타이머를 갱신한다.
Properties
DeltaTime
Pause 상태이면 0, 아니면 Time.deltaTime * TimeScale.
public float DeltaTime { get; }
Property Value
- float
IsPaused
현재 Pause 상태 여부.
public bool IsPaused { get; }
Property Value
- bool
TimeScale
시간 배율. 0 이상 값만 허용. 슬로우모션/패스트포워드에 사용.
public float TimeScale { get; set; }
Property Value
- float
UnscaledDeltaTime
TimeScale·Pause 영향 없는 실제 경과 시간.
public float UnscaledDeltaTime { get; }
Property Value
- float
Methods
Cancel(ScheduleId)
특정 스케줄 취소.
public void Cancel(ScheduleId id)
Parameters
idScheduleId취소할 스케줄 ID.
CancelAll()
모든 스케줄 취소.
public void CancelAll()
Delay(float, Action, CancellationToken)
지정 시간 후 1회 실행.
public ScheduleId Delay(float time, Action action, CancellationToken ct = default)
Parameters
timefloat지연 시간(초).
actionAction실행할 액션.
ctCancellationToken취소 신호.
Returns
- ScheduleId
취소에 사용할 ScheduleId.
IsTimerReady(string)
해당 타이머가 준비 완료(경과 >= duration) 여부.
public bool IsTimerReady(string id)
Parameters
idstring조회 키. 미등록 시 true 반환.
Returns
- bool
Pause()
시간 흐름 정지. DeltaTime이 0을 반환.
public void Pause()
RegisterTimer(string, float)
쿨타임 등록. 이미 존재하는 id는 덮어쓴다.
public void RegisterTimer(string id, float duration)
Parameters
idstring타이머 식별 키.
durationfloat쿨타임 지속 시간(초).
Repeat(float, Action, CancellationToken)
지정 간격으로 반복 실행. ct 취소 또는 Cancel 호출 시 중단.
public ScheduleId Repeat(float interval, Action action, CancellationToken ct = default)
Parameters
intervalfloat반복 간격(초).
actionAction반복 실행할 액션.
ctCancellationToken취소 신호.
Returns
- ScheduleId
취소에 사용할 ScheduleId.
ResetTimer(string)
해당 타이머 경과 시간을 초기화.
public void ResetTimer(string id)
Parameters
idstring리셋할 타이머 키.
Resume()
시간 흐름 재개.
public void Resume()
Tick(float)
Tick 처리. dt = ITimeSystem.DeltaTime 값.
public void Tick(float dt)
Parameters
dtfloat
UnregisterTimer(string)
타이머 등록 해제.
public void UnregisterTimer(string id)
Parameters
idstring해제할 타이머 키.