public static bool IsCrossAssemblyExcluded(this MechDef d)
        {
            if (!Settings.UseOnlyCCAssemblyOptions)
            {
                if (Settings.CrossAssemblyExcludedMechs.Contains(d.Description.Id))
                {
                    return(true);
                }
                if (d.Chassis.ChassisTags.Contains("chassis_ExcludeCrossAssembly"))
                {
                    return(true);
                }
            }
            if (d.IsVehicle())
            {
                VehicleChassisDef vd = d.Chassis.GetVehicleChassisDefFromFakeVehicle();
                if (vd == null)
                {
                    return(false);
                }
                IVAssemblyVariant vv = CCIntegration.GetCCVehicleAssemblyVariant(vd);
                if (vv == null)
                {
                    return(false);
                }
                return(vv.Exclude);
            }
            IAssemblyVariant v = CCIntegration.GetCCAssemblyVariant(d.Chassis);

            if (v != null)
            {
                return(v.Exclude);
            }
            return(false);
        }
        public static bool get_vehicle_custom(MechDef mech, ref IAssemblyVariant __result)
        {
            if (!mech.IsVehicle())
            {
                return(true);
            }

            string id      = mech.Description.Id;
            var    vehicle = UnityGameInstance.BattleTechGame.Simulation.DataManager.VehicleDefs.Get(id);

            if (vehicle != null)
            {
                __result = vehicle.Chassis.GetComponent <VAssemblyVariant>();
            }

            return(false);
        }
        public static bool IsVariantKnown(SimGameState s, MechDef d)
        {
            if (!Settings.UseOnlyCCAssemblyOptions)
            {
                if (d.Chassis.ChassisTags.Contains("chassis_KnownOmniVariant"))
                {
                    return(true);
                }
            }
            IAssemblyVariant v = CCIntegration.GetCCAssemblyVariant(d.Chassis);

            if (v != null)
            {
                if (v.KnownOmniVariant)
                {
                    return(true);
                }
            }
            foreach (KeyValuePair <int, MechDef> a in s.ActiveMechs)
            {
                if (d.ChassisID == a.Value.ChassisID)
                {
                    return(true);
                }
            }
            foreach (KeyValuePair <int, MechDef> a in s.ReadyingMechs)
            {
                if (d.ChassisID == a.Value.ChassisID)
                {
                    return(true);
                }
            }
            string id = s.GetItemStatID(d.Description.Id, "MECHPART");

            if (s.CompanyStats.ContainsStatistic(id))
            {
                return(true);
            }
            id = s.GetItemStatID(d.Chassis.Description, d.GetType());
            if (s.CompanyStats.ContainsStatistic(id))
            {
                return(true);
            }
            return(false);
        }
        public static MechDef GetSalvageRedirect(SimGameState s, MechDef m)
        {
            if (!SimpleMechAssembly_Main.Settings.UseOnlyCCAssemblyOptions)
            {
                if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageMechPartSalvageRedirect.TryGetValue(m.Description.Id, out string red))
                {
                    if (s.DataManager.MechDefs.TryGet(red, out MechDef n) && n != null)
                    {
                        SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (settings): {m.Description.Id}->{red}");
                        return(n);
                    }
                }
                string c = m.MechTags.FirstOrDefault((x) => x.StartsWith("mech_MechPartSalvageRedirect_"));
                if (c != null)
                {
                    c = c.Replace("mech_MechPartSalvageRedirect_", "");
                    if (s.DataManager.MechDefs.TryGet(c, out MechDef n) && n != null)
                    {
                        SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (tag): {m.Description.Id}->{c}");
                        return(n);
                    }
                }
            }
            IAssemblyVariant v = CCIntegration.GetCCAssemblyVariant(m.Chassis);

            if (v != null && v.Lootable != null)
            {
                if (s.DataManager.MechDefs.TryGet(v.Lootable, out MechDef o))
                {
                    SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (lootable): {m.Description.Id}->{v.Lootable}");
                    return(o);
                }
            }
            if (!SimpleMechAssembly_Main.Settings.AllowNonMainVariants && !m.IsMechDefMain())
            {
                MechDef ma = m.Chassis.GetMainMechDef(s.DataManager);
                if (ma != null)
                {
                    SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (main): {m.Description.Id}->{ma.Description.Id}");
                    return(ma);
                }
            }
            return(m);
        }
        public static bool IsCrossAssemblyOverrideEnabled(MechDef a, MechDef b, string va, string vb)
        {
            if (!Settings.UseOnlyCCAssemblyOptions)
            {
                if (a.Chassis.ChassisTags.Contains($"chassis_CrossAssemblyAllowedWith_{vb}"))
                {
                    return(true);
                }
                if (b.Chassis.ChassisTags.Contains($"chassis_CrossAssemblyAllowedWith_{va}"))
                {
                    return(true);
                }
                if (a.Chassis.ChassisTags.Contains($"chassis_CrossAssemblyAllowedWith_{b.Chassis.VariantName}"))
                {
                    return(true);
                }
                if (b.Chassis.ChassisTags.Contains($"chassis_CrossAssemblyAllowedWith_{a.Chassis.VariantName}"))
                {
                    return(true);
                }
                if (a.Chassis.ChassisTags.Contains($"chassis_CrossAssemblyAllowedWith_{b.Description.Id}"))
                {
                    return(true);
                }
                if (b.Chassis.ChassisTags.Contains($"chassis_CrossAssemblyAllowedWith_{a.Description.Id}"))
                {
                    return(true);
                }
            }
            IAssemblyVariant av = CCIntegration.GetCCAssemblyVariant(a.Chassis);

            if (av != null && av.AssemblyAllowedWith != null)
            {
                if (av.AssemblyAllowedWith.Contains(vb))
                {
                    return(true);
                }
                if (av.AssemblyAllowedWith.Contains(b.Chassis.VariantName))
                {
                    return(true);
                }
                if (av.AssemblyAllowedWith.Contains(b.Description.Id))
                {
                    return(true);
                }
            }
            IAssemblyVariant bv = CCIntegration.GetCCAssemblyVariant(b.Chassis);

            if (bv != null && bv.AssemblyAllowedWith != null)
            {
                if (bv.AssemblyAllowedWith.Contains(va))
                {
                    return(true);
                }
                if (bv.AssemblyAllowedWith.Contains(a.Chassis.VariantName))
                {
                    return(true);
                }
                if (bv.AssemblyAllowedWith.Contains(a.Description.Id))
                {
                    return(true);
                }
            }
            return(false);
        }