Example #1
0
    private static IEnumerator TestEveryS_E()
    {
        long last = 0;

        for (int k = 0; k < 20; k++)
        {
            Iter.EverySeconds(ref last, 3, TestEveryS_C);
            yield return(new WaitForSeconds(1));
        }
    }
Example #2
0
        public override IEnumerator _Next(EntityPlayer player)
        {
            Vector3 ppos = player.GetPosition();

            // if (entities.Count == 0) {
            //     Printer.Print("AtEntities empty at ", bounds, player);
            //     yield break;
            // }
            foreach (int p in Repeater.Over())
            {
                Bounds bounds = BoundToPosition(ppos, Placer.Bounds(ppos));
                Iter.EverySeconds(ref last_entities_update, updateEvery, this.UpdateEntities, bounds);

                // Printer.Print("AtEntities_Next Over");
                // for (int draw=0; draw< Repeater.n; draw++) {
                // Downscale only if all entities can't be treated at once. Don't upscale above.
                int nUpdates = Math.Min(entities.Count, (int)Math.Ceiling(rate * entities.Count));
                for (int draw = 0; draw < nUpdates; draw++)
                {
                    // EntityAlive target = entities[this.NextIndex()] as EntityAlive;
                    // Printer.Print("AtEntities_Next Clones", draw, target); // last before null (firestorm)
                    EntityAlive target = SdtdUtils.Cycling.Next(entities, ref _indexEnt) as EntityAlive;
                    if (target != null)
                    {
                        OptionEffect rdm = Randomize();
                        Printer.Log(40, "AtEntities_Next Randomized", draw, target, opt);
                        yield return(this.Apply(player, target, rdm));
                    }
                    else
                    {
                        Printer.Log(40, "AtEntities_Next null Entity", draw);
                    }
                    yield return(Repeater.Yield);
                }
                yield return(Cycler.Yield); // a single cycle
            }
        }