public static Brand MakeBrand(string name, string description = null) { if (LuaPowerData.customEnums[typeof(Brand)].Contains(name)) { MPLog.Log("ERROR: A Brand exists with this name already."); return(Brand.None); } Brand brand = (Brand)(LuaPowerData.customEnums[typeof(Brand)].Count); LuaPowerData.customEnums[typeof(Brand)].Add(name); Array.Resize(ref S.I.deCtrl.brandSprites, Mathf.Max(S.I.deCtrl.brandSprites.Length, (int)brand + 1)); Traverse.Create(S.I.foCtrl).Field("brandTypes").Method("Add", new Type[] { typeof(Brand) }).GetValue(new object[] { brand }); S.I.itemMan.brandTypes.Add(brand); BrandListCard brandListCard = UnityEngine.Object.Instantiate <BrandListCard>(S.I.foCtrl.brandListCardPrefab); brandListCard.transform.SetParent(S.I.foCtrl.focusGrid); brandListCard.foCtrl = S.I.foCtrl; brandListCard.displayButton = false; brandListCard.parentList = S.I.foCtrl.brandListCards; brandListCard.SetBrand(brand); brandListCard.tmpText.text = name; S.I.foCtrl.brandListCards.Add(brandListCard); LuaPowerLang.ImportTerm("BrandNames/" + name, name); if (description != null) { LuaPowerLang.ImportTerm("BrandDescriptions/" + name, description); } return(brand); }
static bool Prefix(string modName) { if (Harmony.HasAnyPatches("com." + modName + ".patch")) { MPLog.Log(modName + " is not being reinstalled", LogLevel.Info); return(false); } return(true); }
public static IEnumerator _SetBrandImage(string name, string sprite, string BGSprite = null) { while (!LuaPowerData.customEnums[typeof(Brand)].Contains(name)) { yield return(new WaitForSeconds(0f)); MPLog.Log("ERROR: A Brand does not exist with the name " + name + ".\nTrying again next frame (make a brand with MakeBrand)", LogLevel.Info); } while (LuaPowerSprites.GetSprite(sprite) == null) { yield return(new WaitForSeconds(0f)); } while (BGSprite != null && LuaPowerSprites.GetSprite(BGSprite) == null) { yield return(new WaitForSeconds(0f)); } Array.Resize(ref S.I.deCtrl.brandSprites, Mathf.Max(S.I.deCtrl.brandSprites.Length, LuaPowerData.customEnums[typeof(Brand)].IndexOf(name) + 1)); S.I.deCtrl.brandSprites[LuaPowerData.customEnums[typeof(Brand)].IndexOf(name)] = LuaPowerSprites.GetSprite(sprite); if (S.I.deCtrl.spellBackgroundBrands.Count <= LuaPowerData.customEnums[typeof(Brand)].IndexOf(name)) { while (S.I.deCtrl.spellBackgroundBrands.Count <= LuaPowerData.customEnums[typeof(Brand)].IndexOf(name)) { if (BGSprite != null) { S.I.deCtrl.spellBackgroundBrands.Add(LuaPowerSprites.GetSprite(BGSprite)); } else { S.I.deCtrl.spellBackgroundBrands.Add(LuaPowerSprites.GetSprite(sprite)); } } } else if (BGSprite != null && LuaPowerSprites.GetSprite(BGSprite) != null) { S.I.deCtrl.spellBackgroundBrands[LuaPowerData.customEnums[typeof(Brand)].IndexOf(name)] = LuaPowerSprites.GetSprite(BGSprite); } else { S.I.deCtrl.spellBackgroundBrands[LuaPowerData.customEnums[typeof(Brand)].IndexOf(name)] = LuaPowerSprites.GetSprite(sprite); } foreach (BrandListCard b in S.I.foCtrl.brandListCards) { if (b.brand == (Brand)LuaPowerData.customEnums[typeof(Brand)].IndexOf(name)) { b.image.sprite = LuaPowerSprites.GetSprite(sprite); } } }
static void Prefix(SpellObject spellObj, Enhancement enhancement) { if ((int)enhancement >= LuaPowerData.baseGameEnumAmount[typeof(Enhancement)] && LuaPowerData.customUpgrades.ContainsKey(enhancement.ToString())) { Script mainscr = Traverse.Create(Traverse.Create <EffectActions>().Field("_Instance").GetValue <EffectActions>()).Field("myLuaScript").GetValue <Script>(); MPLog.Log(" Creating Enhancement: " + enhancement.ToString() + " Check function: " + LuaPowerData.customUpgrades[enhancement.ToString()].Item2 , LogLevel.Info); if (mainscr.Call(mainscr.Globals[LuaPowerData.customUpgrades[enhancement.ToString()].Item2], new object[] { spellObj }).Boolean) { MPLog.Log(" Creating Enhancement: " + enhancement.ToString() + " Apply function: " + LuaPowerData.customUpgrades[enhancement.ToString()].Item3 , LogLevel.Info); mainscr.Call(mainscr.Globals[LuaPowerData.customUpgrades[enhancement.ToString()].Item3], new object[] { spellObj }); spellObj.nameString += U.I.Colorify(" " + LuaPowerData.customUpgrades[enhancement.ToString()].Item1, UIColor.Enhancement); spellObj.enhancements.Add(enhancement); } } }
public static IEnumerator _AddMusicHook(string AudioName, string zoneBgName, string type) { while (!LuaPowerData.customMusic.ContainsKey(AudioName)) { MPLog.Log("Warning: " + AudioName + " is not added as music yet, trying again next frame", LogLevel.Info); yield return(new WaitForSeconds(0f)); } if (type == "Battle") { LuaPowerData.customMusic[zoneBgName + "_Battle"] = LuaPowerData.customMusic[AudioName]; } if (type == "Idle") { LuaPowerData.customMusic[zoneBgName + "_Idle"] = LuaPowerData.customMusic[AudioName]; } if (type == "Boss") { LuaPowerData.customMusic[zoneBgName] = LuaPowerData.customMusic[AudioName]; } }