public static StatusData.EffectData[] GenerateEffectsData(List <Effect> effects, int level = 1) { // Create a list to generate the EffectData[] array into. var list = new List <StatusData.EffectData>(); // Iterate over the effects foreach (var effect in effects) { // Create a blank holder, in the case this effect isn't supported or doesn't serialize anything. var data = new StatusData.EffectData() { Data = new string[] { "" } }; var type = effect.GetType(); if (typeof(PunctualDamage).IsAssignableFrom(type)) { var comp = effect as PunctualDamage; // For PunctualDamage, Data[0] is the entire damage, and Data[1] is the impact. // Each damage goes "Damage : Type", and separated by a ';' char. // So we just iterate over the damage and serialize like that. var dmgString = ""; foreach (var dmg in comp.Damages) { if (dmgString != "") { dmgString += ";"; } dmgString += $"{dmg.Damage * level}:{dmg.Type}"; } // finally, set data data.Data = new string[] { dmgString, comp.Knockback.ToString() }; } else if (typeof(AffectNeed).IsAssignableFrom(type)) { var fi = At.GetFieldInfo(typeof(AffectNeed), "m_affectQuantity"); data.Data = new string[] { ((float)fi.GetValue(effect) * level).ToString() }; } // For most AffectStat components, the only thing that is serialized is the AffectQuantity. else if (At.GetFieldInfo(type, "AffectQuantity") is FieldInfo fi_AffectQuantity) { data.Data = new string[] { ((float)fi_AffectQuantity.GetValue(effect) * level).ToString() }; } // AffectMana uses "Value" instead of AffectQuantity for some reason... else if (At.GetFieldInfo(type, "Value") is FieldInfo fi_Value) { data.Data = new string[] { ((float)fi_Value.GetValue(effect) * level).ToString() }; } else // otherwise maybe I need to add support for this effect... { //SL.Log("[StatusEffect] Unsupported effect: " + type, 1); } list.Add(data); } return(list.ToArray()); }