예제 #1
0
 public BulletControl(SBCF act, Pred persistent, int priority, ICancellee cT)
 {
     action        = act;
     persist       = persistent;
     this.priority = priority;
     this.cT       = cT;
 }
예제 #2
0
        public RealizedPowerAuraOptions(PowerAuraOptions opts, GenCtx gcx, Vector2 unparentedOffset, ICancellee cT, Func <RealizedPowerAuraOptions, Action> next)
        {
            scale      = opts.scale?.Invoke(gcx);
            color      = opts.color;
            time       = opts.time?.Invoke(gcx) ?? 1f;
            iterations = opts.itrs?.Invoke(gcx) ?? 1f;
            sfx        = opts.sfx;
            layer      = opts.layer;
            this.cT    = cT;

            if (opts.static_)
            {
                parent = null;
                offset = unparentedOffset;
            }
            else
            {
                parent = gcx.exec;
                offset = Vector2.zero;
            }

            if (opts.next != null)
            {
                //Note that you must operate over GCX now, since it may be destroyed after this function is exited.
                continuation = next(new RealizedPowerAuraOptions(opts.next, gcx, unparentedOffset, cT, next));
            }
            else
            {
                continuation = null;
            }
        }
예제 #3
0
 public static void ThrowIfCancelled(this ICancellee c)
 {
     if (c.Cancelled)
     {
         throw new OperationCanceledException();
     }
 }
예제 #4
0
        private IEnumerator IShake(float time, FXY magnitude, float magMul, ICancellee cT, Action?done)
        {
            Vector3 pp = tr.localPosition; // Should be (0, 0, ?)

            for (float elapsed = 0; elapsed < time;)
            {
                float   m     = magnitude(elapsed) * magMul * ScreenshakeMultiplier * SaveData.s.Screenshake;
                float   deg   = RNG.GetFloatOffFrame(0, 360);
                Vector2 quake = M.PolarToXY(m, deg);
                tr.localPosition = pp + (Vector3)quake;
                yield return(null);

                if (cT.Cancelled)
                {
                    break;
                }
                elapsed += ETime.FRAME_TIME;
                yield return(null);

                if (cT.Cancelled)
                {
                    break;
                }
                elapsed += ETime.FRAME_TIME;
            }
            //Future: If you want to move the camera, do so by moving the Camera Container object.
            tr.localPosition = pp;
            done?.Invoke();
        }
예제 #5
0
 public BEHControl(BehCF act, Pred persistent, int priorty, ICancellee cT)
 {
     action   = act;
     persist  = persistent;
     priority = priorty;
     this.cT  = cT;
 }
예제 #6
0
        private IEnumerator DoRadialize(ICancellee cT)
        {
            float t   = 0;
            var   lit = time * lerpInTimeRatio;

            for (; t < time * lerpInTimeRatio; t += ETime.FRAME_TIME)
            {
                pb.SetFloat(PropConsts.fillRatio, M.SinDeg(90 * t / lit));
                sr.SetPropertyBlock(pb);
                if (cT.Cancelled)
                {
                    break;
                }
                yield return(null);
            }
            for (; t < time; t += ETime.FRAME_TIME)
            {
                pb.SetFloat(PropConsts.fillRatio, 1 - (t - lit) / (time * (1 - endEarlyRatio) - lit));
                sr.SetPropertyBlock(pb);
                if (cT.Cancelled)
                {
                    break;
                }
                yield return(null);
            }
            if (destroyOnDone)
            {
                Destroy(gameObject);
            }
        }
예제 #7
0
 public override void Initialize(ICancellee cT, float total)
 {
     time1    = time1Ratio * total;
     time2    = time2Ratio * total;
     holdtime = total - time1 - time2;
     //Share(ref time1, out holdtime, ref time2, total);
     RunDroppableRIEnumerator(DoScale(cT));
 }
예제 #8
0
 /// <summary>
 /// Returns when the condition is true
 /// </summary>
 private static IEnumerator WaitFor(Func <bool> condition, ICancellee cT, Action done)
 {
     while (!condition() && !cT.Cancelled)
     {
         yield return(null);
     }
     done();
 }
예제 #9
0
 private static IEnumerator NestLoC(ICancellee cT)
 {
     if (cT.Cancelled)
     {
         yield break;
     }
     yield return(LeaveOnCancel(cT));
 }
