internal static void Postfix( MechDef mechDef, MechLabHardpointElement ___BallisticHardPointElement, MechLabHardpointElement ___EnergyHardPointElement, MechLabHardpointElement ___MissileHardPointElement, MechLabHardpointElement ___SmallHardPointElement) { try { if (mechDef == null) { return; } var inventory = mechDef.Inventory.Select(x => x.Def); var hardpoints = MechDefBuilder.Locations.SelectMany(x => mechDef.Chassis.GetLocationDef(x).Hardpoints).ToArray(); var calc = new HardpointOmniUsageCalculator(inventory, hardpoints); //Control.mod.Logger.Log(calc); ___BallisticHardPointElement.SetData(WeaponCategoryEnumeration.GetBallistic(), calc.Ballistic.HardpointString); ___EnergyHardPointElement.SetData(WeaponCategoryEnumeration.GetEnergy(), calc.Energy.HardpointString); ___MissileHardPointElement.SetData(WeaponCategoryEnumeration.GetMissile(), calc.Missile.HardpointString); ___SmallHardPointElement.SetData(WeaponCategoryEnumeration.GetSupport(), calc.Small.HardpointString); } catch (Exception e) { Control.mod.Logger.LogError(e); } }
internal static void Postfix( MechLabMechInfoWidget __instance, ref MechLabPanel ___mechLab, ref MechLabHardpointElement[] ___hardpoints) { try { var mechDef = ___mechLab.activeMechDef; if (mechDef == null) { return; } var inventory = mechDef.Inventory.Select(x => x.Def); var hardpoints = MechDefBuilder.Locations.SelectMany(x => mechDef.Chassis.GetLocationDef(x).Hardpoints).ToArray(); var calc = new HardpointOmniUsageCalculator(inventory, hardpoints); //Control.mod.Logger.Log(calc); __instance.totalBallisticHardpoints = calc.Ballistic.TheoreticalMax; __instance.totalEnergyHardpoints = calc.Energy.TheoreticalMax; __instance.totalMissileHardpoints = calc.Missile.TheoreticalMax; __instance.totalSmallHardpoints = calc.Small.TheoreticalMax; ___hardpoints[0].SetData(WeaponCategoryEnumeration.GetBallistic(), calc.Ballistic.HardpointTotalString); ___hardpoints[1].SetData(WeaponCategoryEnumeration.GetEnergy(), calc.Energy.HardpointTotalString); ___hardpoints[2].SetData(WeaponCategoryEnumeration.GetMissile(), calc.Missile.HardpointTotalString); ___hardpoints[3].SetData(WeaponCategoryEnumeration.GetSupport(), calc.Small.HardpointTotalString); } catch (Exception e) { Control.mod.Logger.LogError(e); } }
internal HardpointOmniUsageCalculator(IEnumerable <MechComponentDef> items, HardpointDef[] hardpoints) { stats[WeaponCategoryEnumeration.GetBallistic()] = new HardpointStat(WeaponCategoryEnumeration.GetBallistic()); stats[WeaponCategoryEnumeration.GetEnergy()] = new HardpointStat(WeaponCategoryEnumeration.GetEnergy()); stats[WeaponCategoryEnumeration.GetMissile()] = new HardpointStat(WeaponCategoryEnumeration.GetMissile()); stats[WeaponCategoryEnumeration.GetSupport()] = new HardpointStat(WeaponCategoryEnumeration.GetSupport()); SetUsage(items); SetMax(hardpoints); }
internal static WeaponCategoryValue MapToBasicType(WeaponCategoryValue value) { if (value.IsBallistic) { return(WeaponCategoryEnumeration.GetBallistic()); } else if (value.IsEnergy) { return(WeaponCategoryEnumeration.GetEnergy()); } else if (value.IsMissile) { return(WeaponCategoryEnumeration.GetMissile()); } else if (value.IsSupport) { return(WeaponCategoryEnumeration.GetSupport()); } else { throw new System.Exception("nope"); } }
internal static WeaponCategoryValue MapToBasicType(WeaponCategoryValue value) { if (value.IsBallistic) { return(WeaponCategoryEnumeration.GetBallistic()); } else if (value.IsEnergy) { return(WeaponCategoryEnumeration.GetEnergy()); } else if (value.IsMissile) { return(WeaponCategoryEnumeration.GetMissile()); } else if (value.IsSupport) { return(WeaponCategoryEnumeration.GetSupport()); } else { Control.mod.Logger.LogWarning($"Unsupported weapon category for {value.ID}"); return(WeaponCategoryEnumeration.GetNotSetValue()); } }