private static bool ProcessVisiting(ref TouristAI touristAI, uint citizenId, ref Citizen citizen) { CitizenActivityMonitor.LogActivity(citizenId, CitizenActivityMonitor.Activity.Visiting); if (!citizen.ValidVisitBuilding()) { return(false); } var touristHotelSearchRadius = BuildingManager.BUILDINGGRID_CELL_SIZE * 4; var currentBuildingInstance = citizen.VisitBuildingInstance().Value; var simulationManager = SimulationManager.instance; if (citizen.Tired() || citizen.Tired(TimeSpan.FromHours(6))) { if (citizen.Tired() && citizen.InHotel()) { touristAI.GoToSleep(citizenId); return(true); } var foundHotel = touristAI.FindCloseHotel(citizenId, ref citizen, touristHotelSearchRadius, currentBuildingInstance); if (foundHotel != 0 && simulationManager.m_randomizer.Int32(10) < 8) { var foundHotelInstance = BuildingManager.instance.m_buildings.m_buffer[foundHotel]; var estimatedTravelTime = TravelTime.EstimateTravelTime(currentBuildingInstance, foundHotelInstance); if (citizen.Tired(estimatedTravelTime)) { touristAI.TryVisit(citizenId, ref citizen, foundHotel); return(true); } } else if (citizen.Tired()) { touristAI.LeaveTheCity(citizenId, ref citizen); return(true); } } var goSomewhere = (simulationManager.m_randomizer.Int32(10) < 3 || citizen.InHotel()) && !citizen.AfraidOfGettingWet(); if (goSomewhere) { var keepItLocal = simulationManager.m_randomizer.Int32(10) < 6; if (keepItLocal) { var ventureDistance = (BuildingManager.BUILDINGGRID_CELL_SIZE * 2) + (simulationManager.m_randomizer.Int32(3) * BuildingManager.BUILDINGGRID_CELL_SIZE); var randomActivityNumber = simulationManager.m_randomizer.Int32(9); ushort closeActivity = 0; if (randomActivityNumber < 3 || simulationManager.m_currentGameTime.Hour >= 21) { closeActivity = touristAI.FindCloseLeisure(citizenId, ref citizen, ventureDistance, currentBuildingInstance); } else if (randomActivityNumber < 6) { closeActivity = touristAI.FindClosePark(citizenId, ref citizen, ventureDistance, currentBuildingInstance); } else { closeActivity = touristAI.FindCloseShop(citizenId, ref citizen, ventureDistance, currentBuildingInstance); } if (closeActivity != 0) { var closeActivityBuilding = BuildingManager.instance.m_buildings.m_buffer[closeActivity]; if (!citizen.Tired(TravelTime.EstimateTravelTime(currentBuildingInstance, closeActivityBuilding))) { touristAI.TryVisit(citizenId, ref citizen, closeActivity); } } } else { var goShopping = simulationManager.m_randomizer.Int32(10) < 5; if (goShopping) { touristAI.FindAShop(citizenId, ref citizen); } else { touristAI.FindAFunActivity(citizenId, citizen.GetBuilding()); } } } else if (citizen.GettingWet()) { CitizenActivityMonitor.LogActivity(citizenId, CitizenActivityMonitor.Activity.GettingWet); var hotel = touristAI.FindCloseHotel(citizenId, ref citizen, touristHotelSearchRadius, currentBuildingInstance); if (hotel != 0) { touristAI.TryVisit(citizenId, ref citizen, hotel); } } return(true); }
public static bool FindAShop(this TouristAI touristAI, uint citizenId, ref Citizen citizen) { var buildingId = citizen.GetBuilding(); return(touristAI.FindAShop(citizenId, ref citizen, buildingId)); }