Skip to content

Commit

Permalink
Allows Siege Maps in Mapcycle
Browse files Browse the repository at this point in the history
- Chooses the highest priority game mode for the given level (usually this will be MP_Strategy or MP_Siege)
- Note that "Brenn's Chasm" shows up as mapname "RiftBasin_TD" in the current beta, so this mapname would needed to be added to the mapcycle
  • Loading branch information
data-bomb committed Nov 10, 2024
1 parent 9a92b60 commit a75d7bc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Si_Mapcycle/Si_Mapcycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You should have received a copy of the GNU General Public License
using System.Linq;
using UnityEngine;

[assembly: MelonInfo(typeof(MapCycleMod), "Mapcycle", "1.6.3", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(MapCycleMod), "Mapcycle", "1.6.4", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

Expand Down Expand Up @@ -703,6 +703,11 @@ public static void Prefix(MusicJukeboxHandler __instance, GameMode __0)

private static GameModeInfo? GetGameModeInfo(LevelInfo levelInfo)
{
// the highest priority for any given level is the preferred mode
// currently this should resolve to MP_Strategy or MP_Siege for most maps
int highestPriority = -1;
GameModeInfo? priorityGameMode = null;

foreach (GameModeInfo gameModeInfo in levelInfo.GameModes)
{
if (gameModeInfo == null)
Expand All @@ -715,15 +720,15 @@ public static void Prefix(MusicJukeboxHandler __instance, GameMode __0)
continue;
}

MelonLogger.Msg("Found gameModeInfo name: " + gameModeInfo.ObjectName);

if (String.Equals("MP_Strategy", gameModeInfo.ObjectName, StringComparison.OrdinalIgnoreCase))
if (highestPriority < gameModeInfo.Priority)
{
return gameModeInfo;
highestPriority = gameModeInfo.Priority;
priorityGameMode = gameModeInfo;
}
}

return null;
MelonLogger.Msg("Found highest priority gameMode: " + priorityGameMode?.ObjectName ?? "null");
return priorityGameMode;
}

private static bool IsMapNameValid(string mapName)
Expand Down

0 comments on commit a75d7bc

Please sign in to comment.