-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MonsterWaveModifier.cs
48 lines (37 loc) · 1.93 KB
/
MonsterWaveModifier.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
namespace Dawn.DMD.LongerGames;
using Death.Run.Systems;
using Death.Run.Systems.Spawning;
public static class MonsterWaveModifier
{
public static void OnRunStart(Facade_Run run)
{
// If the value is 0, we reset the game length to 20mins
var gameLength = GameLengthMinutesConfig.Value == 0 ? 20 : GameLengthMinutesConfig.Value;
var defaultGameLength = run.Options.WaveData.Last().BeginTimeSec / 60;
var gameLengthMultiplier = (float)gameLength / defaultGameLength;
ModLogger.LogDebug($"New run started! The game length multiplier is '{Math.Round(gameLengthMultiplier, 2)}'");
for (var index = 0; index < run.Options.WaveData.Count; index++)
{
var wave = run.Options.WaveData[index];
if (wave.Mode == WaveData.EventMode.CustomEvent)
HandleBossFight(run, index, wave, gameLengthMultiplier);
wave.BeginTimeSec = (int)(wave.BeginTimeSec * gameLengthMultiplier);
wave.EndTimeSec = (int)(wave.EndTimeSec * gameLengthMultiplier);
}
}
private static void HandleBossFight(Facade_Run run, int index, WaveData.Event wave, float gameLengthMultiplier)
{
var nextWave = index + 1 < run.Options.WaveData.Count ? run.Options.WaveData[index + 1] : null;
var priorBeginTime = wave.BeginTimeSec;
var newBeginTime = priorBeginTime * gameLengthMultiplier;
var eventName = GenerateEventName(wave.EndOnMonsterKills, nextWave);
ModLogger.LogDebug(
$"{eventName} - BeginTime: {Math.Round(priorBeginTime / 60f, 2)} mins -> {Math.Round(newBeginTime / 60f, 2)} mins");
}
private static string GenerateEventName(string[] UniqueMonsters, WaveData.Event? nextWave)
{
if (UniqueMonsters.Length == 0 && nextWave != null)
return $"[ {nextWave.MonsterCode} ] Event";
return $"[ {string.Join(", ", UniqueMonsters)} ] Event";
}
}