载入中...
搜索中...
未找到
PcgSpawnProgress.cpp
浏览该文件的文档.
6Result<PcgSpawnProgressStatus> PcgSpawnProgress::updateRule(std::string name,int total,int done,int localTotal,int localDone) {
9 DiagnosticCode::InvalidArgument,"valid rule counts and a nonempty spawner name are required",{}, {},"procgen.pcgSpawnProgress"));
10 title_="Spawning"; subtitle_=std::move(name)+" "+std::to_string(localDone)+" of "+std::to_string(localTotal)+" Rules";
11 totalRuleCount_=total; totalRulesCompleted_=done; spawnerRuleCount_=localTotal; spawnerRulesCompleted_=localDone;
12 ruleProgress_=0; status_=done==total?PcgSpawnProgressStatus::Completed:PcgSpawnProgressStatus::Active;
18 DiagnosticCode::InvalidArgument,"active progress and a finite fraction in [0,1] are required",{}, {},"procgen.pcgSpawnProgress"));
22 if(status_!=PcgSpawnProgressStatus::Active) return Result<PcgSpawnProgressStatus>::failure(Diagnostic::error(
23 DiagnosticCode::InvalidArgument,"only active spawning can be cancelled",{}, {},"procgen.pcgSpawnProgress"));
24 status_=PcgSpawnProgressStatus::CancelRequested; return Result<PcgSpawnProgressStatus>::success(status_);
26PcgSpawnProgressStatus PcgSpawnProgress::clear() noexcept { title_.clear(); subtitle_.clear(); totalRuleCount_=totalRulesCompleted_=spawnerRuleCount_=spawnerRulesCompleted_=0; ruleProgress_=0; return status_=PcgSpawnProgressStatus::Hidden; }
27double PcgSpawnProgress::progress() const noexcept { return totalRuleCount_<=0?0:std::clamp((double(totalRulesCompleted_)+ruleProgress_)/double(totalRuleCount_),0.0,1.0); }
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Result< PcgSpawnProgressStatus > requestCancel()
Mark cancellation requested while retaining the snapshot.
Definition PcgSpawnProgress.cpp:21
Result< PcgSpawnProgressStatus > updateRuleFraction(double progress)
Update the current rule fraction in [0,1].
Definition PcgSpawnProgress.cpp:15
Result< PcgSpawnProgressStatus > updateRule(std::string spawnerName, int totalRuleCount, int totalRulesCompleted, int spawnerRuleCount, int spawnerRulesCompleted)
Start or advance a spawner rule and reset its fractional progress.
Definition PcgSpawnProgress.cpp:6
double progress() const noexcept
Return Pcg's inverse-lerp total progress.
Definition PcgSpawnProgress.cpp:27
Definition EvpackPointGraphLoader.h:12
PcgSpawnProgressStatus
Observable lifecycle of a Pcg spawning progress operation.
Definition PcgSpawnProgress.h:6
@ CancelRequested
@ InvalidArgument