コード例 #1
0
        private static void UpdateCULancesV1()
        {
            int lanceCount = 1;
            int mCount     = AdditionalMechSlots();

            while (mCount > 0)
            {
                lanceCount++;
                mCount -= 4;
            }
            int vCount = VehicleCount();

            while (vCount > 0)
            {
                lanceCount++;
                vCount -= 4;
            }
            int iBayCount = Math.Max(MinCuBays, companyStats.GetValue <int>("MechBayPods"));

            CustomUnitsAPI.setLancesCount(lanceCount);
            CustomUnitsAPI.setLanceData(0, DefaultMechSlots, DefaultMechSlots, false);
            int vStart = 1;

            mCount = AdditionalMechSlots();
            while (mCount > 0)
            {
                CustomUnitsAPI.setLanceData(vStart, DefaultMechSlots, mCount > DefaultMechSlots ? DefaultMechSlots : mCount, false);
                vStart++;
                mCount -= 4;
            }
            vCount = VehicleCount();
            while (vCount > 0)
            {
                CustomUnitsAPI.setLanceData(vStart, DefaultMechSlots, vCount > DefaultMechSlots ? DefaultMechSlots : vCount, true);
                vStart++;
                vCount -= 4;
            }
            int mechCount = DefaultMechSlots + AdditionalPlayerMechs();

            CustomUnitsAPI.setOverallDeployCount(System.Math.Min(DefaultMechSlots + AdditionalMechSlots() + VehicleCount(), BiggerDrops.settings.MAX_CU_DROP_SIZE));
            // Tanks can fit in either mech or tank slots so count their max drop as as the combine total of slots
            CustomUnitsAPI.playerControl(mechCount, VehicleCount() + mechCount);
            CustomUnitsAPI.setMechBayCount(iBayCount);
        }
コード例 #2
0
        private static void UpdateCULancesV2()
        {
            int UnitCount = 0;
            List <List <string> >      LanceLayout    = new List <List <string> >();
            List <string>              currentLance   = new List <string>();
            List <DropSlotDef>         separateLance  = new List <DropSlotDef>();
            List <DropSlotDef>         HotDrop        = new List <DropSlotDef>();
            List <List <DropSlotDef> > combinedLances = new List <List <DropSlotDef> >();

            foreach (string slotId in SlotOrder)
            {
                DropSlotDef def = CustomUnitsAPI.GetDropSlotDef(slotId);
                if (def != null)
                {
                    if (def.combineLanceWith.Count > 0)
                    {
                        bool bFound = false;
                        foreach (List <DropSlotDef> cLance in combinedLances)
                        {
                            foreach (DropSlotDef slot in cLance)
                            {
                                if (def.combineLanceWith.Contains(slot.Description.Id))
                                {
                                    bFound = true;
                                    break;
                                }
                            }
                            if (bFound)
                            {
                                cLance.Add(def);
                                break;
                            }
                        }

                        if (!bFound)
                        {
                            List <DropSlotDef> cLance = new List <DropSlotDef>();
                            cLance.Add(def);
                            combinedLances.Add(cLance);
                        }
                    }
                    else
                    {
                        if (def.SeparateLance || def.HotDrop)
                        {
                            if (def.HotDrop)
                            {
                                HotDrop.Add(def);
                            }
                            else
                            {
                                separateLance.Add(def);
                            }
                        }
                        else
                        {
                            int slotCount = companyStats.GetValue <int>(def.StatName);
                            UnitCount += slotCount;
                            for (int i = 0; i < slotCount; i++)
                            {
                                if (currentLance.Count >= BiggerDrops.settings.CuV2FormationSize)
                                {
                                    LanceLayout.Add(currentLance);
                                    currentLance = new List <string>();
                                }

                                currentLance.Add(slotId);
                            }
                        }
                    }
                }
            }

            if (currentLance.Count > 0)
            {
                LanceLayout.Add(currentLance);
            }

            foreach (List <DropSlotDef> cLance in combinedLances)
            {
                currentLance = new List <string>();
                foreach (DropSlotDef def in cLance)
                {
                    int slotCount = companyStats.GetValue <int>(def.StatName);
                    UnitCount += slotCount;
                    for (int i = 0; i < slotCount; i++)
                    {
                        if (currentLance.Count >= BiggerDrops.settings.CuV2FormationSize)
                        {
                            LanceLayout.Add(currentLance);
                            currentLance = new List <string>();
                        }
                        currentLance.Add(def.Description.Id);
                    }
                }
                if (currentLance.Count > 0)
                {
                    LanceLayout.Add(currentLance);
                }
            }

            foreach (DropSlotDef def in separateLance)
            {
                currentLance = new List <string>();
                int slotCount = companyStats.GetValue <int>(def.StatName);
                UnitCount += slotCount;
                for (int i = 0; i < slotCount; i++)
                {
                    if (currentLance.Count >= BiggerDrops.settings.CuV2FormationSize)
                    {
                        LanceLayout.Add(currentLance);
                        currentLance = new List <string>();
                    }
                    currentLance.Add(def.Description.Id);
                }
                if (currentLance.Count > 0)
                {
                    LanceLayout.Add(currentLance);
                }
            }

            currentLance = new List <string>();
            foreach (DropSlotDef def in HotDrop)
            {
                int slotCount = companyStats.GetValue <int>(def.StatName);
                UnitCount += slotCount;
                for (int i = 0; i < slotCount; i++)
                {
                    if (currentLance.Count >= BiggerDrops.settings.CuV2FormationSize)
                    {
                        LanceLayout.Add(currentLance);
                        currentLance = new List <string>();
                    }
                    currentLance.Add(def.Description.Id);
                }
            }
            if (currentLance.Count > 0)
            {
                LanceLayout.Add(currentLance);
            }
            CustomUnitsAPI.PushDropLayout(CustomUnitsAPI.BIGGER_DROPS_LAYOUT_ID, LanceLayout, UnitCount, new List <string>()
            {
                "Lance A", "Lance B", "Lance C"
            });
            int iBayCount = Math.Max(MinCuBays, companyStats.GetValue <int>("MechBayPods"));

            CustomUnitsAPI.setMechBayCount(iBayCount);
        }