public static bool Prefix(AmmunitionDef __instance, ref string json) { CustomAmmoCategoriesLog.Log.LogWrite("AmmunitionDef fromJSON "); JObject defTemp = JObject.Parse(json); CustomAmmoCategoriesLog.Log.LogWrite(defTemp["Description"]["Id"] + "\n"); CustomAmmoCategory custCat = CustomAmmoCategories.find((string)defTemp["Category"]); //CustomAmmoCategories.RegisterAmmunition((string)defTemp["Description"]["Id"], custCat); defTemp["Category"] = custCat.BaseCategory.ToString(); ExtAmmunitionDef extAmmoDef = new ExtAmmunitionDef(); extAmmoDef.AmmoCategory = custCat; if (defTemp["AccuracyModifier"] != null) { extAmmoDef.AccuracyModifier = (float)defTemp["AccuracyModifier"]; defTemp.Remove("AccuracyModifier"); } if (defTemp["DamagePerShot"] != null) { extAmmoDef.DamagePerShot = (float)defTemp["DamagePerShot"]; defTemp.Remove("DamagePerShot"); } if (defTemp["HeatDamagePerShot"] != null) { extAmmoDef.HeatDamagePerShot = (float)defTemp["HeatDamagePerShot"]; defTemp.Remove("HeatDamagePerShot"); } if (defTemp["ProjectilesPerShot"] != null) { extAmmoDef.ProjectilesPerShot = (int)defTemp["ProjectilesPerShot"]; defTemp.Remove("ProjectilesPerShot"); } if (defTemp["ShotsWhenFired"] != null) { extAmmoDef.ShotsWhenFired = (int)defTemp["ShotsWhenFired"]; defTemp.Remove("ShotsWhenFired"); } if (defTemp["CriticalChanceMultiplier"] != null) { extAmmoDef.CriticalChanceMultiplier = (float)defTemp["CriticalChanceMultiplier"]; defTemp.Remove("CriticalChanceMultiplier"); } if (defTemp["AIBattleValue"] != null) { extAmmoDef.AIBattleValue = (int)defTemp["AIBattleValue"]; defTemp.Remove("AIBattleValue"); } if (defTemp["MinRange"] != null) { extAmmoDef.MinRange = (float)defTemp["MinRange"]; defTemp.Remove("MinRange"); } if (defTemp["MaxRange"] != null) { extAmmoDef.MaxRange = (float)defTemp["MaxRange"]; defTemp.Remove("MaxRange"); } if (defTemp["ShortRange"] != null) { extAmmoDef.ShortRange = (float)defTemp["ShortRange"]; defTemp.Remove("ShortRange"); } if (defTemp["MediumRange"] != null) { extAmmoDef.MediumRange = (float)defTemp["MediumRange"]; defTemp.Remove("MediumRange"); } if (defTemp["LongRange"] != null) { extAmmoDef.LongRange = (float)defTemp["LongRange"]; defTemp.Remove("LongRange"); } if (defTemp["ForbiddenRange"] != null) { extAmmoDef.ForbiddenRange = (float)defTemp["ForbiddenRange"]; defTemp.Remove("ForbiddenRange"); } if (defTemp["RefireModifier"] != null) { extAmmoDef.RefireModifier = (int)defTemp["RefireModifier"]; defTemp.Remove("RefireModifier"); } if (defTemp["Instability"] != null) { extAmmoDef.Instability = (float)defTemp["Instability"]; defTemp.Remove("Instability"); } if (defTemp["AttackRecoil"] != null) { extAmmoDef.AttackRecoil = (int)defTemp["AttackRecoil"]; defTemp.Remove("AttackRecoil"); } if (defTemp["WeaponEffectID"] != null) { extAmmoDef.WeaponEffectID = (string)defTemp["WeaponEffectID"]; defTemp.Remove("WeaponEffectID"); } if (defTemp["EvasivePipsIgnored"] != null) { extAmmoDef.EvasivePipsIgnored = (float)defTemp["EvasivePipsIgnored"]; defTemp.Remove("EvasivePipsIgnored"); } if (defTemp["FlatJammingChance"] != null) { extAmmoDef.FlatJammingChance = (float)defTemp["FlatJammingChance"]; defTemp.Remove("FlatJammingChance"); } if (defTemp["GunneryJammingBase"] != null) { extAmmoDef.GunneryJammingBase = (float)defTemp["GunneryJammingBase"]; defTemp.Remove("GunneryJammingBase"); } if (defTemp["GunneryJammingMult"] != null) { extAmmoDef.GunneryJammingMult = (float)defTemp["GunneryJammingMult"]; defTemp.Remove("GunneryJammingMult"); } if (defTemp["IndirectFireCapable"] != null) { extAmmoDef.IndirectFireCapable = ((bool)defTemp["IndirectFireCapable"] == true) ? TripleBoolean.True : TripleBoolean.False; defTemp.Remove("IndirectFireCapable"); } if (defTemp["DirectFireModifier"] != null) { extAmmoDef.DirectFireModifier = (float)defTemp["DirectFireModifier"]; defTemp.Remove("DirectFireModifier"); } if (defTemp["AOECapable"] != null) { extAmmoDef.AOECapable = ((bool)defTemp["AOECapable"] == true) ? TripleBoolean.True : TripleBoolean.False; defTemp.Remove("AOECapable"); } if (defTemp["DistantVariance"] != null) { extAmmoDef.DistantVariance = (float)defTemp["DistantVariance"]; defTemp.Remove("DistantVariance"); } if (defTemp["AlwaysIndirectVisuals"] != null) { extAmmoDef.AlwaysIndirectVisuals = ((bool)defTemp["AlwaysIndirectVisuals"] == true) ? TripleBoolean.True : TripleBoolean.False; defTemp.Remove("AlwaysIndirectVisuals"); } if (defTemp["DamageMultiplier"] != null) { extAmmoDef.DamageMultiplier = (float)defTemp["DamageMultiplier"]; defTemp.Remove("DamageMultiplier"); } if (defTemp["DistantVarianceReversed"] != null) { extAmmoDef.DistantVarianceReversed = ((bool)defTemp["DistantVarianceReversed"] == true) ? TripleBoolean.True : TripleBoolean.False; defTemp.Remove("DistantVarianceReversed"); } if (defTemp["DamageVariance"] != null) { extAmmoDef.DamageVariance = (float)defTemp["DamageVariance"]; defTemp.Remove("DamageVariance"); } if (defTemp["HitGenerator"] != null) { try { extAmmoDef.HitGenerator = (HitGeneratorType)Enum.Parse(typeof(HitGeneratorType), (string)defTemp["HitGenerator"], true); } catch (Exception e) { extAmmoDef.HitGenerator = HitGeneratorType.NotSet; } defTemp.Remove("HitGenerator"); } if (defTemp["statusEffects"] != null) { if (defTemp["statusEffects"].Type == JTokenType.Array) { List <EffectData> tmpList = new List <EffectData>(); JToken statusEffects = defTemp["statusEffects"]; foreach (JObject statusEffect in statusEffects) { EffectData effect = new EffectData(); JSONSerializationUtility.FromJSON <EffectData>(effect, statusEffect.ToString()); tmpList.Add(effect); } extAmmoDef.statusEffects = tmpList.ToArray(); } //extAmmoDef.statusEffects = JsonConvert.DeserializeObject<EffectData[]>(defTemp["statusEffects"].ToString()); //JSONSerializationUtility.FromJSON<EffectData[]>(extAmmoDef.statusEffects, defTemp["statusEffects"].ToString()); //CustomAmmoCategoriesLog.Log.LogWrite(JsonConvert.SerializeObject(extAmmoDef.statusEffects)+"\n"); defTemp.Remove("statusEffects"); } CustomAmmoCategories.RegisterExtAmmoDef((string)defTemp["Description"]["Id"], extAmmoDef); json = defTemp.ToString(); return(true); }