public async Task Start(SMHandoff smh, IUIManager?ui, IReadOnlyList <Enemy> subbosses) { var bgo = DependencyInjection.MaybeFind <IBackgroundOrchestrator>(); var photoBoard = DependencyInjection.MaybeFind <IAyaPhotoBoard>(); PreparePhase(ui, smh, out Task cutins, bgo, photoBoard); var lenienceToken = props.Lenient ? GameManagement.Instance.Lenience.CreateToken1(MultiOp.Priority.CLEAR_PHASE) : null; if (props.rootMove != null) { await props.rootMove.Start(smh); } await cutins; smh.ThrowIfCancelled(); if (props.phaseType?.IsPattern() == true) { ETime.Timer.PhaseTimer.Restart(); } var joint_smh = smh.CreateJointCancellee(out var pcTS); PrepareTimeout(ui, subbosses, joint_smh, pcTS); //The start snapshot is taken after the root movement, // so meter can be used during the 1+2 seconds between cards var start_campaign = new CampaignSnapshot(GameManagement.Instance); if (props.phaseType != null) { DependencyInjection.MaybeFind <IChallengeManager>()?.SetupBossPhase(joint_smh); } try { await base.Start(joint_smh); await WaitingUtils.WaitForUnchecked(joint_smh.Exec, joint_smh.cT, 0f, true); //Wait for synchronization before returning to parent joint_smh.ThrowIfCancelled(); } catch (OperationCanceledException) { if (smh.Exec.PhaseShifter == pcTS) { smh.Exec.PhaseShifter = null; } //This is critical to avoid boss destruction during the two-frame phase buffer if (smh.Exec.isEnemy) { smh.Exec.Enemy.SetVulnerable(Vulnerability.NO_DAMAGE); } lenienceToken?.TryRevoke(); if (props.Cleanup) { GameManagement.ClearPhaseAutocull(props.SoftcullProps(smh.Exec)); } if (smh.Exec.AllowFinishCalls) { //TODO why does this use parentCT? finishPhase?.Trigger(smh.Exec, smh.GCX, smh.parentCT); await OnFinish(smh, pcTS, start_campaign, bgo, photoBoard); } if (smh.Cancelled) { throw; } if (props.phaseType != null) { Log.Unity($"Cleared {props.phaseType.Value} phase: {props.cardTitle?.ValueOrEn ?? ""}"); } if (endPhase != null) { await endPhase.Start(smh); } } }