예제 #10
0
 public override void Initialize(ICancellee cT, float total)
 {
     time  = total;
     time1 = time * time1Ratio;
     time2 = time * time2Ratio;
     RunDroppableRIEnumerator(DoRadialize(cT));
     RunDroppableRIEnumerator(DoScale(cT));
 }
예제 #11
0
파일: Metadata.cs 프로젝트: Bagoum/danmokou
 public SMRunner(StateMachine?sm, ICancellee cT, bool cullOnFinish, bool root, GenCtx?gcx)
 {
     this.sm           = sm;
     this.cT           = cT;
     this.cullOnFinish = cullOnFinish;
     this.gcx          = gcx;
     this.root         = root;
 }
예제 #12
0
 public BottomTracker Initialize(BehaviorEntity beh, string sname, ICancellee canceller)
 {
     source = beh;
     source.TryAsEnemy(out enemy);
     text.text = sname;
     cT        = canceller;
     return(this);
 }
예제 #13
0
 /// <summary>
 /// This must be run on RegularCoroutine.
 /// Inner waiter-- Will cb if cancelled. This is necessary so awaiters can be informed of errors,
 /// specifically the task-style waiter, which would otherwise spin infinitely.
 /// </summary>
 public static IEnumerator WaitFor(float wait_time, ICancellee cT, Action done)
 {
     for (; wait_time > ETime.FRAME_YIELD && !cT.Cancelled;
          wait_time -= ETime.FRAME_TIME)
     {
         yield return(null);
     }
     done();
 }
예제 #14
0
파일: Movement.cs 프로젝트: Bagoum/danmokou
 public LimitedTimeMovement(VTP path, float enabledFor, Action done, ICancellee cT, ParametricInfo pi, Pred?condition = null)
 {
     this.vtp        = path;
     this.enabledFor = enabledFor;
     this.done       = done;
     this.cT         = cT;
     this.pi         = pi;
     this.condition  = condition;
 }
예제 #15
0
        public override void FadeSpriteOpacity(BPY fader01, float over, ICancellee cT, Action done)
        {
            Color c    = sprite.color;
            var   tbpi = ParametricInfo.WithRandomId(beh.rBPI.loc, beh.rBPI.index);

            c.a          = fader01(tbpi);
            sprite.color = c;
            beh.RunRIEnumerator(_FadeSpriteOpacity(fader01, tbpi, over, cT, done));
        }
예제 #16
0
 /// <summary>
 /// Outer waiter-- Will cb if cancelled
 /// </summary>
 public static void WaitThenCBEvenIfCancelled(CoroutineRegularUpdater Exec, ICancellee cT, float time, bool zeroToInfinity,
                                              Action cb)
 {
     cT.ThrowIfCancelled();
     if (zeroToInfinity && time < float.Epsilon)
     {
         time = float.MaxValue;
     }
     Exec.RunRIEnumerator(WaitFor(time, cT, cb));
 }
예제 #17
0
 /// <summary>
 /// Outer waiter-- Will not cb if cancelled
 /// </summary>
 public static void WaitThenCB(CoroutineRegularUpdater Exec, ICancellee cT, float time, Func <bool> condition,
                               Action cb)
 {
     cT.ThrowIfCancelled();
     Exec.RunRIEnumerator(WaitForBoth(time, condition, cT, () => {
         if (!cT.Cancelled)
         {
             cb();
         }
     }));
 }
예제 #18
0
 private static IEnumerator LeaveOnCancel(ICancellee cT)
 {
     while (true)
     {
         if (cT.Cancelled)
         {
             yield break;
         }
         yield return(null);
     }
 }
예제 #19
0
 /// <summary>
 /// Waits for the given amount of time, but can be cancelled early by the cT.
 /// </summary>
 public static IEnumerator WaitFor(float time, Action <Completion> done, ICancellee cT, Func <float> dT)
 {
     for (float elapsed = 0; elapsed < time; elapsed += dT())
     {
         if (cT.Cancelled)
         {
             break;
         }
         yield return(null);
     }
     done(cT.ToCompletion());
 }
예제 #20
0
 public static IEnumerator WaitForDialogueConfirm(ICancellee cT, Action done)
 {
     while (!cT.Cancelled)
     {
         if (InputManager.DialogueConfirm)
         {
             break;
         }
         yield return(null);
     }
     done();
 }
