1
0
Fork 0

Add debug-only ability to change weights of tracks while on a moon

And drop obsoleted debug code. With the new on-the-fly track weights
configuration, hardcoding one in build is not necessary anymore.
This commit is contained in:
ivan tkachenko 2025-07-15 23:23:23 +03:00
parent 829c44e347
commit 0d4f180a37
1 changed files with 2 additions and 9 deletions

View File

@ -68,21 +68,12 @@ namespace MuzikaGromche
} }
]; ];
public static int IndexOfTrack(string trackName)
{
return Array.FindIndex(Tracks, track => track.Name == trackName);
}
public static Track ChooseTrack() public static Track ChooseTrack()
{ {
var seed = RoundManager.Instance.dungeonGenerator.Generator.ChosenSeed; var seed = RoundManager.Instance.dungeonGenerator.Generator.ChosenSeed;
int[] weights = [.. Tracks.Select(track => track.Weight.Value)]; int[] weights = [.. Tracks.Select(track => track.Weight.Value)];
var rwi = new RandomWeightedIndex(weights); var rwi = new RandomWeightedIndex(weights);
var trackId = rwi.GetRandomWeightedIndex(seed); var trackId = rwi.GetRandomWeightedIndex(seed);
#if DEBUG
// Override for testing
// trackId = IndexOfTrack("DeployDestroy");
#endif
var track = Tracks[trackId]; var track = Tracks[trackId];
Debug.Log($"Seed is {seed}, chosen track is \"{track.Name}\", #{trackId} of {rwi}"); Debug.Log($"Seed is {seed}, chosen track is \"{track.Name}\", #{trackId} of {rwi}");
return Tracks[trackId]; return Tracks[trackId];
@ -412,10 +403,12 @@ namespace MuzikaGromche
{ {
return CanModifyResult.False("Only for host"); return CanModifyResult.False("Only for host");
} }
#if !DEBUG // Changing tracks on the fly might lead to a desync. But it may speed up development process
if (!startOfRound.inShipPhase) if (!startOfRound.inShipPhase)
{ {
return CanModifyResult.False("Only while orbiting"); return CanModifyResult.False("Only while orbiting");
} }
#endif
return CanModifyResult.True(); return CanModifyResult.True();
} }