refactor(core): 코어 엔진 및 모델 개선
- 애니메이션 시스템 개선 - 오디오 서비스 개선 - 전투/스킬/포션 서비스 개선 - 스토리지 및 저장 시스템 개선 - 모델 클래스 타입 안정성 강화
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:askiineverdie/src/core/model/game_state.dart';
|
||||
import 'package:askiineverdie/src/core/storage/save_manager.dart';
|
||||
import 'package:askiineverdie/src/core/engine/progress_service.dart';
|
||||
import 'package:asciineverdie/src/core/model/game_state.dart';
|
||||
import 'package:asciineverdie/src/core/storage/save_manager.dart';
|
||||
import 'package:asciineverdie/src/core/engine/progress_service.dart';
|
||||
|
||||
class AutoSaveConfig {
|
||||
const AutoSaveConfig({
|
||||
@@ -40,11 +40,13 @@ class ProgressLoop {
|
||||
DateTime Function()? now,
|
||||
this.cheatsEnabled = false,
|
||||
this.onPlayerDied,
|
||||
List<int> availableSpeeds = const [1, 5],
|
||||
}) : _state = initialState,
|
||||
_tickInterval = tickInterval,
|
||||
_autoSaveConfig = autoSaveConfig,
|
||||
_now = now ?? DateTime.now,
|
||||
_stateController = StreamController<GameState>.broadcast();
|
||||
_stateController = StreamController<GameState>.broadcast(),
|
||||
_availableSpeeds = availableSpeeds.isNotEmpty ? availableSpeeds : [1];
|
||||
|
||||
final ProgressService progressService;
|
||||
final SaveManager? saveManager;
|
||||
@@ -60,21 +62,35 @@ class ProgressLoop {
|
||||
Timer? _timer;
|
||||
int? _lastTickMs;
|
||||
int _speedMultiplier = 1;
|
||||
List<int> _availableSpeeds;
|
||||
|
||||
GameState get current => _state;
|
||||
Stream<GameState> get stream => _stateController.stream;
|
||||
GameState _state;
|
||||
|
||||
/// 현재 배속 (1x, 3x, 10x)
|
||||
/// 가용 배속 목록
|
||||
List<int> get availableSpeeds => List.unmodifiable(_availableSpeeds);
|
||||
|
||||
/// 현재 배속 (1x, 2x, 5x)
|
||||
int get speedMultiplier => _speedMultiplier;
|
||||
|
||||
/// 배속 순환: 1 -> 3 -> 10 -> 1
|
||||
/// 배속 순환: 가용 배속 목록 순환
|
||||
/// 명예의 전당에 캐릭터 없으면: 1 -> 5 -> 1
|
||||
/// 명예의 전당에 캐릭터 있으면: 1 -> 2 -> 5 -> 1
|
||||
void cycleSpeed() {
|
||||
_speedMultiplier = switch (_speedMultiplier) {
|
||||
1 => 3,
|
||||
3 => 10,
|
||||
_ => 1,
|
||||
};
|
||||
final currentIndex = _availableSpeeds.indexOf(_speedMultiplier);
|
||||
final nextIndex = (currentIndex + 1) % _availableSpeeds.length;
|
||||
_speedMultiplier = _availableSpeeds[nextIndex];
|
||||
}
|
||||
|
||||
/// 가용 배속 목록 업데이트 (명예의 전당 상태 변경 시)
|
||||
void updateAvailableSpeeds(List<int> speeds) {
|
||||
if (speeds.isEmpty) return;
|
||||
_availableSpeeds = speeds;
|
||||
// 현재 배속이 새 목록에 없으면 첫 번째로 리셋
|
||||
if (!_availableSpeeds.contains(_speedMultiplier)) {
|
||||
_speedMultiplier = _availableSpeeds.first;
|
||||
}
|
||||
}
|
||||
|
||||
void start() {
|
||||
|
||||
Reference in New Issue
Block a user