Skip to content

Commit

Permalink
Fix population not being set and error
Browse files Browse the repository at this point in the history
  • Loading branch information
brgmnn committed Jul 20, 2024
1 parent 545ded2 commit 80b6e17
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 9 deletions.
34 changes: 34 additions & 0 deletions AutogenRundown/src/DataBlocks/Alarms/WavePopulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ public static void Setup()
{
var pack = new List<(double, int, WavePopulation)>();

if (!settings.Modifiers.Contains(Levels.LevelModifiers.NoChargers))
{
pack.Add((2.0, 10, Baseline_Chargers));
pack.Add((4.0, 2, OnlyChargers));
}

if (!settings.Modifiers.Contains(Levels.LevelModifiers.NoShadows))
{
pack.Add((2.0, 10, Baseline_Shadows));
pack.Add((4.0, 3, OnlyShadows));
}

if (!settings.Modifiers.Contains(Levels.LevelModifiers.NoNightmares))
{
pack.Add((2.0, 10, Baseline_Nightmare));
pack.Add((2.0, 10, OnlyNightmares));
}

if (!settings.Modifiers.Contains(Levels.LevelModifiers.NoFlyers))
{
pack.Add((3.0, 5, Baseline_Flyers));
}


switch (tier)
{
case "A":
Expand Down Expand Up @@ -154,6 +178,16 @@ public static void Setup()
Name = "Baseline_Chargers"
};

public static WavePopulation Baseline_Flyers = new WavePopulation
{
WaveRoleWeakling = Enemy.Shadow,
WaveRoleStandard = Enemy.Striker_Wave,
WaveRoleSpecial = Enemy.Flyer,
WaveRoleMiniBoss = Enemy.StrikerGiant_Wave,
WaveRoleBoss = Enemy.FlyerBig,
Name = "Baseline_Chargers"
};

public static WavePopulation Baseline_Nightmare = new WavePopulation
{
WaveRoleWeakling = Enemy.Shadow,
Expand Down
9 changes: 5 additions & 4 deletions AutogenRundown/src/DataBlocks/Alarms/WaveSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using BepInEx;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace AutogenRundown.DataBlocks.Alarms
{
Expand Down Expand Up @@ -238,7 +236,7 @@ public static void Setup()
=> Setup<GameDataWaveSettings, WaveSettings>(Bins.WaveSettings, "SurvivalWaveSettings");

public override string ToString()
=> $"WavePopulation {{ Name = {Name}, PersistentId = {PersistentId} }}";
=> $"WaveSettings {{ Name = {Name}, PersistentId = {PersistentId} }}";

/// <summary>
/// Return a DrawSelect list of wave settings to attach on alarms. Pack is for one LevelLayout. So we need probably
Expand Down Expand Up @@ -294,6 +292,9 @@ public override string ToString()
Bins.WaveSettings.AddBlock(Baseline_VeryHard);
Bins.WaveSettings.AddBlock(MiniBoss_Hard);

// Error
Bins.WaveSettings.AddBlock(Error_Normal);

// Exit
Bins.WaveSettings.AddBlock(Exit_Baseline);

Expand Down
63 changes: 61 additions & 2 deletions AutogenRundown/src/DataBlocks/LevelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ModifiersSet : HashSet<LevelModifiers>
Remove(LevelModifiers.FogIsInfectious);
break;

case LevelModifiers.NoChargers:
/*case LevelModifiers.NoChargers:
case LevelModifiers.Chargers:
case LevelModifiers.ManyChargers:
case LevelModifiers.OnlyChargers:
Expand All @@ -43,6 +43,26 @@ public class ModifiersSet : HashSet<LevelModifiers>
Remove(LevelModifiers.OnlyChargers);
break;
case LevelModifiers.NoFlyers:
case LevelModifiers.Flyers:
case LevelModifiers.ManyFlyers:
case LevelModifiers.OnlyFlyers:
Remove(LevelModifiers.NoFlyers);
Remove(LevelModifiers.Flyers);
Remove(LevelModifiers.ManyFlyers);
Remove(LevelModifiers.OnlyFlyers);
break;
case LevelModifiers.NoNightmares:
case LevelModifiers.Nightmares:
case LevelModifiers.ManyNightmares:
case LevelModifiers.OnlyNightmares:
Remove(LevelModifiers.NoNightmares);
Remove(LevelModifiers.Nightmares);
Remove(LevelModifiers.ManyNightmares);
Remove(LevelModifiers.OnlyNightmares);
break;
case LevelModifiers.NoShadows:
case LevelModifiers.Shadows:
case LevelModifiers.ManyShadows:
Expand All @@ -51,7 +71,7 @@ public class ModifiersSet : HashSet<LevelModifiers>
Remove(LevelModifiers.Shadows);
Remove(LevelModifiers.ManyShadows);
Remove(LevelModifiers.OnlyShadows);
break;
break;*/
}

return base.Add(modifier);
Expand Down Expand Up @@ -177,13 +197,17 @@ public void Generate()
case "A":
{
Modifiers.Add(LevelModifiers.NoChargers);
Modifiers.Add(LevelModifiers.NoFlyers);
Modifiers.Add(LevelModifiers.NoNightmares);
Modifiers.Add(LevelModifiers.NoShadows);
break;
}

case "B":
{
Modifiers.Add(LevelModifiers.NoChargers);
Modifiers.Add(LevelModifiers.NoFlyers);
Modifiers.Add(LevelModifiers.NoNightmares);
Modifiers.Add(LevelModifiers.NoShadows);

// Fog modifiers
Expand All @@ -210,6 +234,13 @@ public void Generate()
new WeightedModifier { Modifier = LevelModifiers.Chargers, Weight = 0.5 },
new WeightedModifier { Modifier = LevelModifiers.ManyChargers, Weight = 0.1 },
}).Modifier);
Modifiers.Add(
Generator.Select(new List<(double, LevelModifiers)>
{
(0.4, LevelModifiers.NoNightmares),
(100.5, LevelModifiers.Nightmares),
(0.1, LevelModifiers.ManyNightmares),
}));

