internal static void SetupCalculator(ChassisDef chassisDef, List <MechComponentRef> componentRefs)
        {
            if (chassisDef == null || chassisDef.HardpointDataDef == null || chassisDef.HardpointDataDef.HardpointData == null)
            {
                return;
            }

            if (componentRefs == null || componentRefs.Count == 0)
            {
                return;
            }

            componentRefs = componentRefs
                            .Where(c => c != null)
                            .Where(c => c.ComponentDefType == ComponentType.Weapon)
                            .Where(c => c.Def is WeaponDef)
                            .ToList();

            if (componentRefs.Count == 0)
            {
                return;
            }

            try
            {
                calculator = new WeaponComponentPrefabCalculator(chassisDef, componentRefs);
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }
        }
示例#2
0
        private int GetNotMappedPrefabNameCount(MechComponentRef newComponentRef)
        {
            var chassis  = _adapter.MechLab.activeMechDef.Chassis;
            var location = _adapter.Loadout.Location;

            var componentRefs = _adapter.LocalInventory
                                .Select(item => item.ComponentRef)
                                .Where(c => c.Def.ComponentType == ComponentType.Weapon)
                                .ToList();

            componentRefs.Add(newComponentRef);

            var calculator = new WeaponComponentPrefabCalculator(chassis, componentRefs, location);

            return(calculator.NotMappedPrefabNameCount);
        }
 internal static void ResetCalculator()
 {
     calculator = null;
 }