more expedition changes (#17403)
Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
|
||||
public interface IBiomeSpecificMod : ISalvageMod
|
||||
{
|
||||
/// <summary>
|
||||
/// Whitelist for biomes. If null then any biome is allowed.
|
||||
/// </summary>
|
||||
List<string>? Biomes { get; }
|
||||
}
|
||||
@@ -7,5 +7,8 @@ public interface ISalvageMod
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Cost for difficulty modifiers.
|
||||
/// </summary>
|
||||
float Cost { get; }
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
/// Which one is selected depends on the mission difficulty, different weightedRandoms are picked from.
|
||||
/// </summary>
|
||||
[Prototype("salvageAirMod")]
|
||||
public sealed class SalvageAirMod : IPrototype, ISalvageMod
|
||||
public sealed class SalvageAirMod : IPrototype, IBiomeSpecificMod
|
||||
{
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
@@ -23,6 +23,10 @@ public sealed class SalvageAirMod : IPrototype, ISalvageMod
|
||||
[DataField("cost")]
|
||||
public float Cost { get; } = 0f;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? Biomes { get; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true if this planet will have no atmosphere.
|
||||
/// </summary>
|
||||
@@ -34,10 +38,4 @@ public sealed class SalvageAirMod : IPrototype, ISalvageMod
|
||||
/// </summary>
|
||||
[DataField("gases")]
|
||||
public float[] Gases = new float[Atmospherics.AdjustedNumberOfGases];
|
||||
|
||||
/// <summary>
|
||||
/// Biomes this air mixture is allowed to occur in.
|
||||
/// </summary>
|
||||
[DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? Biomes;
|
||||
}
|
||||
|
||||
@@ -6,24 +6,23 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
|
||||
[Prototype("salvageDungeonMod")]
|
||||
public sealed class SalvageDungeonMod : IPrototype, ISalvageMod
|
||||
public sealed class SalvageDungeonMod : IPrototype, IBiomeSpecificMod
|
||||
{
|
||||
[IdDataField] public string ID { get; } = default!;
|
||||
|
||||
[DataField("desc")] public string Description { get; } = string.Empty;
|
||||
|
||||
[DataField("proto", customTypeSerializer:typeof(PrototypeIdSerializer<DungeonConfigPrototype>))]
|
||||
public string Proto = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Cost for difficulty modifiers.
|
||||
/// </summary>
|
||||
/// <inheridoc/>
|
||||
[DataField("cost")]
|
||||
public float Cost { get; } = 0f;
|
||||
|
||||
/// <inheridoc/>
|
||||
[DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? Biomes { get; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Biomes this dungeon can occur in.
|
||||
/// The config to use for spawning the dungeon.
|
||||
/// </summary>
|
||||
[DataField("biomeMods", customTypeSerializer:typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? BiomeMods;
|
||||
[DataField("proto", customTypeSerializer: typeof(PrototypeIdSerializer<DungeonConfigPrototype>))]
|
||||
public string Proto = string.Empty;
|
||||
}
|
||||
|
||||
@@ -4,23 +4,19 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
|
||||
[Prototype("salvageLightMod")]
|
||||
public sealed class SalvageLightMod : IPrototype, ISalvageMod
|
||||
public sealed class SalvageLightMod : IPrototype, IBiomeSpecificMod
|
||||
{
|
||||
[IdDataField] public string ID { get; } = default!;
|
||||
|
||||
[DataField("desc")] public string Description { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Cost for difficulty modifiers.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
[DataField("cost")]
|
||||
public float Cost { get; } = 0f;
|
||||
|
||||
[DataField("color", required: true)] public Color? Color;
|
||||
|
||||
/// <summary>
|
||||
/// Biomes that this color applies to.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
[DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? Biomes;
|
||||
public List<string>? Biomes { get; } = null;
|
||||
|
||||
[DataField("color", required: true)] public Color? Color;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
|
||||
[Prototype("salvageTemperatureMod")]
|
||||
public sealed class SalvageTemperatureMod : IPrototype, IBiomeSpecificMod
|
||||
{
|
||||
[IdDataField] public string ID { get; } = default!;
|
||||
|
||||
[DataField("desc")] public string Description { get; } = string.Empty;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DataField("cost")]
|
||||
public float Cost { get; } = 0f;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? Biomes { get; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Temperature in the planets air mix.
|
||||
/// </summary>
|
||||
[DataField("temperature")]
|
||||
public float Temperature = 293.15f;
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Weather;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
@@ -7,24 +6,23 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
|
||||
[Prototype("salvageWeatherMod")]
|
||||
public sealed class SalvageWeatherMod : IPrototype, ISalvageMod
|
||||
public sealed class SalvageWeatherMod : IPrototype, IBiomeSpecificMod
|
||||
{
|
||||
[IdDataField] public string ID { get; } = default!;
|
||||
|
||||
[DataField("desc")] public string Description { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Cost for difficulty modifiers.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
[DataField("cost")]
|
||||
public float Cost { get; } = 0f;
|
||||
|
||||
[DataField("weather", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<WeatherPrototype>))]
|
||||
public string WeatherPrototype = string.Empty;
|
||||
/// <inheritdoc/>
|
||||
[DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer<SalvageBiomeMod>))]
|
||||
public List<string>? Biomes { get; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Whitelist for biomes. If empty assumed any allowed.
|
||||
/// Weather prototype to use on the planet.
|
||||
/// </summary>
|
||||
[DataField("biomes", customTypeSerializer:typeof(PrototypeIdListSerializer<BiomeTemplatePrototype>))]
|
||||
public List<string> Biomes = new();
|
||||
[DataField("weather", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<WeatherPrototype>))]
|
||||
public string WeatherPrototype = string.Empty;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public sealed record SalvageMission(
|
||||
SalvageMissionType Mission,
|
||||
string Biome,
|
||||
string Air,
|
||||
float Temperature,
|
||||
Color? Color,
|
||||
TimeSpan Duration,
|
||||
List<string> Rewards,
|
||||
@@ -140,6 +141,11 @@ public sealed record SalvageMission(
|
||||
/// </summary>
|
||||
public readonly string Air = Air;
|
||||
|
||||
/// <summary>
|
||||
/// Temperature of the planet's atmosphere.
|
||||
/// </summary>
|
||||
public readonly float Temperature = Temperature;
|
||||
|
||||
/// <summary>
|
||||
/// Lighting color to be used (AKA outdoor lighting).
|
||||
/// </summary>
|
||||
|
||||
@@ -65,9 +65,9 @@ public abstract class SharedSalvageSystem : EntitySystem
|
||||
case DifficultyRating.Moderate:
|
||||
return 4;
|
||||
case DifficultyRating.Hazardous:
|
||||
return 6;
|
||||
case DifficultyRating.Extreme:
|
||||
return 8;
|
||||
case DifficultyRating.Extreme:
|
||||
return 16;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(rating), rating, null);
|
||||
}
|
||||
@@ -97,16 +97,23 @@ public abstract class SharedSalvageSystem : EntitySystem
|
||||
var rand = new System.Random(seed);
|
||||
var faction = GetMod<SalvageFactionPrototype>(rand, ref rating);
|
||||
var biome = GetMod<SalvageBiomeMod>(rand, ref rating);
|
||||
var dungeon = GetDungeon(biome.ID, rand, ref rating);
|
||||
var dungeon = GetBiomeMod<SalvageDungeonMod>(biome.ID, rand, ref rating);
|
||||
var mods = new List<string>();
|
||||
|
||||
var air = GetAir(biome.ID, rand, ref rating);
|
||||
var air = GetBiomeMod<SalvageAirMod>(biome.ID, rand, ref rating);
|
||||
if (air.Description != string.Empty)
|
||||
{
|
||||
mods.Add(air.Description);
|
||||
}
|
||||
|
||||
var light = GetLight(biome.ID, rand, ref rating);
|
||||
// only show the description if there is an atmosphere since wont matter otherwise
|
||||
var temp = GetBiomeMod<SalvageTemperatureMod>(biome.ID, rand, ref rating);
|
||||
if (temp.Description != string.Empty && !air.Space)
|
||||
{
|
||||
mods.Add(temp.Description);
|
||||
}
|
||||
|
||||
var light = GetBiomeMod<SalvageLightMod>(biome.ID, rand, ref rating);
|
||||
if (light.Description != string.Empty)
|
||||
{
|
||||
mods.Add(light.Description);
|
||||
@@ -124,60 +131,18 @@ public abstract class SharedSalvageSystem : EntitySystem
|
||||
}
|
||||
|
||||
var rewards = GetRewards(difficulty, rand);
|
||||
return new SalvageMission(seed, difficulty, dungeon.ID, faction.ID, config, biome.ID, air.ID, light.Color, duration, rewards, mods);
|
||||
return new SalvageMission(seed, difficulty, dungeon.ID, faction.ID, config, biome.ID, air.ID, temp.Temperature, light.Color, duration, rewards, 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)
|
||||
public T GetBiomeMod<T>(string biome, System.Random rand, ref float rating) where T : class, IPrototype, IBiomeSpecificMod
|
||||
{
|
||||
var mods = _proto.EnumeratePrototypes<SalvageDungeonMod>().ToList();
|
||||
var mods = _proto.EnumeratePrototypes<T>().ToList();
|
||||
mods.Sort((x, y) => string.Compare(x.ID, y.ID, StringComparison.Ordinal));
|
||||
rand.Shuffle(mods);
|
||||
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
if (mod.BiomeMods?.Contains(biome) == false ||
|
||||
mod.Cost > rating)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
rating -= (int) mod.Cost;
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
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();
|
||||
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)
|
||||
if (mod.Cost > rating || (mod.Biomes != null && !mod.Biomes.Contains(biome)))
|
||||
continue;
|
||||
|
||||
rating -= mod.Cost;
|
||||
@@ -238,9 +203,9 @@ public abstract class SharedSalvageSystem : EntitySystem
|
||||
case DifficultyRating.Moderate:
|
||||
return new string[] { common, rare, rare };
|
||||
case DifficultyRating.Hazardous:
|
||||
return new string[] { rare, rare, epic };
|
||||
return new string[] { rare, rare, rare, epic };
|
||||
case DifficultyRating.Extreme:
|
||||
return new string[] { rare, epic, epic };
|
||||
return new string[] { rare, rare, epic, epic, epic };
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user