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( MechDef ___selectedMech, TextMeshProUGUI ___ballisticHardpointText, TextMeshProUGUI ___energyHardpointText, TextMeshProUGUI ___missileHardpointText, TextMeshProUGUI ___smallHardpointText) { try { if (___selectedMech == null) { return; } var inventory = ___selectedMech.Inventory.Select(x => x.Def); var hardpoints = MechDefBuilder.Locations.SelectMany(x => ___selectedMech.Chassis.GetLocationDef(x).Hardpoints).ToArray(); var calc = new HardpointOmniUsageCalculator(inventory, hardpoints); Control.Logger.Debug?.Log(calc); ___ballisticHardpointText.SetText(calc.Ballistic.HardpointString); ___energyHardpointText.SetText(calc.Energy.HardpointString); ___missileHardpointText.SetText(calc.Missile.HardpointString); ___smallHardpointText.SetText(calc.Small.HardpointString); } catch (Exception e) { Control.Logger.Error.Log(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(WeaponCategory.Ballistic, calc.Ballistic.HardpointTotalString); ___hardpoints[1].SetData(WeaponCategory.Energy, calc.Energy.HardpointTotalString); ___hardpoints[2].SetData(WeaponCategory.Missile, calc.Missile.HardpointTotalString); ___hardpoints[3].SetData(WeaponCategory.AntiPersonnel, calc.Small.HardpointTotalString); } catch (Exception e) { Control.mod.Logger.LogError(e); } }
internal static void Postfix( MechLabLocationWidget __instance, ref LocationDef ___chassisLocationDef, ref int ___currentBallisticCount, ref int ___currentEnergyCount, ref int ___currentMissileCount, ref int ___currentSmallCount, ref int ___totalBallisticHardpoints, ref int ___totalEnergyHardpoints, ref int ___totalMissileHardpoints, ref int ___totalSmallHardpoints, ref MechLabHardpointElement[] ___hardpoints, ref List <MechLabItemSlotElement> ___localInventory) { try { var inventory = ___localInventory.Select(x => x.ComponentRef.Def); var hardpoints = ___chassisLocationDef.Hardpoints; if (hardpoints == null) { // how can this happen? is this from the properties widget? //Control.mod.Logger.LogDebug($"hardpoints is null in location={__instance.loadout?.Location}"); return; } var calc = new HardpointOmniUsageCalculator(inventory, hardpoints); //Control.mod.Logger.Log(calc); ___currentBallisticCount = calc.Ballistic.VanillaUsage; ___currentEnergyCount = calc.Energy.VanillaUsage; ___currentMissileCount = calc.Missile.VanillaUsage; ___currentSmallCount = calc.Small.VanillaUsage; ___totalBallisticHardpoints = calc.Ballistic.DynamicMax; ___totalEnergyHardpoints = calc.Energy.DynamicMax; ___totalMissileHardpoints = calc.Missile.DynamicMax; ___totalSmallHardpoints = calc.Small.DynamicMax; ___hardpoints[0].SetData(calc.Ballistic.CategoryForLocationWidget, calc.Ballistic.HardpointString); ___hardpoints[1].SetData(calc.Energy.CategoryForLocationWidget, calc.Energy.HardpointString); ___hardpoints[2].SetData(calc.Missile.CategoryForLocationWidget, calc.Missile.HardpointString); ___hardpoints[3].SetData(calc.Small.CategoryForLocationWidget, calc.Small.HardpointString); } catch (Exception e) { Control.mod.Logger.LogError(e); } }