예제 #21
0
 /// <summary>
 /// Waits until the cT is cancelled.
 /// </summary>
 public static IEnumerator Spin(Action <Completion> done, ICancellee cT)
 {
     while (true)
     {
         if (cT.Cancelled)
         {
             break;
         }
         yield return(null);
     }
     done(cT.ToCompletion());
 }
예제 #22
0
 public void DoTimeout(bool withSound, float maxTime, ICancellee cT, float?stayOnZero = null)
 {
     EndTimeout();
     if (maxTime < float.Epsilon)
     {
         timeout.text = "";
     }
     else
     {
         timeoutCor = StartCoroutine(Timeout(maxTime, withSound, stayOnZero ?? 3f, cT));
     }
 }
예제 #23
0
        private async Task OnFinish(SMHandoff smh, ICancellee prepared, CampaignSnapshot start_campaign,
                                    IBackgroundOrchestrator?bgo, IAyaPhotoBoard?photoBoard)
        {
            if (props.BgTransitionOut != null)
            {
                bgo?.QueueTransition(props.BgTransitionOut);
            }
            if (props.BossPhotoHP.Try(out _))
            {
                photoBoard?.TearDown();
            }
            //The shift-phase token is cancelled by timeout or by HP.
            var completedBy = prepared.Cancelled ?
                              (smh.Exec.isEnemy ?
                               (smh.Exec.Enemy.PhotoHP <= 0 && (props.photoHP ?? 0) > 0) ?
                               PhaseClearMethod.PHOTO :
                               (smh.Exec.Enemy.HP <= 0 && (props.hp ?? 0) > 0) ?
                               PhaseClearMethod.HP :
                               (PhaseClearMethod?)null :
                               null) ??
                              PhaseClearMethod.TIMEOUT :
                              PhaseClearMethod.CANCELLED;
            var pc = new PhaseCompletion(props, completedBy, smh.Exec, start_campaign, Timeout);

            if (pc.StandardCardFinish)
            {
                if (props.Boss != null)
                {
                    BulletManager.RequestPowerAura("powerup1", 0, 0, new RealizedPowerAuraOptions(
                                                       new PowerAuraOptions(new[] {
                        PowerAuraOption.Color(_ => ColorHelpers.CV4(props.Boss.colors.powerAuraColor)),
                        PowerAuraOption.Time(_ => 1f),
                        PowerAuraOption.Iterations(_ => - 1f),
                        PowerAuraOption.Scale(_ => 3.5f),
                        PowerAuraOption.Static(),
                        PowerAuraOption.High(),
                    }), GenCtx.Empty, smh.Exec.GlobalPosition(), smh.cT, null !));
                }
                smh.Exec.DropItems(pc.DropItems, 1.4f, 0.6f, 1f, 0.2f, 2f);
                DependencyInjection.MaybeFind <IRaiko>()
                ?.Shake(defaultShakeTime, defaultShakeMult, defaultShakeMag, smh.cT, null);
            }
            GameManagement.Instance.PhaseEnd(pc);
            if (pc.StandardCardFinish && !smh.Cancelled && props.Boss != null && pc.CaptureStars.HasValue)
            {
                Object.Instantiate(GameManagement.References.prefabReferences.phasePerformance)
                .GetComponent <PhasePerformance>().Initialize($"{props.Boss.CasualName} / Boss Card", pc);
                await WaitingUtils.WaitForUnchecked(smh.Exec, smh.cT, EndOfCardDelayTime, false);
            }
        }
예제 #24
0
 /// <summary>
 /// Task style. Will return as soon as the time is up or cancellation is triggered.
 /// You must check cT.IsCancelled after awaiting this.
 /// </summary>
 /// <returns></returns>
 public static Task WaitForUnchecked(CoroutineRegularUpdater Exec, ICancellee cT, float time, bool zeroToInfinity)
 {
     cT.ThrowIfCancelled();
     if (zeroToInfinity && time < float.Epsilon)
     {
         time = float.MaxValue;
     }
     if (time < float.Epsilon)
     {
         return(Task.CompletedTask);
     }
     Exec.RunRIEnumerator(WaitFor(time, cT, GetAwaiter(out Task t)));
     return(t);
 }
