Пример #1
0
    public static Vector3[] Positions4(string worldseed, Vector3i chunk, int maxsize)
    {
        Printer.Log(55, "ZChunk.Positions4 start", worldseed, chunk, maxsize);
        int            len00 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x, chunk.z));
        int            len10 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x + 1, chunk.z));
        int            len01 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x, chunk.z + 1));
        int            len11 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x + 1, chunk.z + 1));
        List <Vector3> pos   = new List <Vector3>();

        for (int index = 0; index < maxsize; index++) // todo : 4 boolean to optimize test and break
        {
            if (index < len00)
            {
                pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk, index));
            }
            if (index < len10)
            {
                pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk + new Vector3i(1, 0, 0), index));
            }
            if (index < len01)
            {
                pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk + new Vector3i(0, 0, 1), index));
            }
            if (index < len11)
            {
                pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk + new Vector3i(1, 0, 1), index));
            }
        }
        Printer.Log(55, "ZChunk.Positions4 OK", pos.Count(), pos);
        return(pos.ToArray());
    }
Пример #2
0
    private static void ShowPos(List <string> _params)
    {
        EntityPlayerLocal player = GameManager.Instance.World.GetLocalPlayers()[0];
        Vector3i          pos    = Vectors.ToInt(player.GetPosition());
        Vector3i          c1     = ZChunk.TL1(pos.x, pos.z);
        Vector3i          c4     = ZChunk.TL4(pos);

        Printer.FPrint("Pos {0} -> {1}. C4={2}", pos, c1, c4);
    }
Пример #3
0
        public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt)
        {
            Printer.Print("SingleChunked Effect1", place.position, place.ipos, opt.OptionItem.item);
            Vector3i where = Vectors.ToInt(player.GetPosition());
            int      y0  = Geo3D.Surface(where).y;
            Vector3i nw4 = ZChunk.TL4(place.ipos);
            Bounds   b4  = ZChunk.Bounds4(nw4, y0);

            Zombiome.Routines.Start(Regen(player, b4, y0), name + "-SingleChunked");
        }
Пример #4
0
        public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt)
        {
            Printer.Log(46, "SingleChunked Effect1", place.position, place.ipos, opt.OptionItem.item);
            Vector3i where = Vectors.ToInt(player.GetPosition());
            int y0 = Geo3D.Surface(where).y;

            Vector3i nw4 = ZChunk.TL4(place.ipos);

            Zombiome.Routines.Start(Regen(player, nw4, y0), name + "-SingleChunked0");
            Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(1, 0, 0), y0), name + "-SingleChunked1");
            Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(0, 0, 1), y0), name + "-SingleChunked2");
            Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(1, 0, 1), y0), name + "-SingleChunked3");
        }
Пример #5
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);
                }
            }
        }
Пример #6
0
        public override IEnumerator<Vector3> Get(Vector3 position) {
            int maxsize = 10;
            Vector3i zchunk = ZChunk.TL4(position);
            bool D0 = false; int L0 = ZChunk.Len(zchunk + ZChunk.adjacents[0], maxsize);
            bool D1 = false; int L1 = ZChunk.Len(zchunk + ZChunk.adjacents[1], maxsize);
            bool D2 = false; int L2 = ZChunk.Len(zchunk + ZChunk.adjacents[2], maxsize);
            bool D3 = false; int L3 = ZChunk.Len(zchunk + ZChunk.adjacents[3], maxsize);

            for (int step=0; step<maxsize; step++) {
                if (! D0 && step > L0) D0 = true;
                if (! D0) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[0], step);
                if (! D1 && step > L1) D1 = true;
                if (! D1) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[1], step);
                if (! D2 && step > L2) D2 = true;
                if (! D2) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[2], step);
                if (! D3 && step > L3) D3 = true;
                if (! D3) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[3], step);
                if (D0 && D1 && D2 && D3) break;
            }
        }
Пример #7
0
    public static Zone[] GetFour(Vector3 position)
    {
        Vector3i cp = ZChunk.TL4(position, ZoneSize);

        Zone[] zones = new Zone[4];
        for (int adj = 0; adj < 4; adj++)
        {
            // foreach (Vector3i offset in ZChunk.adjacents) {
            Vector3i zca    = cp + ZChunk.adjacents[adj];
            int      _index = zca.x + nZone * zca.z;
            if (!AllZones.ContainsKey(_index))
            {
                Zone created = new Zone(zca.x, zca.z);
                Printer.Log(62, "GetFour returned", created);
                AllZones[_index] = created;
            }
            zones[adj] = AllZones[_index];
            Printer.Log(62, "Zone Get dict _index", _index);
            Printer.Log(62, "Zone Get in dict", AllZones[_index]);
        }
        return(zones);
    }
Пример #8
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);
            }
        }
Пример #9
0
 public override Bounds Bounds(Vector3 position) {
     Vector3i zchunk = ZChunk.TL4(position);
     return ZChunk.Bounds4(zchunk, (int) Math.Floor(position.y));
 }