diff --git a/Content.Server/Salvage/SpawnSalvageMissionJob.cs b/Content.Server/Salvage/SpawnSalvageMissionJob.cs index 60e73a5b5a..caeaf6c7bc 100644 --- a/Content.Server/Salvage/SpawnSalvageMissionJob.cs +++ b/Content.Server/Salvage/SpawnSalvageMissionJob.cs @@ -105,14 +105,15 @@ public sealed class SpawnSalvageMissionJob : Job _entManager.Dirty(gravity, metadata); // Atmos - var atmos = _entManager.EnsureComponent(mapUid); - atmos.Space = false; + var air = _prototypeManager.Index(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(mapUid); + atmos.Space = air.Space; atmos.Mixture = new GasMixture(2500) { + // TODO: temperature mods Temperature = 293.15f, Moles = moles, }; diff --git a/Content.Shared/Salvage/Expeditions/Modifiers/SalvageAirMod.cs b/Content.Shared/Salvage/Expeditions/Modifiers/SalvageAirMod.cs new file mode 100644 index 0000000000..167c140b4b --- /dev/null +++ b/Content.Shared/Salvage/Expeditions/Modifiers/SalvageAirMod.cs @@ -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; + +/// +/// 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. +/// +[Prototype("salvageAirMod")] +public sealed class SalvageAirMod : IPrototype, ISalvageMod +{ + [IdDataField] + public string ID { get; } = default!; + + /// + [DataField("desc")] + public string Description { get; } = string.Empty; + + /// + [DataField("cost")] + public float Cost { get; } = 0f; + + /// + /// Set to true if this planet will have no atmosphere. + /// + [DataField("space")] + public bool Space; + + /// + /// Number of moles of each gas in the mixture. + /// + [DataField("gases")] + public float[] Gases = new float[Atmospherics.AdjustedNumberOfGases]; + + /// + /// Biomes this air mixture is allowed to occur in. + /// + [DataField("biomes", customTypeSerializer: typeof(PrototypeIdListSerializer))] + public List? Biomes; +} diff --git a/Content.Shared/Salvage/SalvageExpeditions.cs b/Content.Shared/Salvage/SalvageExpeditions.cs index 18247470ff..18a41eb30a 100644 --- a/Content.Shared/Salvage/SalvageExpeditions.cs +++ b/Content.Shared/Salvage/SalvageExpeditions.cs @@ -100,6 +100,7 @@ public sealed record SalvageMission( string Faction, SalvageMissionType Mission, string Biome, + string Air, Color? Color, TimeSpan Duration, Dictionary Loot, @@ -135,6 +136,11 @@ public sealed record SalvageMission( /// public readonly string Biome = Biome; + /// + /// Air mixture to be used for the mission's planet. + /// + public readonly string Air = Air; + /// /// Lighting color to be used (AKA outdoor lighting). /// diff --git a/Content.Shared/Salvage/SharedSalvageSystem.cs b/Content.Shared/Salvage/SharedSalvageSystem.cs index 0eae88598a..50c8af9771 100644 --- a/Content.Shared/Salvage/SharedSalvageSystem.cs +++ b/Content.Shared/Salvage/SharedSalvageSystem.cs @@ -101,11 +101,15 @@ public abstract class SharedSalvageSystem : EntitySystem var dungeon = GetDungeon(biome.ID, rand, ref rating); var mods = new List(); - 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().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().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().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().ToList(); diff --git a/Resources/Prototypes/Procedural/salvage_mods.yml b/Resources/Prototypes/Procedural/salvage_mods.yml index 09dcd26567..77c58c4cac 100644 --- a/Resources/Prototypes/Procedural/salvage_mods.yml +++ b/Resources/Prototypes/Procedural/salvage_mods.yml @@ -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 diff --git a/Resources/Prototypes/Procedural/salvage_rewards.yml b/Resources/Prototypes/Procedural/salvage_rewards.yml index 3739e16b86..9d5ea6cc96 100644 --- a/Resources/Prototypes/Procedural/salvage_rewards.yml +++ b/Resources/Prototypes/Procedural/salvage_rewards.yml @@ -55,6 +55,7 @@ WeaponXrayCannon: 1.0 WeaponSniperHristov: 1.0 # extremely rare weapons + GatfruitSeeds: 0.25 WeaponLauncherRocket: 0.1 # rare chemicals CognizineChemistryBottle: 1.0