예제 #25
0
파일: Endcards.cs 프로젝트: Bagoum/danmokou
        private IEnumerator _FadeOut(float t, ICancellee cT, Action cb)
        {
            for (float elapsed = 0; elapsed < t; elapsed += ETime.FRAME_TIME)
            {
                main.sr.color = Color.Lerp(Color.black, Color.white, 1 - elapsed / t);
                yield return(null);

                if (cT.Cancelled)
                {
                    break;
                }
            }
            main.sr.color = Color.black;
            cb();
        }
예제 #26
0
 /// <summary>
 /// Outer waiter-- Will not cancel if cancelled
 /// </summary>
 public static void WaitThenCancel(CoroutineRegularUpdater Exec, ICancellee cT, float time, bool zeroToInfinity,
                                   Cancellable toCancel)
 {
     cT.ThrowIfCancelled();
     if (zeroToInfinity && time < float.Epsilon)
     {
         time = float.MaxValue;
     }
     Exec.RunRIEnumerator(WaitFor(time, cT, () => {
         if (!cT.Cancelled)
         {
             toCancel.Cancel();
         }
     }));
 }
예제 #27
0
        /// <summary>
        /// Task style-- will throw if cancelled. This checks cT.IsCancelled before returning,
        /// so you do not need to check it after awaiting this.
        /// </summary>
        /// <returns></returns>
        public static async Task WaitFor(BehaviorEntity Exec, ICancellee cT, float time, bool zeroToInfinity)
        {
            cT.ThrowIfCancelled();
            if (zeroToInfinity && time < float.Epsilon)
            {
                time = float.MaxValue;
            }
            if (time < float.Epsilon)
            {
                return;
            }
            Exec.RunRIEnumerator(WaitFor(time, cT, GetAwaiter(out Task t)));
            await t;

            //I do want this throw here, which is why I don't 'return t'
            cT.ThrowIfCancelled();
        }
예제 #28
0
        private IEnumerator DoScale(ICancellee cT)
        {
            AssignScale(startScale);
            FXY e1 = ease1.Into <FXY>();
            FXY e2 = ease2.Into <FXY>();

            for (float t = 0; t < time1; t += ETime.FRAME_TIME)
            {
                if (cT.Cancelled)
                {
                    break;
                }
                yield return(null);

                AssignScale(startScale + (midScale - startScale) * e1(t / time1));
            }
            AssignScale(midScale);
            for (float t = 0; t < holdtime; t += ETime.FRAME_TIME)
            {
                if (cT.Cancelled)
                {
                    break;
                }
                yield return(null);
            }
            for (float t = 0; t < time2; t += ETime.FRAME_TIME)
            {
                if (cT.Cancelled)
                {
                    break;
                }
                yield return(null);

                AssignScale(midScale + (endScale - midScale) * e2(t / time2));
            }
            AssignScale(endScale);
            if (destroyOnDone)
            {
                Destroy(gameObject);
            }
        }
예제 #29
0
        private IEnumerator Timeout(float maxTime, bool withSound, float stayOnZero, ICancellee cT)
        {
            float currTime      = maxTime;
            var   currTimeIdent = -2;

            while (currTime > 0)
            {
                if (Mathf.RoundToInt(currTime * 10) != currTimeIdent)
                {
                    timeout.text  = string.Format(timeoutTextFormat, currTime);
                    currTimeIdent = Mathf.RoundToInt(currTime * 10);
                }
                yield return(null);

                if (cT.Cancelled)
                {
                    break;
                }
                var tryCross = Mathf.FloorToInt(currTime);
                currTime -= ETime.dT;
                if (withSound && currTime < tryCross)
                {
                    if (0 < tryCross && tryCross <= countdownSounds.Length)
                    {
                        SFXService.Request(countdownSounds[tryCross - 1]);
                    }
                }
            }
            if (currTime < 1)
            {
                timeout.text = string.Format(timeoutTextFormat, 0);
            }
            while (stayOnZero > 0f)
            {
                yield return(null);

                stayOnZero -= ETime.dT;
            }
            timeout.text = "";
        }
예제 #30
0
        private static IEnumerator OnePlusTwoFrames(ICancellee cT)
        {
            IEnumerator TwoFrames()
            {
                if (cT.Cancelled)
                {
                    yield break;
                }
                yield return(null);

                if (cT.Cancelled)
                {
                    yield break;
                }
                yield return(null);
            }

            if (cT.Cancelled)
            {
                yield break;
            }
            yield return(TwoFrames());
        }