protected CareerLocation FindClosestCareerLocation(SimDescription s, OccupationNames careerName) { if (s.Household == null) { IncStat("No Household"); return(null); } Career staticCareer = CareerManager.GetStaticCareer(careerName); if (staticCareer == null) { IncStat("Career Fail"); return(null); } Lot lotHome = s.Household.LotHome; if (lotHome == null) { if (staticCareer.Locations.Count > 0x0) { return(RandomUtil.GetRandomObjectFromList <CareerLocation>(staticCareer.Locations)); } else { IncStat("No Lot Home"); return(null); } } CareerLocation location = null; float bestDistance = float.MaxValue; float distanceToObject = 0f; foreach (CareerLocation location2 in staticCareer.Locations) { if (!GetLotOptions(location2.Owner.LotCurrent).AllowCastes(this, s)) { continue; } distanceToObject = lotHome.GetDistanceToObject(location2.Owner.RabbitHoleProxy); if (distanceToObject < bestDistance) { location = location2; bestDistance = distanceToObject; } } return(location); }