private static void Postfix(MechLabPanel __instance) { try { var newMechDef = __instance.activeMechDef; var sim = UnityGameInstance.BattleTechGame.Simulation; var inventory = newMechDef?.Inventory; for (var index = 0; index < inventory?.Length; index++) { var mechComponentRef = inventory[index]; if (mechComponentRef != null) { var loc = mechComponentRef.Def?.AllowedLocations & mechComponentRef.MountedLocation; if (loc != mechComponentRef.MountedLocation) { var componentInstallWorkOrder = sim.CreateComponentInstallWorkOrder( newMechDef.GUID, mechComponentRef, ChassisLocations.None, mechComponentRef.MountedLocation); componentInstallWorkOrder.Parent = componentInstallWorkOrder; componentInstallWorkOrder.CBillCost = 0; sim.MoveWorkOrderItemsToQueue(componentInstallWorkOrder); __instance.pendingWorkOrders.Add(componentInstallWorkOrder); __instance.ApplyWorkOrder(componentInstallWorkOrder); __instance.DoConfirmRefit(); var popup = GenericPopupBuilder.Create(GenericPopupType.Info, $"Component removed from invalid location and placed in storage.\n{mechComponentRef.Def.Description.Name} in {mechComponentRef.MountedLocation}"); popup.AddButton("Understood"); popup.Render(); } } } } catch (Exception ex) { FileLog.Log(ex.ToString()); } // non-working prototype to display the view distance on the mechlab based on equipped rangefinder //FileLog.Log("PING"); //LocalizableText component = ___obj_mech.FindFirstChildNamed("uixPrfPanl_ML_main-Widget(Clone)").FindFirstChildNamed("Centerline").FindFirstChildNamed("uixPrfPanl_ML_location-Widget-MANAGED") // .FindFirstChildNamed("txt_location") // .GetComponent<LocalizableText>(); //FileLog.Log(component.text); //IEnumerable<MechComponentRef> enumerable = ___activeMechInventory.Where((MechComponentRef x) => x.Def.statusEffects.Any((EffectData y) => y.statisticData.statName == "SpotterDistanceAbsolute")); //float num = 0f; //FileLog.Log("Rangefinders: " + enumerable.Count()); //foreach (MechComponentRef item in enumerable) //{ // StatisticEffectData statisticData = item.Def.statusEffects.First((EffectData x) => x.statisticData.statName == "SpotterDistanceAbsolute").statisticData; // StatCollection.StatOperation operation = statisticData.operation; // FileLog.Log(operation.ToString()); // int num2 = Convert.ToInt32(statisticData.modValue); // FileLog.Log(num2.ToString()); // switch (operation) // { // case StatCollection.StatOperation.Float_Add: // num += (float)num2; // break; // case StatCollection.StatOperation.Float_Subtract: // num -= (float)num2; // break; // } //} //FileLog.Log(num.ToString()); //string arg = null; //if (num > 0f) //{ // arg = $"+{num}m"; //} //else if (num < 0f) //{ // arg = $"-{num}m"; //} //component.SetText($"{component} {arg}"); }