public static SL_ImbueEffect ParseImbueEffect(ImbueEffectPreset imbue) { var template = new SL_ImbueEffect { TargetStatusID = imbue.PresetID, Name = imbue.Name, Description = imbue.Description }; //CustomStatusEffects.GetImbueLocalization(imbue, out template.Name, out template.Description); var list = new List <SL_EffectTransform>(); foreach (Transform child in imbue.transform) { var effectsChild = SL_EffectTransform.ParseTransform(child); if (effectsChild.HasContent) { list.Add(effectsChild); } } template.Effects = list.ToArray(); return(template); }
/// <summary> /// Use this to create or modify an Imbue Effect status. /// </summary> /// <param name="template">The SL_ImbueEffect Template for this imbue.</param> public static ImbueEffectPreset CreateCustomImbue(SL_ImbueEffect template) { var original = (ImbueEffectPreset)GetOrigEffectPreset(template.TargetStatusID); if (!original) { SL.LogError("Could not find an ImbueEffectPreset with the Preset ID " + template.TargetStatusID); return(null); } ImbueEffectPreset newEffect; if (template.TargetStatusID == template.NewStatusID) { if (!OrigEffectPresets.ContainsKey(template.TargetStatusID)) { // instantiate and cache original var cached = GameObject.Instantiate(original.gameObject).GetComponent <EffectPreset>(); cached.gameObject.SetActive(false); GameObject.DontDestroyOnLoad(cached.gameObject); OrigEffectPresets.Add(template.TargetStatusID, cached); } newEffect = original; } else { // instantiate original and use that as newEffect newEffect = GameObject.Instantiate(original.gameObject).GetComponent <ImbueEffectPreset>(); newEffect.gameObject.SetActive(false); // Set Preset ID At.SetField <EffectPreset>(newEffect, "m_StatusEffectID", template.NewStatusID); // Fix localization GetImbueLocalization(original, out string name, out string desc); SetImbueLocalization(newEffect, name, desc); } newEffect.gameObject.name = template.NewStatusID + "_" + (template.Name ?? newEffect.Name); // fix RPM_Presets dictionary if (!References.RPM_EFFECT_PRESETS.ContainsKey(template.NewStatusID)) { References.RPM_EFFECT_PRESETS.Add(template.NewStatusID, newEffect.GetComponent <EffectPreset>()); } else { References.RPM_EFFECT_PRESETS[template.NewStatusID] = newEffect; } // Always do this GameObject.DontDestroyOnLoad(newEffect.gameObject); //// Apply template //if (SL.PacksLoaded) // template.ApplyTemplate(); //else // SL.INTERNAL_ApplyStatuses += template.ApplyTemplate; return(newEffect); }