/// <summary> /// Constructor. /// </summary> public ThumbnailGenerator() { Debugging.OptionalMessage("creating thumbnail generator"); // Get local reference from parent. renderer = ThumbnailManager.Renderer; // Size and setting for thumbnail images: 109 x 100, doubled for anti-aliasing. renderer.Size = new Vector2(109, 100) * 2f; renderer.CameraRotation = 210f; }
private static bool Prefix(BuildingInfo __instance) { // Basic sanity check before proceeding; if failed, don't do anything here - just continue on to game method. if (__instance.name == null) { return(true); } // Create a new building record for this prefab and add it to our lists. var buildingData = new BuildingData { prefab = __instance, name = __instance.name, density = Loading.xmlManager.SetPrefabDensity(__instance), category = Loading.xmlManager.AssignCategory(__instance), }; Loading.xmlManager.prefabHash[__instance] = buildingData; // Add to broken prefabs list (will be removed later if it's not broken). Loading.brokenPrefabs.Add(__instance); // Search for PloppableRICODefinition.xml files with this asset. // Need to use FindAssetByName(string, AssetType) because FindAssetByName(string) doesn't catch all assets at this stage of initialisation // (those two methods are more different than you might think - discovered that the hard way). Package.Asset asset = PackageManager.FindAssetByName(__instance.name, Package.AssetType.Object); if (asset?.package?.packagePath != null) { // Get custom asset filesystem location (if CRP pacakge). string crpPath = asset.package.packagePath; // Look for RICO settings file. string ricoDefPath = Path.Combine(Path.GetDirectoryName(crpPath), "PloppableRICODefinition.xml"); if (File.Exists(ricoDefPath)) { // Parse the file. var tempRicoDef = RICOReader.ParseRICODefinition(asset.package.packageName, ricoDefPath); if (tempRicoDef != null) { foreach (var buildingDef in tempRicoDef.Buildings) { // Go through each building parsed and check to see if we've got a match for this prefab. if (MatchRICOName(buildingDef.name, __instance.name, asset.package.packageName)) { // Match! Add these author settings to our prefab dictionary. Debugging.OptionalMessage("found author settings for " + buildingDef.name); Loading.xmlManager.prefabHash[__instance].author = buildingDef; Loading.xmlManager.prefabHash[__instance].hasAuthor = true; } } } } } // Check for and add any local settings for this prefab to our list. if (Loading.localRicoDef != null) { // Step through our previously loaded local settings and see if we've got a match. foreach (var buildingDef in Loading.localRicoDef.Buildings) { if (buildingDef.name.Equals(__instance.name)) { // Match! Add these author settings to our prefab dictionary. Loading.xmlManager.prefabHash[__instance].local = buildingDef; Loading.xmlManager.prefabHash[__instance].hasLocal = true; } } } // Check for any Workshop RICO mod settings for this prefab. if (Loading.mod1RicoDef != null) { // Step through our previously loaded local settings and see if we've got a match. foreach (var buildingDef in Loading.mod1RicoDef.Buildings) { if (buildingDef.name.Equals(__instance.name)) { // Match! Add these author settings to our prefab dictionary. Loading.xmlManager.prefabHash[__instance].mod = buildingDef; Loading.xmlManager.prefabHash[__instance].hasMod = true; } } } // Check for Modern Japan CCP mod settings for this prefab. if (Loading.mod2RicoDef != null) { // Step through our previously loaded local settings and see if we've got a match. foreach (var buildingDef in Loading.mod2RicoDef.Buildings) { if (buildingDef.name.Equals(__instance.name)) { // Match! Add these author settings to our prefab dictionary. Loading.xmlManager.prefabHash[__instance].mod = buildingDef; Loading.xmlManager.prefabHash[__instance].hasMod = true; } } } // Apply appropriate RICO settings to prefab. if (Loading.convertPrefabs != null) { // Start with local settings. if (Loading.xmlManager.prefabHash[__instance].hasLocal) { // If local settings disable RICO, dont convert. if (Loading.xmlManager.prefabHash[__instance].local.ricoEnabled) { Loading.convertPrefabs.ConvertPrefab(Loading.xmlManager.prefabHash[__instance].local, __instance); } } // If no local settings, apply author settings. else if (Loading.xmlManager.prefabHash[__instance].hasAuthor) { // If author settings disable RICO, dont convert. if (Loading.xmlManager.prefabHash[__instance].author.ricoEnabled) { Loading.convertPrefabs.ConvertPrefab(Loading.xmlManager.prefabHash[__instance].author, __instance); } } // If none of the above, apply mod settings. else if (Loading.xmlManager.prefabHash[__instance].hasMod) { // If mod settings disable RICO, dont convert. if (Loading.xmlManager.prefabHash[__instance].mod.ricoEnabled) { Loading.convertPrefabs.ConvertPrefab(Loading.xmlManager.prefabHash[__instance].mod, __instance); } } else { // No RICO settings; replicate game InitializePrefab checks overridden by transpiler. int privateServiceIndex = ItemClass.GetPrivateServiceIndex(__instance.m_class.m_service); if (privateServiceIndex != -1) { if (__instance.m_placementStyle == ItemClass.Placement.Manual) { throw new PrefabException(__instance, "Private building cannot have manual placement style"); } if (__instance.m_paths != null && __instance.m_paths.Length != 0) { throw new PrefabException(__instance, "Private building cannot include roads or other net types"); } } } } else { // This means that there's been a significant failure. Ploppable RICO settings can't be applied. Debugging.Message("convertPrefabs not initialised"); } // If we've made it this far, the patch is working fine - set the watchdog flag to confirm. Loading.patchOperating = true; // Continue on to execute game InitializePrefab. return(true); }