/// <summary> /// 'sets up Arrays with the Structure pieces and their weights' /// </summary> public static void PrepareStructurePieces() { StructurePieceList = new List <StructureStrongholdPieceWeight>(); StructureStrongholdPieceWeight[] astructurestrongholdpieceweight = PieceWeightArray; int i = astructurestrongholdpieceweight.Length; for (int j = 0; j < i; j++) { StructureStrongholdPieceWeight structurestrongholdpieceweight = astructurestrongholdpieceweight[j]; structurestrongholdpieceweight.InstancesSpawned = 0; StructurePieceList.Add(structurestrongholdpieceweight); } StrongComponentType = null; }
private static bool CanAddStructurePieces() { bool flag = false; TotalWeight = 0; for (IEnumerator <StructureStrongholdPieceWeight> iterator = StructurePieceList.GetEnumerator(); iterator.MoveNext();) { StructureStrongholdPieceWeight structurestrongholdpieceweight = iterator.Current; if (structurestrongholdpieceweight.InstancesLimit > 0 && structurestrongholdpieceweight.InstancesSpawned < structurestrongholdpieceweight.InstancesLimit) { flag = true; } TotalWeight += structurestrongholdpieceweight.PieceWeight; } return(flag); }
private static ComponentStronghold GetNextComponent(ComponentStrongholdStairs2 par0ComponentStrongholdStairs2, List <StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) { if (!CanAddStructurePieces()) { return(null); } else { if (StrongComponentType != null) { ComponentStronghold var8 = GetStrongholdComponentFromWeightedPiece(StrongComponentType, par1List, par2Random, par3, par4, par5, par6, par7); StrongComponentType = null; if (var8 != null) { return(var8); } } int var13 = 0; while (var13 < 5) { ++var13; int var9 = par2Random.Next(TotalWeight); IEnumerator <StructureStrongholdPieceWeight> var10 = StructurePieceList.GetEnumerator(); while (var10.MoveNext()) { StructureStrongholdPieceWeight var11 = var10.Current; var9 -= var11.PieceWeight; if (var9 < 0) { if (!var11.CanSpawnMoreStructuresOfType(par7) || var11 == par0ComponentStrongholdStairs2.Field_35038_a) { break; } ComponentStronghold var12 = GetStrongholdComponentFromWeightedPiece(var11.PieceClass, par1List, par2Random, par3, par4, par5, par6, par7); if (var12 != null) { ++var11.InstancesSpawned; par0ComponentStrongholdStairs2.Field_35038_a = var11; if (!var11.CanSpawnMoreStructures()) { StructurePieceList.Remove(var11); } return(var12); } } } } StructureBoundingBox var14 = ComponentStrongholdCorridor.Func_35051_a(par1List, par2Random, par3, par4, par5, par6); if (var14 != null && var14.MinY > 1) { return(new ComponentStrongholdCorridor(par7, par2Random, var14, par6)); } else { return(null); } } }