public static void Postfix(MechLabInventoryWidget __instance, float ___mechTonnage,
                                   List <InventoryItemElement_NotListView> ___localInventory)
        {
            foreach (var item in ___localInventory)
            {
                MechComponentDef component = null;

                if (item.controller != null)
                {
                    component = item.controller.componentDef;
                }
                else if (item.ComponentRef != null)
                {
                    component = item.ComponentRef.Def;
                }

                if (component != null && component.IsStructure())
                {
                    var tonnage = component.GetStructureWeight();
//                    Control.mod.Logger.Log(string.Format("[{0}] found structure {1} {2}/{3}", Time.realtimeSinceStartup,
//                       component.Description.Id, tonnage, ___mechTonnage));
                    item.gameObject.SetActive(
                        (___mechTonnage < 0 ||
                         ___mechTonnage == tonnage) && item.gameObject.activeSelf
                        );
                }
            }
        }
예제 #2
0
        internal static void AdjustTooltip(TooltipPrefab_Equipment tooltip, MechLabPanel panel, MechComponentDef mechComponentDef)
        {
            if (!mechComponentDef.IsStructure())
            {
                return;
            }

            var calculator = new StructureWeightSavingCalculator(panel.activeMechDef);
            var tonnage    = calculator.WeightSavings;

            tooltip.bonusesText.text = string.Format("- {0} ton,  {1} / {2}", tonnage, calculator.Count, calculator.RequiredCount);
        }
예제 #3
0
        internal static int GetStructureWeight(this MechComponentDef componentDef)
        {
            if (componentDef == null || !componentDef.IsStructure())
            {
                return(0);
            }

            try
            {
                var str = componentDef.Description.Id.Substring(componentDef.Description.Id.Length - 3, 3);
                if (str[0] == '_')
                {
                    return(int.Parse(str.Substring(1, 2)));
                }
                else
                {
                    return(int.Parse(str));
                }
            }
            catch (Exception e)
            {
                return(0);
            }
        }