Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
                }
            }
        }