Example #1
0
        private static StructureComponent GetNextComponentVillagePath(ComponentVillageStartPiece par0ComponentVillageStartPiece, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7)
        {
            if (par7 > 3 + par0ComponentVillageStartPiece.TerrainType)
            {
                return(null);
            }

            if (Math.Abs(par3 - par0ComponentVillageStartPiece.GetBoundingBox().MinX) > 112 || Math.Abs(par5 - par0ComponentVillageStartPiece.GetBoundingBox().MinZ) > 112)
            {
                return(null);
            }

            StructureBoundingBox structureboundingbox = ComponentVillagePathGen.Func_35087_a(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6);

            if (structureboundingbox != null && structureboundingbox.MinY > 10)
            {
                ComponentVillagePathGen componentvillagepathgen = new ComponentVillagePathGen(par7, par2Random, structureboundingbox, par6);
                int i  = (((StructureComponent)(componentvillagepathgen)).BoundingBox.MinX + ((StructureComponent)(componentvillagepathgen)).BoundingBox.MaxX) / 2;
                int j  = (((StructureComponent)(componentvillagepathgen)).BoundingBox.MinZ + ((StructureComponent)(componentvillagepathgen)).BoundingBox.MaxZ) / 2;
                int k  = ((StructureComponent)(componentvillagepathgen)).BoundingBox.MaxX - ((StructureComponent)(componentvillagepathgen)).BoundingBox.MinX;
                int l  = ((StructureComponent)(componentvillagepathgen)).BoundingBox.MaxZ - ((StructureComponent)(componentvillagepathgen)).BoundingBox.MinZ;
                int i1 = k <= l ? l : k;

                if (par0ComponentVillageStartPiece.GetWorldChunkManager().AreBiomesViable(i, j, i1 / 2 + 4, MapGenVillage.VillageSpawnBiomes))
                {
                    par1List.Add(componentvillagepathgen);
                    par0ComponentVillageStartPiece.Field_35106_f.Add(componentvillagepathgen);
                    return(componentvillagepathgen);
                }
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// 'attempts to find a next Structure Component to be spawned, private Village function'
        /// </summary>
        private static StructureComponent GetNextVillageStructureComponent(ComponentVillageStartPiece par0ComponentVillageStartPiece, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7)
        {
            if (par7 > 50)
            {
                return(null);
            }

            if (Math.Abs(par3 - par0ComponentVillageStartPiece.GetBoundingBox().MinX) > 112 || Math.Abs(par5 - par0ComponentVillageStartPiece.GetBoundingBox().MinZ) > 112)
            {
                return(null);
            }

            ComponentVillage componentvillage = GetNextVillageComponent(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6, par7 + 1);

            if (componentvillage != null)
            {
                int i  = (((StructureComponent)(componentvillage)).BoundingBox.MinX + ((StructureComponent)(componentvillage)).BoundingBox.MaxX) / 2;
                int j  = (((StructureComponent)(componentvillage)).BoundingBox.MinZ + ((StructureComponent)(componentvillage)).BoundingBox.MaxZ) / 2;
                int k  = ((StructureComponent)(componentvillage)).BoundingBox.MaxX - ((StructureComponent)(componentvillage)).BoundingBox.MinX;
                int l  = ((StructureComponent)(componentvillage)).BoundingBox.MaxZ - ((StructureComponent)(componentvillage)).BoundingBox.MinZ;
                int i1 = k <= l ? l : k;

                if (par0ComponentVillageStartPiece.GetWorldChunkManager().AreBiomesViable(i, j, i1 / 2 + 4, MapGenVillage.VillageSpawnBiomes))
                {
                    par1List.Add(componentvillage);
                    par0ComponentVillageStartPiece.Field_35108_e.Add(componentvillage);
                    return(componentvillage);
                }
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// 'attempts to find a next Village Component to be spawned'
        /// </summary>
        private static ComponentVillage GetNextVillageComponent(ComponentVillageStartPiece par0ComponentVillageStartPiece, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7)
        {
            int var8 = GetAvailablePieceWeight(par0ComponentVillageStartPiece.StructureVillageWeightedPieceList);

            if (var8 <= 0)
            {
                return(null);
            }
            else
            {
                int var9 = 0;

                while (var9 < 5)
                {
                    ++var9;
                    int var10 = par2Random.Next(var8);
                    IEnumerator <StructureVillagePieceWeight> var11 = par0ComponentVillageStartPiece.StructureVillageWeightedPieceList.GetEnumerator();

                    while (var11.MoveNext())
                    {
                        StructureVillagePieceWeight var12 = var11.Current;
                        var10 -= var12.VillagePieceWeight;

                        if (var10 < 0)
                        {
                            if (!var12.CanSpawnMoreVillagePiecesOfType(par7) || var12 == par0ComponentVillageStartPiece.StructVillagePieceWeight && par0ComponentVillageStartPiece.StructureVillageWeightedPieceList.Count > 1)
                            {
                                break;
                            }

                            ComponentVillage var13 = GetVillageComponentFromWeightedPiece(var12, par1List, par2Random, par3, par4, par5, par6, par7);

                            if (var13 != null)
                            {
                                ++var12.VillagePiecesSpawned;
                                par0ComponentVillageStartPiece.StructVillagePieceWeight = var12;

                                if (!var12.CanSpawnMoreVillagePieces())
                                {
                                    par0ComponentVillageStartPiece.StructureVillageWeightedPieceList.Remove(var12);
                                }

                                return(var13);
                            }
                        }
                    }
                }

                StructureBoundingBox var14 = ComponentVillageTorch.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6);

                if (var14 != null)
                {
                    return(new ComponentVillageTorch(par7, par2Random, var14, par6));
                }
                else
                {
                    return(null);
                }
            }
        }
        public static StructureBoundingBox Func_35087_a(ComponentVillageStartPiece par0ComponentVillageStartPiece, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6)
        {
            for (int i = 7 * MathHelper2.GetRandomIntegerInRange(par2Random, 3, 5); i >= 7; i -= 7)
            {
                StructureBoundingBox structureboundingbox = StructureBoundingBox.GetComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 3, 3, i, par6);

                if (StructureComponent.FindIntersecting(par1List, structureboundingbox) == null)
                {
                    return(structureboundingbox);
                }
            }

            return(null);
        }
        public StructureVillageStart(World par1World, Random par2Random, int par3, int par4, int par5)
        {
            HasMoreThanTwoComponents = false;
            int i = par5;
            List <StructureVillagePieceWeight> arraylist = StructureVillagePieces.GetStructureVillageWeightedPieceList(par2Random, i);
            ComponentVillageStartPiece         componentvillagestartpiece = new ComponentVillageStartPiece(par1World.GetWorldChunkManager(), 0, par2Random, (par3 << 4) + 2, (par4 << 4) + 2, arraylist, i);

            Components.Add(componentvillagestartpiece);
            componentvillagestartpiece.BuildComponent(componentvillagestartpiece, Components, par2Random);
            List <StructureComponent> arraylist1 = componentvillagestartpiece.Field_35106_f;

            for (List <StructureComponent> arraylist2 = componentvillagestartpiece.Field_35108_e; arraylist1.Count > 0 || arraylist2.Count > 0;)
            {
                if (arraylist1.Count > 0)
                {
                    int j = par2Random.Next(arraylist1.Count);
                    StructureComponent structurecomponent = arraylist1[i];
                    arraylist1.RemoveAt(j);
                    structurecomponent.BuildComponent(componentvillagestartpiece, Components, par2Random);
                }
                else
                {
                    int k = par2Random.Next(arraylist2.Count);
                    StructureComponent structurecomponent1 = arraylist2[k];
                    arraylist2.RemoveAt(k);
                    structurecomponent1.BuildComponent(componentvillagestartpiece, Components, par2Random);
                }
            }

            UpdateBoundingBox();
            int l = 0;
            IEnumerator <StructureComponent> iterator = Components.GetEnumerator();

            do
            {
                if (!iterator.MoveNext())
                {
                    break;
                }

                StructureComponent structurecomponent2 = iterator.Current;

                if (!(structurecomponent2 is ComponentVillageRoadPiece))
                {
                    l++;
                }
            }while (true);

            HasMoreThanTwoComponents = l > 2;
        }
Example #6
0
        /// <summary>
        /// Gets the next village component, with the bounding box shifted +1 in the X and Z direction.
        /// </summary>
        protected virtual StructureComponent GetNextComponentPP(ComponentVillageStartPiece par1ComponentVillageStartPiece, List <StructureComponent> par2List, Random par3Random, int par4, int par5)
        {
            switch (CoordBaseMode)
            {
            case 2:
                return(StructureVillagePieces.GetNextStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, BoundingBox.MaxX + 1, BoundingBox.MinY + par4, BoundingBox.MinZ + par5, 3, GetComponentType()));

            case 0:
                return(StructureVillagePieces.GetNextStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, BoundingBox.MaxX + 1, BoundingBox.MinY + par4, BoundingBox.MinZ + par5, 3, GetComponentType()));

            case 1:
                return(StructureVillagePieces.GetNextStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, BoundingBox.MinX + par5, BoundingBox.MinY + par4, BoundingBox.MaxZ + 1, 0, GetComponentType()));

            case 3:
                return(StructureVillagePieces.GetNextStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, BoundingBox.MinX + par5, BoundingBox.MinY + par4, BoundingBox.MaxZ + 1, 0, GetComponentType()));
            }

            return(null);
        }
Example #7
0
 public static StructureComponent GetNextStructureComponentVillagePath(ComponentVillageStartPiece par0ComponentVillageStartPiece, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7)
 {
     return(GetNextComponentVillagePath(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6, par7));
 }