expedition air mod (#17369)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-06-16 05:25:25 +00:00
committed by GitHub
parent f0896685ff
commit 41fae6e9cd
6 changed files with 181 additions and 11 deletions

View File

@@ -101,11 +101,15 @@ public abstract class SharedSalvageSystem : EntitySystem
var dungeon = GetDungeon(biome.ID, rand, ref rating);
var mods = new List<string>();
SalvageLightMod? light = null;
if (biome.BiomePrototype != null)
var air = GetAir(biome.ID, rand, ref rating);
if (air.Description != string.Empty)
{
mods.Add(air.Description);
}
var light = GetLight(biome.ID, rand, ref rating);
if (light.Description != string.Empty)
{
light = GetLight(biome.ID, rand, ref rating);
mods.Add(light.Description);
}
@@ -115,15 +119,16 @@ public abstract class SharedSalvageSystem : EntitySystem
exactDuration = MathF.Round(exactDuration / 15f) * 15f;
var duration = TimeSpan.FromSeconds(exactDuration);
if (time.ID != "StandardTime")
if (time.Description != string.Empty)
{
mods.Add(time.Description);
}
var loots = GetLoot(config, _proto.EnumeratePrototypes<SalvageLootPrototype>().Where(o => !o.Guaranteed).ToList(), GetDifficulty(difficulty), seed);
return new SalvageMission(seed, difficulty, dungeon.ID, faction.ID, config, biome.ID, light?.Color, duration, loots, mods);
return new SalvageMission(seed, difficulty, dungeon.ID, faction.ID, config, biome.ID, air.ID, light.Color, duration, loots, mods);
}
// TODO: probably worth putting the biome whitelist thing in a common thing then having a getmod overload for it
public SalvageDungeonMod GetDungeon(string biome, System.Random rand, ref float rating)
{
var mods = _proto.EnumeratePrototypes<SalvageDungeonMod>().ToList();
@@ -146,6 +151,25 @@ public abstract class SharedSalvageSystem : EntitySystem
throw new InvalidOperationException();
}
public SalvageAirMod GetAir(string biome, System.Random rand, ref float rating)
{
var mods = _proto.EnumeratePrototypes<SalvageAirMod>().ToList();
mods.Sort((x, y) => string.Compare(x.ID, y.ID, StringComparison.Ordinal));
rand.Shuffle(mods);
foreach (var mod in mods)
{
if (mod.Biomes?.Contains(biome) == false || mod.Cost > rating)
continue;
rating -= mod.Cost;
return mod;
}
throw new InvalidOperationException();
}
public SalvageLightMod GetLight(string biome, System.Random rand, ref float rating)
{
var mods = _proto.EnumeratePrototypes<SalvageLightMod>().ToList();