private IEnumerator SetupCoroutine() { while (!ResourcesPrefabManager.Instance.Loaded) { yield return(null); } // Prefabs are loaded // Elemental Discharge Object ID 8200310 var _elementalDischargeID = 8200310; // check to make sure it is a skill if (ResourcesPrefabManager.Instance.GetItemPrefab(_elementalDischargeID) is Skill _skill) { // maintain compatibility with other mods by checking if unique effects added if (_skill.transform.Find("Effects") is Transform effects) { // add component to child effects.gameObject.AddComponent <RemoveImbueEffects>(); } else { // create new child var removeImbueEffect = new GameObject("Effects"); removeImbueEffect.transform.parent = _skill.transform; // add component to the child removeImbueEffect.AddComponent <RemoveImbueEffects>(); } // change item description (copied from sinai's side loader) string name = "Elemental Discharge"; string desc = String.Format("Required: Infused Weapon\n\nThrust your weapon forward, removing the elemental infusion to shoot a projectile of that element."); ItemLocalization loc = new ItemLocalization(name, desc); typeof(Item).GetField("m_name", flags).SetValue(_skill, name); if (typeof(LocalizationManager).GetField("m_itemLocalization", flags).GetValue(LocalizationManager.Instance) is Dictionary <int, ItemLocalization> dict) { if (dict.ContainsKey(_skill.ItemID)) { dict[_skill.ItemID] = loc; } else { dict.Add(_skill.ItemID, loc); } typeof(LocalizationManager).GetField("m_itemLocalization", flags).SetValue(LocalizationManager.Instance, dict); } // make sure safe through loading screens DontDestroyOnLoad(_skill.gameObject); } }
/// <summary> Set both name and description. Used by SetName and SetDescription. </summary> public static void SetNameAndDescription(Item item, string _name, string _description) { var name = _name ?? ""; var desc = _description ?? ""; // set the local fields on the item (this should be enough for 99% of cases) At.SetField(item, "m_name", name); At.SetField(item, "m_localizedName", name); At.SetField(item, "m_lastNameLang", LocalizationManager.Instance.CurrentLanguage); At.SetField(item, "m_localizedDescription", desc); At.SetField(item, "m_lastDescLang", LocalizationManager.Instance.CurrentLanguage); // set the localization to the LocalizationManager dictionary var loc = new ItemLocalization(name, desc); if (References.ITEM_LOCALIZATION.ContainsKey(item.ItemID)) { References.ITEM_LOCALIZATION[item.ItemID] = loc; } else { References.ITEM_LOCALIZATION.Add(item.ItemID, loc); } // keep track of the custom localization in case the user changes language if (s_customLocalizations.ContainsKey(item.ItemID)) { s_customLocalizations[item.ItemID] = loc; } else { s_customLocalizations.Add(item.ItemID, loc); } // If the item is in the "duplicate" localization dicts, remove it. if (References.LOCALIZATION_DUPLICATE_NAME.ContainsKey(item.ItemID)) { References.LOCALIZATION_DUPLICATE_NAME.Remove(item.ItemID); } if (References.LOCALIZATION_DUPLICATE_DESC.ContainsKey(item.ItemID)) { References.LOCALIZATION_DUPLICATE_DESC.Remove(item.ItemID); } }
public void SetNameAndDesc(Item item, string name, string desc) { ItemLocalization loc = new ItemLocalization(name, desc); At.SetValue(name, typeof(Item), item, "m_name"); if (At.GetValue(typeof(LocalizationManager), LocalizationManager.Instance, "m_itemLocalization") is Dictionary <int, ItemLocalization> dict) { if (dict.ContainsKey(item.ItemID)) { dict[item.ItemID] = loc; } else { dict.Add(item.ItemID, loc); } At.SetValue(dict, typeof(LocalizationManager), LocalizationManager.Instance, "m_itemLocalization"); } }
// Token: 0x0600001C RID: 28 RVA: 0x00002920 File Offset: 0x00000B20 public static void SetNameAndDesc(ImbueEffectPreset imbueEffect, string name, string desc) { ItemLocalization value = new ItemLocalization(name, desc); Dictionary <int, ItemLocalization> dictionary = At.GetValue(typeof(LocalizationManager), LocalizationManager.Instance, "m_itemLocalization") as Dictionary <int, ItemLocalization>; bool flag = dictionary != null; if (flag) { bool flag2 = dictionary.ContainsKey(imbueEffect.PresetID); if (flag2) { dictionary[imbueEffect.PresetID] = value; } else { dictionary.Add(imbueEffect.PresetID, value); } } }