public bool OnSuccess(ChallengeManager.TrackingContext ctx) { Log.Unity($"PASSED challenge {cr.Description}"); //This saves completion. Needs to be done locally in case of continuations. //The callback will handle replaying. var record = Requester.MakeGameRecord(ctx.cm.ChallengePhotos.ToArray()); Requester.TrySave(record); if (Requester.replay == null && cr.NextChallenge(Requester.metadata).Try(out var nextC)) { Log.Unity($"Autoproceeding to next challenge: {nextC.Description}"); var nextGr = new InstanceRequest(Requester.cb, Requester.metadata, new InstanceLowRequest(nextC), null); nextGr.SetupInstance(); Replayer.Cancel(); //can't replay both scenes together, //or even just the second scene due to time-dependency of world objects such as shots ctx.cm.TrackChallenge(new SceneChallengeReqest(nextGr, nextC), ctx.onSuccess); ctx.cm.LinkBoss(ctx.exec); return(false); } else { UIManager.MessageChallengeEnd(true, out _); //The callback should have a wait procedure in it ctx.onSuccess(record); //WaitingUtils.WaitThenCB(ctx.cm, Cancellable.Null, t, false, () => ctx.onSuccess(record)); return(true); } }
public void OnFail(ChallengeManager.TrackingContext ctx) { Log.Unity($"FAILED challenge {cr.Description}"); UIManager.MessageChallengeEnd(false, out float t); if (ctx.exec != null) { ctx.exec.ShiftPhase(); } WaitingUtils.WaitThenCB(ctx.cm, Cancellable.Null, t, false, () => { BulletManager.PlayerTarget.Player.Hit(999, true); }); }