public static void Prefix(LookupDirector __instance) { __instance.identifiablePrefabs.AddRange(LookupRegistry.objectsToPatch); __instance.vacEntries.AddRange(LookupRegistry.vacEntriesToPatch); __instance.gadgetEntries.AddRange(LookupRegistry.gadgetEntriesToPatch); __instance.upgradeEntries.AddRange(LookupRegistry.upgradeEntriesToPatch); }
// Initializes the Extension internal static void InitExtension(this LookupDirector director) { // Required prefabs GameObject gingerSpawnResource = director.GetPrefab(Identifiable.Id.GINGER_VEGGIE).CreatePrefabCopy(); gingerSpawnResource.GetComponent <ResourceCycle>().unripeGameHours = 12; GameObject kookadobaSpawnResource = director.GetPrefab(Identifiable.Id.KOOKADOBA_FRUIT).CreatePrefabCopy(); kookadobaSpawnResource.GetComponent <ResourceCycle>().unripeGameHours = 6; // Load garden resources gardenResources.Add(Identifiable.Id.BEET_VEGGIE, director.GetPrefab(Identifiable.Id.BEET_VEGGIE)); gardenResources.Add(Identifiable.Id.CARROT_VEGGIE, director.GetPrefab(Identifiable.Id.CARROT_VEGGIE)); gardenResources.Add(Identifiable.Id.GINGER_VEGGIE, gingerSpawnResource); gardenResources.Add(Identifiable.Id.OCAOCA_VEGGIE, director.GetPrefab(Identifiable.Id.OCAOCA_VEGGIE)); gardenResources.Add(Identifiable.Id.ONION_VEGGIE, director.GetPrefab(Identifiable.Id.BEET_VEGGIE)); gardenResources.Add(Identifiable.Id.PARSNIP_VEGGIE, director.GetPrefab(Identifiable.Id.PARSNIP_VEGGIE)); gardenResources.Add(Identifiable.Id.CUBERRY_FRUIT, director.GetPrefab(Identifiable.Id.CUBERRY_FRUIT)); gardenResources.Add(Identifiable.Id.KOOKADOBA_FRUIT, kookadobaSpawnResource); gardenResources.Add(Identifiable.Id.LEMON_FRUIT, director.GetPrefab(Identifiable.Id.LEMON_FRUIT)); gardenResources.Add(Identifiable.Id.MANGO_FRUIT, director.GetPrefab(Identifiable.Id.MANGO_FRUIT)); gardenResources.Add(Identifiable.Id.PEAR_FRUIT, director.GetPrefab(Identifiable.Id.PEAR_FRUIT)); gardenResources.Add(Identifiable.Id.POGO_FRUIT, director.GetPrefab(Identifiable.Id.POGO_FRUIT)); }
// Gordo Creation System public static SlimeTemplate MakeRoamingGordo(this LookupDirector director, string name, Identifiable.Id gordoID, SlimeDefinition definition) { SlimeDefinition gordoDef = ScriptableObject.CreateInstance <SlimeDefinition>(); gordoDef.AppearancesDefault = definition.AppearancesDefault; gordoDef.AppearancesDynamic = definition.AppearancesDynamic; gordoDef.BaseModule = definition.BaseModule; gordoDef.BaseSlimes = definition.BaseSlimes; gordoDef.CanLargofy = false; gordoDef.Diet = definition.Diet; gordoDef.FavoriteToys = new Identifiable.Id[0]; gordoDef.IdentifiableId = gordoID; gordoDef.IsLargo = true; gordoDef.PrefabScale = 4f; gordoDef.SlimeModules = definition.SlimeModules; gordoDef.Sounds = definition.Sounds; gordoDef.Name = "roamGordo." + definition.Name; FearProfile prof = ScriptableObject.CreateInstance <FearProfile>(); prof.threats = new List <FearProfile.ThreatEntry>(); prof.GetType().GetMethod("OnEnable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(prof, new object[0]); SlimeTemplate gordo = new SlimeTemplate(name, gordoDef).SetVacSize(Vacuumable.Size.GIANT) .SetHealth(60).SetFeralState(false).SetGlitchState(false).SetFearProfile(prof).SetTranslation(definition.Name + " Gordo"); Identifiable.SLIME_CLASS.Add(gordoID); return(gordo); }
public static void Postfix(LookupDirector __instance) { if (wasMainMenu != Levels.isSpecial()) { wasMainMenu = Levels.isSpecial(); SRCubeSlimeMod.updateActiveSlimes = true; } if (!SRCubeSlimeMod.updateActiveSlimes) { return; } SRCubeSlimeMod.updateActiveSlimes = false; int num = 0; foreach (Identifiable identifiable in Object.FindObjectsOfType <Identifiable>()) { if (!Identifiable.IsSlime(identifiable.id)) { continue; } MeshFilter[] meshFilters = identifiable.gameObject.GetComponentsInChildren <MeshFilter>(); foreach (MeshFilter meshFilter in meshFilters) { if (SRCubeSlimeMod.replaceMeshes.Contains(meshFilter.name)) { meshFilter.mesh = SRCubeSlimeMod.replaceMesh; } } num++; } SRCubeSlimeMod.Log("Successfully replaced the mesh in " + num.ToString() + " active Slimes."); }
private static void Awake_Postfix(LookupDirector @this, Dictionary <Identifiable.Id, GameObject> p_identifiablePrefabDict, Dictionary <Gadget.Id, GadgetDefinition> p_gadgetDefinitionDict, Dictionary <Identifiable.Id, VacItemDefinition> p_vacItemDict) { //& Injects main game content IdentifiableRegistry.InjectPrefabs(p_identifiablePrefabDict); GadgetRegistry.InjectGadgets(p_gadgetDefinitionDict); IdentifiableRegistry.InjectVacEntries(p_vacItemDict); }
//+ BEHAVIOUR /// <summary>Awakes the behaviour, ran before any interactions</summary> public new void Awake() { displayMap.Clear(); econDir = SceneContext.Instance.EconomyDirector; progressDir = SceneContext.Instance.ProgressDirector; lookupDir = GameContext.Instance.LookupDirector; FixEntryPrefab(); }
public static Identifiable.Id CraftLargo(this LookupDirector director, Identifiable.Id slimeA, Identifiable.Id slimeB, Action <SlimeDefinition> extraLargoBehaviour = null, Predicate <Identifiable.Id> canBeTarr = null, Predicate <Identifiable.Id> forceLargo = null) { if (director.LargoExists(slimeA, slimeB)) { return(Identifiable.Id.NONE); } string prefabName = "slime" + slimeA.ToString().Replace("_SLIME", "").ToUpper()[0] + slimeA.ToString().Replace("_SLIME", "").ToLower().Substring(1) + slimeB.ToString().Replace("_SLIME", "").ToUpper()[0] + slimeB.ToString().Replace("_SLIME", "").ToLower().Substring(1); string name = slimeA.ToString().Replace("_SLIME", "") + slimeB.ToString().Replace("_SLIME", "") + "_LARGO"; Identifiable.Id largoID = IdentifiableRegistry.CreateIdentifiableId(EnumPatcher.GetFirstFreeValue(typeof(Identifiable.Id)), name); SlimeDefinitions defs = GameContext.Instance.SlimeDefinitions; SlimeDefinition curr = defs.GetSlimeByIdentifiableId(slimeA); SlimeDefinition other = defs.GetSlimeByIdentifiableId(slimeB); bool largofyState = curr.CanLargofy; curr.CanLargofy = true; if (!other.CanLargofy && !(forceLargo?.Invoke(slimeB) ?? false)) { return(Identifiable.Id.NONE); } bool largofyStateB = other.CanLargofy; other.CanLargofy = true; SlimeDefinition largoDef = defs.GetLargoByBaseSlimes(curr, other); largoDef.IdentifiableId = largoID; curr.CanLargofy = largofyState; other.CanLargofy = largofyStateB; if (!(canBeTarr?.Invoke(slimeB) ?? true)) { largoDef.Diet.EatMap.RemoveAll((entry) => entry.becomesId == Identifiable.Id.TARR_SLIME); largoDef.Diet.EatMap.RemoveAll((entry) => entry.becomesId == Identifiable.Id.GLITCH_TARR_SLIME); } extraLargoBehaviour?.Invoke(largoDef); SlimeTemplate largoTemplate = new SlimeTemplate(prefabName, largoDef).SetVacSize(Vacuumable.Size.LARGE) .SetTranslation(curr.Name + " " + other.Name + " Largo").Create(); LookupRegistry.RegisterIdentifiablePrefab(largoTemplate.ToPrefab()); return(largoID); }
//+ PREFAB CONTROL /// <summary> /// Gets all the prefabs from the given IDs /// </summary> /// <param name="dir">The lookup director</param> /// <param name="ids">The IDs</param> public static GameObject[] GetPrefabs(this LookupDirector dir, Identifiable.Id[] ids) { List <GameObject> objs = new List <GameObject>(); foreach (Identifiable.Id id in ids) { objs.Add(dir.GetPrefab(id)); } return(objs.ToArray()); }
public static void Prefix(LookupDirector __instance) { __instance.identifiablePrefabs.AddAndRemoveRangeWhere(LookupRegistry.objectsToPatch, (x, y) => Identifiable.GetId(x) == Identifiable.GetId(y)); __instance.vacItemDefinitions.AddAndRemoveRangeWhere(LookupRegistry.vacEntriesToPatch, (x, y) => x.id == y.id); __instance.gadgetDefinitions.AddAndRemoveRangeWhere(LookupRegistry.gadgetEntriesToPatch, (x, y) => x.id == y.id); __instance.upgradeDefinitions.AddAndRemoveRangeWhere(LookupRegistry.upgradeEntriesToPatch, (x, y) => x.upgrade == y.upgrade); __instance.plotPrefabs.AddAndRemoveRangeWhere(LookupRegistry.landPlotsToPatch, (x, y) => x.GetComponentInChildren <LandPlot>().typeId == y.GetComponentInChildren <LandPlot>().typeId); __instance.resourceSpawnerPrefabs.AddAndRemoveRangeWhere(LookupRegistry.resourceSpawnersToPatch, (x, y) => x.GetComponent <SpawnResource>().id == y.GetComponent <SpawnResource>().id); __instance.liquidDefinitions.AddAndRemoveRangeWhere(LookupRegistry.liquidsToPatch, (x, y) => x.id == y.id); __instance.gordoEntries.AddAndRemoveRangeWhere(LookupRegistry.gordosToPatch, (x, y) => y.GetComponent <GordoIdentifiable>().id == x.GetComponent <GordoIdentifiable>().id); __instance.toyDefinitions.AddAndRemoveRangeWhere(LookupRegistry.toysToPatch, (x, y) => x.toyId == y.toyId); }
// Check Methods public static bool LargoExists(this LookupDirector director, Identifiable.Id slimeA, Identifiable.Id slimeB) { string nameA = slimeA.ToString().Replace("_SLIME", ""); string nameB = slimeB.ToString().Replace("_SLIME", ""); string largoA = $"{nameA}_{nameB}_LARGO"; string largoB = $"{nameB}_{nameA}_LARGO"; object result = Enum.Parse(typeof(Identifiable.Id), largoA) ?? Enum.Parse(typeof(Identifiable.Id), largoB); return(result != null); }
// Largo Creation System public static List <Identifiable.Id> MakeLargos(this LookupDirector director, Identifiable.Id slimeA, Action <SlimeDefinition> extraLargoBehaviour = null, Predicate <Identifiable.Id> canBeTarr = null, Predicate <Identifiable.Id> forceLargo = null) { List <Identifiable.Id> largoIDs = new List <Identifiable.Id>(); foreach (Identifiable.Id id in GameContext.Instance.LookupDirector.GetSlimeIDs(slimeA)) { largoIDs.Add(director.CraftLargo(slimeA, id, extraLargoBehaviour, canBeTarr, forceLargo)); } largoIDs.RemoveAll((id) => id == Identifiable.Id.NONE); return(largoIDs); }
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; }
public static GameObject GetLargoPrefab(this LookupDirector director, Identifiable.Id slimeA, Identifiable.Id slimeB) { Identifiable.Id largo = Identifiable.Id.NONE; string nameA = slimeA.ToString().Replace("_SLIME", ""); string nameB = slimeB.ToString().Replace("_SLIME", ""); string largoA = $"{nameA}_{nameB}_LARGO"; string largoB = $"{nameB}_{nameA}_LARGO"; object result = Enum.Parse(typeof(Identifiable.Id), largoA) ?? Enum.Parse(typeof(Identifiable.Id), largoB); if (result != null) { largo = (Identifiable.Id)result; } return(largo == Identifiable.Id.NONE ? null : director.GetPrefab(largo)); }
private void CommandLoadPrefabs() //load the prefab maps we need for randomization { lookupDirector = SRSingleton <GameContext> .Instance.LookupDirector; var slimes = Identifiable.SLIME_CLASS; slimePrefabToId = new Dictionary <String, Identifiable.Id>(); foreach (Identifiable.Id id in slimes) { slimePrefabToId.Add(lookupDirector.GetPrefab(id).ToString(), id); } var produce = Identifiable.FRUIT_CLASS.ToList(); produce.AddRange(Identifiable.VEGGIE_CLASS); producePrefabToId = new Dictionary <string, Identifiable.Id>(); foreach (Identifiable.Id id in produce) { producePrefabToId.Add(lookupDirector.GetPrefab(id).ToString(), id); } }
// Get IDs Methods public static List <Identifiable.Id> GetSlimeIDs(this LookupDirector director, params Identifiable.Id[] exclusions) { List <Identifiable.Id> result = new List <Identifiable.Id>(); List <Identifiable.Id> exclude = new List <Identifiable.Id>(exclusions); foreach (Identifiable.Id id in Enum.GetValues(typeof(Identifiable.Id))) { if (exclude.Contains(id)) { continue; } if (!id.ToString().EndsWith("_SLIME")) { continue; } result.Add(id); } return(result); }
/// <summary>Adjusts the UI rendering to account for value of <see cref="Configuration.maxItemSlots"/>.</summary> /// <param name="this">The instance of SiloSlotUI this method is hooking.</param> public static void Update(SiloSlotUI @this) { //set lookupDir only once (only if it's null) lookupDir = lookupDir ?? SRSingleton <GameContext> .Instance.LookupDirector; //this has to be done here, because we don't have access to the private field //We can't just save it, because there will be many SiloSlotUIs, and they don't all share the same SiloStorage SiloStorage storage = @this.GetComponentInParent <SiloStorage>(); //Get the slot ID for the Silo slot this screen is on Identifiable.Id slotIdentifiable = storage.GetSlotIdentifiable(@this.slotIdx); //check if there is any item in this slot if (slotIdentifiable != Identifiable.Id.NONE) { //do render stuff @this.slotIcon.sprite = lookupDir.GetIcon(slotIdentifiable); @this.slotIcon.enabled = true; //rather than scaling our current item count, we just change the max slots @this.bar.maxValue = BiggerSilo.Config.maxItemSlots; @this.bar.currValue = storage.GetSlotCount(@this.slotIdx); @this.bar.barColor = lookupDir.GetColor(slotIdentifiable); @this.frontFrameIcon.sprite = @this.frontFilled; @this.backFrameIcon.sprite = @this.backFilled; } else { //do more render stuff @this.slotIcon.enabled = false; @this.bar.currValue = 0f; @this.bar.barColor = Color.black; @this.frontFrameIcon.sprite = @this.frontEmpty; @this.backFrameIcon.sprite = @this.backEmpty; } }
public static GordoTemplate MakeStaticGordo(this LookupDirector director, string name, Identifiable.Id gordoID, SlimeDefinition definition, Material[] gordoMaterials) { return(new GordoTemplate(name, gordoID, definition, gordoMaterials).SetTranslation(definition.Name + " Gordo")); }
/// <summary> /// Checks if there is a prefab for the given identifiable ID /// </summary> /// <param name="dir">The lookup director</param> /// <param name="id">The ID to check</param> public static bool HasPrefab(this LookupDirector dir, Identifiable.Id id) { return(dir.GetPrivateField <Dictionary <Identifiable.Id, GameObject> >("identifiablePrefabDict").ContainsKey(id)); }
/// <summary> /// Checks if there is a prefab for the given land plot ID /// </summary> /// <param name="dir">The lookup director</param> /// <param name="id">The ID to check</param> public static bool HasPlotPrefab(this LookupDirector dir, LandPlot.Id id) { return(dir.GetPrivateField <Dictionary <LandPlot.Id, GameObject> >("plotPrefabDict").ContainsKey(id)); }
private static void Awake_Prefix(LookupDirector @this) { }
// Get Prefab Methods public static GameObject GetGardenResourcePrefab(this LookupDirector director, Identifiable.Id ID) { return(gardenResources.ContainsKey(ID) ? gardenResources[ID] : null); }
// Get Component Methods public static Identifiable GetIdentifiable(this LookupDirector director, Identifiable.Id ID) { return(director.GetPrefab(ID).GetComponent <Identifiable>()); }