public static UnitSpawnPointOverride GetUnitToCopy(this LanceOverride lanceOverride)
    {
        if (lanceOverride.unitSpawnPointOverrideList.Count <= 0)
        {
            MissionControl.Main.LogDebug("[GetUnitToCopy] No UnitSpawnPointOverrides in lance. No unit to copy");
            return(null);
        }

        UnitSpawnPointOverride originalUnitSpawnPointOverride = lanceOverride.GetAnyTaggedLanceMember();

        // If there are only manual units - then select one at random from the Lance. Previously this selected copies of the first unit in the lance
        if (originalUnitSpawnPointOverride == null)
        {
            MissionControl.Main.LogDebug($"[LanceOverrideExtensions.GetUnitToCopy] Using '{MissionControl.Main.Settings.ExtendedLances.AutofillUnitCopyType}' to get unit to copy");
            if (MissionControl.Main.Settings.ExtendedLances.AutofillUnitCopyType == "FirstInLance")
            {
                originalUnitSpawnPointOverride = lanceOverride.unitSpawnPointOverrideList[0];
            }
            else // RandomInLance
            {
                originalUnitSpawnPointOverride = lanceOverride.GetRandomNonEmptyUnit();
            }
        }
        return(originalUnitSpawnPointOverride);
    }
Beispiel #2
0
        private void AddNewLanceMembers(ContractOverride contractOverride, TeamOverride teamOverride, LanceOverride lanceOverride, int numberOfUnitsInLance, int factionLanceSize)
        {
            for (int i = numberOfUnitsInLance; i < factionLanceSize; i++)
            {
                UnitSpawnPointOverride originalUnitSpawnPointOverride = lanceOverride.GetAnyTaggedLanceMember();
                if (originalUnitSpawnPointOverride == null)
                {
                    originalUnitSpawnPointOverride = lanceOverride.unitSpawnPointOverrideList[0];
                }
                UnitSpawnPointOverride unitSpawnPointOverride = originalUnitSpawnPointOverride.DeepCopy();
                TagSet companyTags = new TagSet(UnityGameInstance.BattleTechGame.Simulation.CompanyTags);

                unitSpawnPointOverride.GenerateUnit(MetadataDatabase.Instance, UnityGameInstance.Instance.Game.DataManager, lanceOverride.selectedLanceDifficulty, lanceOverride.name, null, i, DataManager.Instance.GetSimGameCurrentDate(), companyTags);
                lanceOverride.unitSpawnPointOverrideList.Add(unitSpawnPointOverride);
            }
        }
Beispiel #3
0
        private void AutofillWithTaggedOrFirstUnitOverrideSlots(TeamOverride teamOverride, LanceOverride lanceOverride, int numberOfUnitsInLanceOverride, int intendedLanceSize)
        {
            for (int i = numberOfUnitsInLanceOverride; i < intendedLanceSize; i++)
            {
                UnitSpawnPointOverride originalUnitSpawnPointOverride = lanceOverride.GetAnyTaggedLanceMember();

                if (originalUnitSpawnPointOverride == null)
                {
                    originalUnitSpawnPointOverride = lanceOverride.GetUnitToCopy();
                    Main.LogDebug($"[AddExtraLanceMembers] [{teamOverride.faction}] Autofill mode. Adding unit {i + 1} by duplicating an existing unit.");
                }
                else
                {
                    Main.LogDebug($"[AddExtraLanceMembers] [{teamOverride.faction}] Autofill mode. Adding unit {i + 1} by duplicating a 'Tagged' or 'Use Lance' lance member.");
                }

                UnitSpawnPointOverride unitSpawnPointOverride = originalUnitSpawnPointOverride.DeepCopy();
                unitSpawnPointOverride.customUnitName = "";
                Main.LogDebug($"[AddExtraLanceMembers] [{teamOverride.faction}] Using unit with old GUID '{originalUnitSpawnPointOverride.GUID}' and new GUID '{unitSpawnPointOverride.GUID}' unitDefId '{unitSpawnPointOverride.unitDefId}' as a base");

                lanceOverride.unitSpawnPointOverrideList.Add(unitSpawnPointOverride);
            }
        }
        private bool AreAnyLanceMembersTagged(LanceOverride lanceOverride)
        {
            UnitSpawnPointOverride unitSpawnOverrides = lanceOverride.GetAnyTaggedLanceMember();

            return(unitSpawnOverrides != null);
        }