Exemplo n.º 1
0
        public override IEnumerator Regen(EntityPlayer player, Vector3i zchunk, int iniguess)
        {
            Bounds        bounds   = ZChunk.Bounds4(zchunk, iniguess);
            List <Entity> existing = GameManager.Instance.World.GetEntitiesInBounds(
                EntityGhost.Concretes[this.concreteIdx],
                bounds,
                new List <Entity>()
                );

            yield return(Iterating.Repeater.Frame); // listent may be costly

            Vector3i min = Vectors.ToInt(bounds.min);
            Vector3i max = Vectors.ToInt(bounds.max);

            int current = existing.Count;
            int gen     = ZChunk.Size(this.gen);
            // gen = 1; // DEBUG
            int regen = ZChunk.Size(this.regen);
            int iniy  = (int)Math.Floor(player.GetPosition().y);

            Zombiome.Routines.Start(Routines.IfNotRunning(
                                        LockRenew,
                                        EffectExisting(player, existing)
                                        ), "Ghost-Existing");

            int nnew = Math.Min(limit_new, gen - current);

            Entity[] Tracker = new Entity[] { null };
            if (current < regen)
            {
                Printer.Log(45, "Ghost regen", regen, current, gen, "=>", gen - current);
                for (int k = 0; k < nnew; k++)
                {
                    Vector3i pos = new Vector3i(rand.RandomRange(min.x, max.x), 0, rand.RandomRange(min.z, max.z));
                    pos = Geo3D.Surface(pos, iniy);
                    if (GameManager.Instance.World.GetTerrainHeight(pos.x, pos.z) > 2)
                    {
                        Printer.Log(40, "Ghost", pos, opt.OptionEntity.entity, opt.OptionEntity.buff);
                        Emplacement place = Emplacement.At(Vectors.ToFloat(pos) + 2f * Vectors.Float.UnitY, Vectors.Float.UnitY);
                        GhostData   gdata = (ghost_type == "") ? this.GhostData : GhostData.Ghosts[ghost_type];
                        yield return(EntityGhost.Create(gdata, place, opt.OptionEntity.entity));
                    }
                    yield return(Repeater.Yield);
                }
            }
        }
Exemplo n.º 2
0
        public override IEnumerator Regen(EntityPlayer player, Vector3i zchunk, int iniguess)
        {
            yield return(ZBActivity.Environment.ZBSounds.Play(ZBiomeInfo.NoiseWater, player.GetPosition(), player, World, 2, 0, 0.5f));

            int gen = ZChunk.Size(this.gen);

            Vector3[] positions = ZChunk.Positions(Zombiome.worldSeed, zchunk, gen);

            foreach (Vector3 pos in positions)
            {
                Printer.Log(40, "Flood regen", zchunk, pos);
                Vector3i    surfaced = Geo3D.Surface(Vectors.ToInt(pos), iniguess);
                Emplacement place    = Emplacement.At(Vectors.ToFloat(surfaced), Vectors.Float.UnitY);
                /* Generate Emplacement => apply filter from gth */
                int  th = GameManager.Instance.World.GetTerrainHeight(surfaced.x, surfaced.z);
                bool go = th > 5;
                if (go)
                {
                    go = surfaced.y < th + Placer.pOffSurface;
                }
                if (go)
                {
                    go = surfaced.y > th - Placer.nOffSurface;
                }
                if (go)
                {
                    go = !(IsWater(World.GetBlock(surfaced + Vectors.Up).Block) &&
                           IsWater(World.GetBlock(surfaced + 2 * Vectors.Up).Block));
                }
                if (go)
                {
                    Printer.Log(40, "Flood at", place);
                    // Dont do it if already water, surtout qu'on affaisse la surface !!
                    // Cave allows to bound water by ground
                    yield return(EffectsCollapse.Cave(player, place, opt));
                }
                yield return(Repeater.Yield);
            }
        }