public static bool Prefix(byte park, ref DistrictPark data) { var districtPark = DistrictPark.FromPark(park); if (districtPark.Name != string.Empty) { Constraints.ReleaseDistrictPark(districtPark); } return(true); }
/// <summary> /// Called when a building is first created. If situated in a district or park, then automatically restricts that /// building to serve its home district only. /// </summary> /// <param name="buildingId"></param> public static void CreateBuilding(ushort buildingId) { if (!TransferManagerInfo.IsDistrictServicesBuilding(buildingId)) { return; } var buildingInfo = BuildingManager.instance.m_buildings.m_buffer[buildingId].Info; var service = buildingInfo.GetService(); var subService = buildingInfo.GetSubService(); var ai = buildingInfo.GetAI(); // Do not pack the homeDistrict and homePark into a single DistrictPark struct. Otherwise, it will make // removing districts/parks a lot harder!! var position = BuildingManager.instance.m_buildings.m_buffer[buildingId].m_position; var homeDistrict = DistrictManager.instance.GetDistrict(position); var homePark = DistrictManager.instance.GetPark(position); Logger.Log($"Constraints::CreateBuilding: buildingId={buildingId}, homeDistrict={homeDistrict}, homePark={homePark}, service={service}, subService={subService}, ai={ai}"); // Set default input settings. SetAllInputLocalAreas(buildingId, true); SetAllInputOutsideConnections(buildingId, true); m_inputBuildingToDistrictParkServiced[buildingId] = null; // Do not set the home district for these types of buildings. if (ai is ChildcareAI || ai is EldercareAI) { homeDistrict = 0; homePark = 0; } // Serve all areas if the building doesn't belong to any district or park. SetAllOutputLocalAreas(buildingId, homeDistrict == 0 && homePark == 0); SetAllOutputOutsideConnections(buildingId, homeDistrict == 0 && homePark == 0); m_outputBuildingToDistrictParkServiced[buildingId] = null; if (homeDistrict != 0) { AddOutputDistrictParkServiced(buildingId, DistrictPark.FromDistrict(homeDistrict)); } if (homePark != 0) { AddOutputDistrictParkServiced(buildingId, DistrictPark.FromPark(homePark)); } }