1
0

finish chicken nugget anime loader

This commit is contained in:
2026-01-09 16:49:06 +08:00
parent 06bfe69c0e
commit ff34754274
3 changed files with 26 additions and 26 deletions

View File

@@ -6,33 +6,26 @@ namespace basalt::shared::anime_loader {
#pragma region Anime Loader
IAnimeLoader::IAnimeLoader() : status(AnimeLoaderStatus::Ready), time(0), last_index(0) {}
IAnimeLoader::IAnimeLoader() : status(AnimeLoaderStatus::Ready), time(0) {}
IAnimeLoader::~IAnimeLoader() {}
void IAnimeLoader::load() {
void IAnimeLoader::load(AnimeLoaderConfig&& config) {
if (this->status != AnimeLoaderStatus::Ready) throw std::runtime_error("unexpected anime loader status");
// load by user
internal_load();
// check empty
if (this->frames.empty()) throw std::runtime_error("no anime key frames.");
// Get last frame index
auto last_pair = this->frames.end();
--last_pair;
this->last_index = last_pair->first;
// change status
this->config = std::move(config);
this->status = AnimeLoaderStatus::Loaded;
}
KeyFrameSpan IAnimeLoader::tick() {
if (this->status != AnimeLoaderStatus::Loaded) throw std::runtime_error("unexpected anime loader status");
// Get last frame index
auto last_pair = this->frames.end();
--last_pair;
auto last_index = last_pair->first;
// Accumulate time
++this->time;
if (this->time > this->last_index) {
if (this->time > last_index) {
this->time = 0;
}
@@ -61,10 +54,6 @@ namespace basalt::shared::anime_loader {
};
}
void IAnimeLoader::internal_load() {
throw std::logic_error("unimplemented function");
}
#pragma endregion
} // namespace basalt::shared::anime_loader