private VillageDoorInfo Func_48284_a(Village par1Village) { VillageDoorInfo villagedoorinfo = null; int i = 0x7fffffff; List <VillageDoorInfo> list = par1Village.GetVillageDoorInfoList(); IEnumerator <VillageDoorInfo> iterator = list.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } VillageDoorInfo villagedoorinfo1 = iterator.Current; int j = villagedoorinfo1.GetDistanceSquared(MathHelper2.Floor_double(TheEntity.PosX), MathHelper2.Floor_double(TheEntity.PosY), MathHelper2.Floor_double(TheEntity.PosZ)); if (j < i && !Func_48285_a(villagedoorinfo1)) { villagedoorinfo = villagedoorinfo1; i = j; } }while (true); return(villagedoorinfo); }
/// <summary> /// Find a door suitable for shelter. If there are more doors in a distance of 16 blocks, then the least restricted /// one (i.e. the one protecting the lowest number of villagers) of them is chosen, else the nearest one regardless /// of restriction. /// </summary> public virtual VillageDoorInfo FindNearestDoorUnrestricted(int par1, int par2, int par3) { VillageDoorInfo villagedoorinfo = null; int i = 0x7fffffff; IEnumerator <VillageDoorInfo> iterator = VillageDoorInfoList.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } VillageDoorInfo villagedoorinfo1 = iterator.Current; int j = villagedoorinfo1.GetDistanceSquared(par1, par2, par3); if (j > 256) { j *= 1000; } else { j = villagedoorinfo1.GetDoorOpeningRestrictionCounter(); } if (j < i) { villagedoorinfo = villagedoorinfo1; i = j; } }while (true); return(villagedoorinfo); }
private void UpdateVillageRadiusAndCenter() { int i = VillageDoorInfoList.Count; if (i == 0) { Center.Set(0, 0, 0); VillageRadius = 0; return; } Center.Set(CenterHelper.PosX / i, CenterHelper.PosY / i, CenterHelper.PosZ / i); int j = 0; for (IEnumerator <VillageDoorInfo> iterator = VillageDoorInfoList.GetEnumerator(); iterator.MoveNext();) { VillageDoorInfo villagedoorinfo = iterator.Current; j = Math.Max(villagedoorinfo.GetDistanceSquared(Center.PosX, Center.PosY, Center.PosZ), j); } VillageRadius = Math.Max(32, (int)Math.Sqrt(j) + 1); }