Beispiel #1
0
 public static void Prefix(MechComponentDef __instance, ref string json)
 {
     try {
         JObject content = JObject.Parse(json);
         if (content["Auras"] != null)
         {
             Log.Debug?.Write("Auras WeaponDef:" + content["Description"]["Id"] + "\n");
             if (content["Auras"].Type == JTokenType.Array)
             {
                 List <AuraDef> auras  = new List <AuraDef>();
                 JToken         jauras = content["Auras"];
                 foreach (JObject jaura in jauras)
                 {
                     AuraDef aura = JsonConvert.DeserializeObject <AuraDef>(jaura.ToString());
                     if (jaura["statusEffects"] != null)
                     {
                         if (jaura["statusEffects"].Type == JTokenType.Array)
                         {
                             JToken statusEffects = jaura["statusEffects"];
                             aura.statusEffects = new List <EffectData>();
                             foreach (JObject statusEffect in statusEffects)
                             {
                                 EffectData effect = new EffectData();
                                 JSONSerializationUtility.FromJSON <EffectData>(effect, statusEffect.ToString());
                                 aura.statusEffects.Add(effect);
                             }
                         }
                     }
                     auras.Add(aura);
                 }
                 __instance.AddAuras(auras);
             }
             content.Remove("Auras");
         }
         json = content.ToString();
     } catch (Exception e) {
         Log.Debug?.Write("Error:" + e.ToString() + "\n");
         Log.Debug?.Write("IN:" + json + "\n");
     }
 }