expedition air mod (#17369)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -105,14 +105,15 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
||||
_entManager.Dirty(gravity, metadata);
|
||||
|
||||
// Atmos
|
||||
var atmos = _entManager.EnsureComponent<MapAtmosphereComponent>(mapUid);
|
||||
atmos.Space = false;
|
||||
var air = _prototypeManager.Index<SalvageAirMod>(mission.Air);
|
||||
// copy into a new array since the yml deserialization discards the fixed length
|
||||
var moles = new float[Atmospherics.AdjustedNumberOfGases];
|
||||
moles[(int) Gas.Oxygen] = 21.824779f;
|
||||
moles[(int) Gas.Nitrogen] = 82.10312f;
|
||||
|
||||
air.Gases.CopyTo(moles, 0);
|
||||
var atmos = _entManager.EnsureComponent<MapAtmosphereComponent>(mapUid);
|
||||
atmos.Space = air.Space;
|
||||
atmos.Mixture = new GasMixture(2500)
|
||||
{
|
||||
// TODO: temperature mods
|
||||
Temperature = 293.15f,
|
||||
Moles = moles,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
|
||||
/// <summary>
|
||||
/// Prototype for a planet's air gas mixture.
|
||||
/// Used when creating the planet for a salvage expedition.
|
||||
/// Which one is selected depends on the mission difficulty, different weightedRandoms are picked from.
|
||||
/// </summary>
|
||||
[Prototype("salvageAirMod")]
|
||||
public sealed class SalvageAirMod : IPrototype, ISalvageMod
|
||||
{
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DataField("desc")]
|
||||
public string Description { get; } = string.Empty;
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DataField("cost")]
|
||||
public float Cost { get; } = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true if this planet will have no atmosphere.
|
||||
/// </summary>
|
||||
[DataField("space")]
|
||||
public bool Space;
|
||||
|
||||
/// <summary>
|
||||
/// Number of moles of each gas in the mixture.
|
||||
/// </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;
|
||||
}
|
||||
@@ -100,6 +100,7 @@ public sealed record SalvageMission(
|
||||
string Faction,
|
||||
SalvageMissionType Mission,
|
||||
string Biome,
|
||||
string Air,
|
||||
Color? Color,
|
||||
TimeSpan Duration,
|
||||
Dictionary<string, int> Loot,
|
||||
@@ -135,6 +136,11 @@ public sealed record SalvageMission(
|
||||
/// </summary>
|
||||
public readonly string Biome = Biome;
|
||||
|
||||
/// <summary>
|
||||
/// Air mixture to be used for the mission's planet.
|
||||
/// </summary>
|
||||
public readonly string Air = Air;
|
||||
|
||||
/// <summary>
|
||||
/// Lighting color to be used (AKA outdoor lighting).
|
||||
/// </summary>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -100,3 +100,98 @@
|
||||
proto: LavaBrig
|
||||
biomeMods:
|
||||
- Lava
|
||||
|
||||
# Air mixtures
|
||||
- type: salvageAirMod
|
||||
id: Space
|
||||
desc: No atmosphere
|
||||
space: true
|
||||
cost: 1
|
||||
biomes:
|
||||
- Caves
|
||||
- Lava
|
||||
|
||||
- type: salvageAirMod
|
||||
id: Breathable
|
||||
gases:
|
||||
- 21.824779 # oxygen
|
||||
- 82.10312 # nitrogen
|
||||
biomes:
|
||||
- Caves
|
||||
#- LowDesert
|
||||
- Snow
|
||||
- Grasslands
|
||||
|
||||
- type: salvageAirMod
|
||||
id: Sleepy
|
||||
cost: 1
|
||||
desc: Dangerous atmosphere
|
||||
gases:
|
||||
- 21.824779 # oxygen
|
||||
- 72.10312 # nitrogen
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 10 # nitrous oxide
|
||||
biomes:
|
||||
- Caves
|
||||
#- LowDesert
|
||||
- Snow
|
||||
- Grasslands
|
||||
- Lava
|
||||
|
||||
- type: salvageAirMod
|
||||
id: Poisoned
|
||||
cost: 2
|
||||
desc: Dangerous atmosphere
|
||||
gases:
|
||||
- 21.824779 # oxygen
|
||||
- 77.10312 # nitrogen
|
||||
- 10 # carbon dioxide
|
||||
biomes:
|
||||
- Caves
|
||||
#- LowDesert
|
||||
- Snow
|
||||
- Grasslands
|
||||
- Lava
|
||||
|
||||
- type: salvageAirMod
|
||||
id: Poison
|
||||
cost: 3
|
||||
desc: Toxic atmosphere
|
||||
gases:
|
||||
- 21.824779 # oxygen
|
||||
- 0
|
||||
- 82.10312 # carbon dioxide
|
||||
biomes:
|
||||
- Caves
|
||||
- Snow
|
||||
- Lava
|
||||
|
||||
- type: salvageAirMod
|
||||
id: Plasma
|
||||
cost: 4
|
||||
desc: Toxic atmosphere
|
||||
gases:
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 103.927899 # plasma
|
||||
biomes:
|
||||
- Caves
|
||||
- Lava
|
||||
|
||||
- type: salvageAirMod
|
||||
id: Burnable
|
||||
cost: 5
|
||||
desc: Volatile atmosphere
|
||||
gases:
|
||||
- 21.824779 # oxygen
|
||||
- 0
|
||||
- 0
|
||||
- 82.10312 # plasma
|
||||
biomes:
|
||||
- Caves
|
||||
- Lava
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
WeaponXrayCannon: 1.0
|
||||
WeaponSniperHristov: 1.0
|
||||
# extremely rare weapons
|
||||
GatfruitSeeds: 0.25
|
||||
WeaponLauncherRocket: 0.1
|
||||
# rare chemicals
|
||||
CognizineChemistryBottle: 1.0
|
||||
|
||||
Reference in New Issue
Block a user