public static void Start() { Log("Slime Rancher Cube Slime Mod v" + UMFMod.GetModVersion().ToString(), true); UMFGUI.RegisterPauseHandler(Pause); //Load the Mesh replaceMesh = UMFAsset.LoadMesh(meshFile); if (replaceMesh == null) { Log("Error: Failed to load the mesh."); } else { Log("Successfully loaded the mesh."); } }
public static void Prefix(LookupDirector __instance, ref List <GameObject> ___identifiablePrefabs, ref List <LookupDirector.VacEntry> ___vacEntries) { if (!Levels.isSpecial() || patched) { return; } patched = true; //Replace the mesh on all slimes with the cube slime mesh List <GameObject> prefabs = ___identifiablePrefabs; foreach (GameObject go in prefabs) { Identifiable identifiable = go.GetComponent <Identifiable>(); if (!identifiable || !Identifiable.IsSlime(identifiable.id)) { continue; } MeshFilter[] meshFilters = go.GetComponentsInChildren <MeshFilter>(); foreach (MeshFilter meshFilter in meshFilters) { if (SRCubeSlimeMod.replaceMeshes.Contains(meshFilter.name)) { meshFilter.mesh = SRCubeSlimeMod.replaceMesh; } } } Traverse.Create(__instance).Field("identifiablePrefabs").SetValue(prefabs); SRCubeSlimeMod.Log("Successfully replaced the mesh in prefab Slimes."); //Load and replace the icons List <LookupDirector.VacEntry> vacEntries = ___vacEntries; foreach (LookupDirector.VacEntry entry in vacEntries) { if (SRCubeSlimeMod.replaceIcons.Contains(entry.id)) { Texture2D icon = UMFAsset.LoadTexture2D("icon_" + entry.id.ToString().ToLower() + ".png"); Sprite sprite = Sprite.Create(icon, entry.icon.rect, entry.icon.pivot, entry.icon.pixelsPerUnit); entry.icon = sprite; } } Traverse.Create(__instance).Field("vacEntries").SetValue(vacEntries); SRCubeSlimeMod.Log("Successfully replaced the Slime Icons."); SRCubeSlimeMod.updateActiveSlimes = true; }