Пример #1
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);
                }
            }
        }
Пример #2
0
        private static ComponentVillage GetVillageComponentFromWeightedPiece(StructureVillagePieceWeight par0StructureVillagePieceWeight, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7)
        {
            Type   class1 = par0StructureVillagePieceWeight.VillagePieceClass;
            object obj    = null;

            if (class1 == (typeof(net.minecraft.src.ComponentVillageHouse4_Garden)))
            {
                obj = ComponentVillageHouse4_Garden.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageChurch)))
            {
                obj = ComponentVillageChurch.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageHouse1)))
            {
                obj = ComponentVillageHouse1.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageWoodHut)))
            {
                obj = ComponentVillageWoodHut.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageHall)))
            {
                obj = ComponentVillageHall.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageField)))
            {
                obj = ComponentVillageField.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageField2)))
            {
                obj = ComponentVillageField2.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageHouse2)))
            {
                obj = ComponentVillageHouse2.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }
            else if (class1 == (typeof(net.minecraft.src.ComponentVillageHouse3)))
            {
                obj = ComponentVillageHouse3.FindValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7);
            }

            return((ComponentVillage)(obj));
        }
Пример #3
0
        private static int GetAvailablePieceWeight(List <StructureVillagePieceWeight> par0ArrayList)
        {
            bool flag = false;
            int  i    = 0;

            for (IEnumerator <StructureVillagePieceWeight> iterator = par0ArrayList.GetEnumerator(); iterator.MoveNext();)
            {
                StructureVillagePieceWeight structurevillagepieceweight = iterator.Current;

                if (structurevillagepieceweight.VillagePiecesLimit > 0 && structurevillagepieceweight.VillagePiecesSpawned < structurevillagepieceweight.VillagePiecesLimit)
                {
                    flag = true;
                }

                i += structurevillagepieceweight.VillagePieceWeight;
            }

            return(flag ? i : -1);
        }