public static void DumpQuick() { var types = new HashSet <Type>() { typeof(BlueprintCharacterClass), typeof(BlueprintRaceVisualPreset), typeof(BlueprintRace), typeof(BlueprintArchetype), typeof(BlueprintProgression), typeof(BlueprintStatProgression), typeof(BlueprintFeature), typeof(BlueprintFeatureSelection), typeof(BlueprintSpellbook), typeof(BlueprintSpellList), typeof(BlueprintSpellsTable), typeof(BlueprintItemWeapon), }; foreach (var blueprint in ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>()) { if (types.Contains(blueprint.GetType())) { JsonBlueprints.Dump(blueprint); } } }
public static void DumpBlueprint(BlueprintScriptableObject blueprint, string directory = "Blueprints", bool verbose = false) { JsonSerializerSettings settings = null; if (verbose) { settings = JsonBlueprints.CreateSettings(); settings.DefaultValueHandling = DefaultValueHandling.Include; } JsonBlueprints.Dump(blueprint, $"{directory}/{blueprint.GetType()}/{blueprint.name}.{blueprint.AssetGuid}.json", settings); }
public static void DumpUnitViews() { foreach (var kv in ResourcesLibrary.LibraryObject.ResourcePathsByAssetId) { var resource = ResourcesLibrary.TryGetResource <UnitEntityView>(kv.Key); if (resource == null) { continue; } JsonBlueprints.Dump(resource, kv.Key); } }
public static void DumpBlueprints() { var seen = new HashSet <Type>(); var blueprints = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>(); foreach (var blueprint in blueprints) { if (!seen.Contains(blueprint.GetType())) { seen.Add(blueprint.GetType()); JsonBlueprints.Dump(blueprint); } } }
public static void DumpScriptableObjects() { Directory.CreateDirectory("ScriptableObjects"); foreach (var obj in UnityEngine.Object.FindObjectsOfType <ScriptableObject>()) { try { JsonBlueprints.Dump(obj, $"ScriptableObjects/{obj.GetType()}/{obj.name}.{obj.GetInstanceID()}.json"); } catch (Exception ex) { File.WriteAllText($"ScriptableObjects/{obj.GetType()}/{obj.name}.{obj.GetInstanceID()}.txt", ex.ToString()); } } }
public static void DumpScriptableObjects() { Directory.CreateDirectory("ScriptableObjects"); foreach (var obj in UnityEngine.Object.FindObjectsOfType <ScriptableObject>()) { try { if (obj is BlueprintScriptableObject blueprint && !GetBlueprintMap().ContainsKey(blueprint.AssetGuid)) { JsonBlueprints.Dump(blueprint, $"ScriptableObjects/{blueprint.GetType()}/{blueprint.name}.{blueprint.AssetGuid}.json"); } else { JsonBlueprints.Dump(obj, $"ScriptableObjects/{obj.GetType()}/{obj.name}.{obj.GetInstanceID()}.json"); } }
public static void DumpAllBlueprints() { var blueprints = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>(); Directory.CreateDirectory("Blueprints"); using (var file = new StreamWriter("Blueprints/log.txt")) { foreach (var blueprint in blueprints) { if (blueprint.AssetGuid.Length != 32) { continue; } try { JsonBlueprints.Dump(blueprint); } catch (Exception ex) { file.WriteLine($"Error dumping {blueprint.name}:{blueprint.AssetGuid}:{blueprint.GetType().FullName}, {ex.ToString()}"); } } } }
static void OnGUI(UnityModManager.ModEntry modEntry) { try { if (!enabled) { return; } #if (DEBUG) GUILayout.Label($"Game Version: {GameVersion.GetVersion()}"); if (GUILayout.Button("DumpAssets")) { AssetsDump.DumpAssets(); } if (GUILayout.Button("DumpClassRaceBlueprints")) { AssetsDump.DumpQuick(); } if (GUILayout.Button("DumpSampleOfBlueprints")) { AssetsDump.DumpBlueprints(); } if (GUILayout.Button("DumpAllBlueprints")) { AssetsDump.DumpAllBlueprints(); } if (GUILayout.Button("DumpAllBlueprintsVerbose")) { AssetsDump.DumpAllBlueprintsVerbose(); } if (GUILayout.Button("DumpFlags")) { var blueprints = ResourcesLibrary.GetBlueprints <BlueprintUnlockableFlag>(); Directory.CreateDirectory("Blueprints"); using (var file = new StreamWriter("Blueprints/log.txt")) { foreach (var blueprint in blueprints) { if (blueprint.AssetGuid.Length != 32) { continue; } Main.DebugLog($"Dumping {blueprint.name} - {blueprint.AssetGuid}"); try { AssetsDump.DumpBlueprint(blueprint); } catch (Exception ex) { file.WriteLine($"Error dumping {blueprint.name}:{blueprint.AssetGuid}:{blueprint.GetType().FullName}, {ex.ToString()}"); } } } } if (GUILayout.Button("DumpEquipmentEntities")) { AssetsDump.DumpEquipmentEntities(); } if (GUILayout.Button("DumpUnitViews")) { AssetsDump.DumpUnitViews(); } if (GUILayout.Button("DumpList")) { AssetsDump.DumpList(); } if (GUILayout.Button("DumpScriptableObjects")) { AssetsDump.DumpScriptableObjects(); } if (GUILayout.Button("DumpAssetBundles")) { AssetsDump.DumpAssetBundles(); } if (GUILayout.Button("DumpUI")) { AssetsDump.DumpUI(); } if (GUILayout.Button("DumpSceneList")) { AssetsDump.DumpSceneList(); } if (GUILayout.Button("DumpKingdom")) { AssetsDump.DumpKingdom(); } if (GUILayout.Button("DumpView")) { var view = ResourcesLibrary.TryGetResource <GameObject>("adf003833b2463543a065d5160c7e8f1"); var character = view.GetComponent <Character>(); JsonBlueprints.Dump(character, "adf003833b2463543a065d5160c7e8f1"); } if (GUILayout.Button("TestLoad")) { var vp = JsonBlueprints.Load <BlueprintRaceVisualPreset>("mods/customraces/data/TestPreset.json"); DebugLog("Loaded " + vp.name); } #endif } catch (Exception e) { DebugLog(e.ToString() + " " + e.StackTrace); } }
static void DumpResource(UnityEngine.Object resource, string assetId) { Directory.CreateDirectory($"Blueprints/{resource.GetType()}"); JsonBlueprints.Dump(resource, $"Blueprints/{resource.GetType()}/{resource.name}.{assetId}.json"); }
public static void DumpKingdom() { JsonBlueprints.Dump(KingdomState.Instance, "Kingdom"); }
public static void DumpBlueprint(BlueprintScriptableObject blueprint) { JsonBlueprints.Dump(blueprint, $"Blueprints/{blueprint.GetType()}/{blueprint.name}.{blueprint.AssetGuid}.json"); }
static void OnGUI(UnityModManager.ModEntry modEntry) { try { if (!enabled) { return; } #if (DEBUG) if (GUILayout.Button("DumpClassRaceBlueprints")) { AssetsDump.DumpQuick(); } if (GUILayout.Button("DumpSampleOfBlueprints")) { AssetsDump.DumpBlueprints(); } if (GUILayout.Button("DumpAllBlueprints")) { AssetsDump.DumpAllBlueprints(); } if (GUILayout.Button("DumpEquipmentEntities")) { AssetsDump.DumpEquipmentEntities(); } if (GUILayout.Button("DumpUnitViews")) { AssetsDump.DumpUnitViews(); } if (GUILayout.Button("DumpList")) { AssetsDump.DumpList(); } if (GUILayout.Button("DumpAssetBundles")) { AssetsDump.DumpAssetBundles(); } if (GUILayout.Button("DumpUI")) { AssetsDump.DumpUI(); } if (GUILayout.Button("DumpKingdom")) { AssetsDump.DumpKingdom(); } if (GUILayout.Button("DumpView")) { var view = ResourcesLibrary.TryGetResource <GameObject>("adf003833b2463543a065d5160c7e8f1"); var character = view.GetComponent <Character>(); JsonBlueprints.Dump(character, "adf003833b2463543a065d5160c7e8f1"); } if (GUILayout.Button("TestLoad")) { //var bp = JsonBlueprints.Load<BlueprintCharacterClass>("mods/customraces/data/slayerclass.json"); //DebugLog("Loaded " + (bp?.name ?? "NULL")); //var info = BlueprintInfo.Load(); //DebugLog("Loaded " + info.Classes[0].name); var vp = JsonBlueprints.Load <BlueprintRaceVisualPreset>("mods/customraces/data/TestPreset.json"); DebugLog("Loaded " + vp.name); } /* * UnityEngine.Networking.NetworkTransport.GetAssetId(go) //returns "" * internal static extern bool Object.DoesObjectWithInstanceIDExist(int instanceID); //returns true * internal static extern Object Object.FindObjectFromInstanceID(int instanceID); // returns CR_Hair_VioletDark_U_HM * Resources.FindObjectsOfTypeAll<Texture2D>() // returns CR_Hair_VioletDark_U_HM after it has been loaded with Resource.Load */ if (GUILayout.Button("FindObject")) { var go = BlueprintUtil.FindObjectByInstanceId <GameObject>(270194); DebugLog("FindByID " + go == null ? "NULL" : go.name); //OH_LongswordThieves var sprite = BlueprintUtil.FindObjectByInstanceId <Sprite>(45820); DebugLog(sprite == null ? "NULL" : sprite.name); //OH_LongswordThieves var texture1 = BlueprintUtil.FindObjectByInstanceId <Texture2D>(552466); DebugLog(texture1 == null ? "NULL" : texture1.name); //CR_Hair_VioletDark_U_HM var humanHair = ResourcesLibrary.TryGetResource <EquipmentEntity>("a9558cfc0705d4e48af7ecd2ebd75411"); //EE_Hair_HairLongWavy_M_HM var texture2 = BlueprintUtil.FindObjectByInstanceId <Texture2D>(552466); DebugLog(texture2 == null ? "NULL" : texture2.name); //CR_Hair_VioletDark_U_HM } if (GUILayout.Button("FindObject2")) { var doesExist = Traverse.Create <UnityEngine.Object>().Method("DoesObjectWithInstanceIDExist", new object[] { 552466 }).GetValue <bool>(); DebugLog($"Does resource exist first {doesExist}"); var tex1 = Traverse.Create <UnityEngine.Object>().Method("FindObjectFromInstanceID", new object[] { 552466 }).GetValue <UnityEngine.Object>(); DebugLog(tex1 == null ? "NULL" : tex1.name); //CR_Hair_VioletDark_U_HM var humanHair = ResourcesLibrary.TryGetResource <EquipmentEntity>("a9558cfc0705d4e48af7ecd2ebd75411"); //EE_Hair_HairLongWavy_M_HM doesExist = Traverse.Create <UnityEngine.Object>().Method("DoesObjectWithInstanceIDExist", new object[] { 552466 }).GetValue <bool>(); DebugLog($"Does resource exist second {doesExist}"); var tex2 = Traverse.Create <UnityEngine.Object>().Method("FindObjectFromInstanceID", new object[] { 552466 }).GetValue <UnityEngine.Object>(); DebugLog(tex2 == null ? "NULL" : tex2.name); //CR_Hair_VioletDark_U_HM var go = (GameObject)BlueprintUtil.FindObjectByInstanceId <GameObject>(270194); DebugLog("FindByID " + go == null ? "NULL" : go.name); //OH_LongswordThieves var assetId = UnityEngine.Networking.NetworkTransport.GetAssetId(go); if (assetId == null) { assetId = "NULL"; } if (assetId == "") { assetId = "Empty"; } DebugLog($"AssetId: {assetId}"); } if (GUILayout.Button("Reload")) { BlueprintManager.Reload(); } #endif } catch (Exception e) { DebugLog(e.ToString() + " " + e.StackTrace); } }