if (Generator.Flip(0.3))
Modifiers.Add(LevelModifiers.FogIsInfectious);
Expand Down Expand Up @@ -249,6 +280,20 @@ public void Generate()
new WeightedModifier { Modifier = LevelModifiers.Chargers, Weight = 0.5 },
new WeightedModifier { Modifier = LevelModifiers.ManyChargers, Weight = 0.1 },
}).Modifier);
Modifiers.Add(
Generator.Select(new List<(double, LevelModifiers)>
{
(0.4, LevelModifiers.NoNightmares),
(110.5, LevelModifiers.Nightmares),
(0.1, LevelModifiers.ManyNightmares),
}));
Modifiers.Add(
Generator.Select(new List<(double, LevelModifiers)>
{
(0.4, LevelModifiers.NoFlyers),
(110.5, LevelModifiers.Flyers),
(0.1, LevelModifiers.ManyFlyers),
}));

if (Generator.Flip(0.5))
Modifiers.Add(LevelModifiers.FogIsInfectious);
Expand Down Expand Up @@ -301,6 +346,20 @@ public void Generate()
new WeightedModifier { Modifier = LevelModifiers.Chargers, Weight = 0.6 },
new WeightedModifier { Modifier = LevelModifiers.ManyChargers, Weight = 0.1 },
}).Modifier);
Modifiers.Add(
Generator.Select(new List<(double, LevelModifiers)>
{
(0.3, LevelModifiers.NoNightmares),
(110.6, LevelModifiers.Nightmares),
(0.1, LevelModifiers.ManyNightmares),
}));
Modifiers.Add(
Generator.Select(new List<(double, LevelModifiers)>
{
(0.3, LevelModifiers.NoFlyers),
(110.6, LevelModifiers.Flyers),
(0.1, LevelModifiers.ManyFlyers),
}));

if (Generator.Flip(0.8))
Modifiers.Add(LevelModifiers.FogIsInfectious);
Expand Down
11 changes: 8 additions & 3 deletions AutogenRundown/src/DataBlocks/Zone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,17 @@ public void RollAlarms(

// TODO: Randomize things like travel distance here
// We only copy the population settings in if we have an actual alarm here
if (puzzle.TriggerAlarmOnActivate)
if (puzzle.TriggerAlarmOnActivate &&
puzzle != ChainedPuzzle.AlarmClass3_Surge &&
puzzle != ChainedPuzzle.AlarmClass4_Surge)
{
var population = Generator.DrawSelect(wavePopulationPack)!;
var settings = Generator.DrawSelect(waveSettingsPack)!;

Alarm = puzzle with { Population = population, Settings = settings };
puzzle = puzzle with { Population = population, Settings = settings };
Alarm = puzzle;

Plugin.Logger.LogDebug($"Zone {LocalIndex} drew population/settings: {population}");
}
else
Alarm = puzzle;
Expand All @@ -661,7 +666,7 @@ public void RollAlarms(
EventsOnDoorScanStart.AddRange(puzzle.EventsOnDoorScanStart);
EventsOnDoorScanDone.AddRange(puzzle.EventsOnDoorScanDone);

Alarm.Persist();
puzzle.Persist();
}
#endregion

Expand Down

0 comments on commit 80b6e17

Please sign in to comment.