diff --git a/Content.Server/Chemistry/EntitySystems/SolutionHeaterSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionHeaterSystem.cs index a4dbc10d88..6e6373e10b 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionHeaterSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionHeaterSystem.cs @@ -1,5 +1,3 @@ -using Content.Server._CP14.Temperature; -using Content.Server.Atmos.Components; using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Containers.EntitySystems; using Content.Server.Power.Components; @@ -94,26 +92,5 @@ public sealed class SolutionHeaterSystem : EntitySystem } } } - - //CrystallPunk bonfire - var flammablequery = EntityQueryEnumerator(); - while (flammablequery.MoveNext(out _, out var heater, out var placer, out var flammable)) - { - foreach (var heatingEntity in placer.PlacedEntities) - { - if (!flammable.OnFire) - continue; - - if (!TryComp(heatingEntity, out var container)) - continue; - - var energy = flammable.FireStacks * frameTime * 300; - foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((heatingEntity, container))) - { - _solutionContainer.AddThermalEnergy(soln, energy); - } - } - } - //CrystallPunk bonfire end } } diff --git a/Content.Server/_CP14/Chemistry/ReagentEffect/CP14InverseEffect.cs b/Content.Server/_CP14/Chemistry/ReagentEffect/CP14InverseEffect.cs new file mode 100644 index 0000000000..2ee3be5c78 --- /dev/null +++ b/Content.Server/_CP14/Chemistry/ReagentEffect/CP14InverseEffect.cs @@ -0,0 +1,47 @@ +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.EntitySystems; +using Content.Shared.Chemistry.Reagent; +using Content.Shared.FixedPoint; +using JetBrains.Annotations; +using Robust.Shared.Prototypes; + +namespace Content.Server._CP14.Chemistry.ReagentEffect; + +[UsedImplicitly] +[DataDefinition] +public sealed partial class CP14InverseEffect : Shared.Chemistry.Reagent.ReagentEffect +{ + [DataField] + public Dictionary, ProtoId> Inversion = new(); + protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) + { + return Loc.GetString("cp14-reagent-effect-guidebook-inverse-effect", ("chance", Probability)); + } + + public override void Effect(ReagentEffectArgs args) + { + if (args.Source == null) + return; + + if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out var solutionComp)) + return; + + var solutionContainer = args.EntityManager.System(); + + var ent = new Entity(args.SolutionEntity, solutionComp); + + Dictionary taskList = new(); + + foreach (var reagent in args.Source.Contents) + { + if (Inversion.ContainsKey(reagent.Reagent.Prototype)) + taskList.Add(reagent.Reagent, reagent.Quantity); + } + + foreach (var task in taskList) + { + solutionContainer.RemoveReagent(ent, task.Key, task.Value); + solutionContainer.TryAddReagent(ent, Inversion[task.Key.Prototype].Id, task.Value); + } + } +} diff --git a/Content.Server/_CP14/Temperature/CP14FlammableSolutionHeaterComponent.cs b/Content.Server/_CP14/Temperature/CP14FlammableSolutionHeaterComponent.cs index 218a81afb0..badb049b0e 100644 --- a/Content.Server/_CP14/Temperature/CP14FlammableSolutionHeaterComponent.cs +++ b/Content.Server/_CP14/Temperature/CP14FlammableSolutionHeaterComponent.cs @@ -1,11 +1,11 @@ -using Content.Server.Chemistry.EntitySystems; - namespace Content.Server._CP14.Temperature; /// -/// Adds thermal energy from FlammableComponent to solutions placed on it. +/// allows you to heat the temperature of solutions depending on the number of stacks of fire /// -[RegisterComponent, Access(typeof(SolutionHeaterSystem))] +[RegisterComponent, Access(typeof(CP14SolutionTemperatureSystem))] public sealed partial class CP14FlammableSolutionHeaterComponent : Component { + [DataField] + public float DegreesPerStack = 100f; } diff --git a/Content.Server/_CP14/Temperature/CP14SolutionTemperatureComponent.cs b/Content.Server/_CP14/Temperature/CP14SolutionTemperatureComponent.cs new file mode 100644 index 0000000000..5acccfaa01 --- /dev/null +++ b/Content.Server/_CP14/Temperature/CP14SolutionTemperatureComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Server._CP14.Temperature; + +/// +/// passively returns the solution temperature to the standard +/// +[RegisterComponent, Access(typeof(CP14SolutionTemperatureSystem))] +public sealed partial class CP14SolutionTemperatureComponent : Component +{ + [DataField] + public float StandardTemp = 300f; +} diff --git a/Content.Server/_CP14/Temperature/CP14SolutionTemperatureSystem.cs b/Content.Server/_CP14/Temperature/CP14SolutionTemperatureSystem.cs new file mode 100644 index 0000000000..e9f4c783d4 --- /dev/null +++ b/Content.Server/_CP14/Temperature/CP14SolutionTemperatureSystem.cs @@ -0,0 +1,77 @@ +using Content.Server.Atmos.Components; +using Content.Server.Chemistry.Containers.EntitySystems; +using Content.Shared.Chemistry.Components.SolutionManager; +using Content.Shared.FixedPoint; +using Content.Shared.Placeable; +using Robust.Shared.Timing; + +namespace Content.Server._CP14.Temperature; + +public sealed partial class CP14SolutionTemperatureSystem : EntitySystem +{ + [Dependency] private readonly SolutionContainerSystem _solutionContainer = default!; + [Dependency] private readonly IGameTiming _timing = default!; + + private TimeSpan _updateTick = TimeSpan.FromSeconds(1f); + private TimeSpan _timeToNextUpdate = TimeSpan.Zero; + + public override void Update(float frameTime) + { + base.Update(frameTime); + + if (_timing.CurTime <= _timeToNextUpdate) + return; + + _timeToNextUpdate = _timing.CurTime + _updateTick; + + FlammableHeating(); + NormalizeTemperature(); + } + + private void NormalizeTemperature() + { + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var temp, out var container)) + { + foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((uid, container))) + { + if (TryAffectTemp(soln.Comp.Solution.Temperature, temp.StandardTemp, soln.Comp.Solution.Volume, out var newT, power: 0.05f)) + _solutionContainer.SetTemperature(soln, newT); + } + } + } + private void FlammableHeating() + { + var query = + EntityQueryEnumerator(); + while (query.MoveNext(out _, out var heater, out var itemPlacer, out var flammable)) + { + foreach (var heatingEntity in itemPlacer.PlacedEntities) + { + if (!flammable.OnFire) + continue; + + if (!TryComp(heatingEntity, out var container)) + continue; + + var targetT = flammable.FireStacks * heater.DegreesPerStack; + foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((heatingEntity, container))) + { + if (TryAffectTemp(soln.Comp.Solution.Temperature, targetT, soln.Comp.Solution.Volume, out var newT)) + _solutionContainer.SetTemperature(soln, newT); + } + } + } + } + + private static bool TryAffectTemp(float oldT, float targetT, FixedPoint2 mass, out float newT, float power = 1) + { + newT = oldT; + + if (mass == 0) + return false; + + newT = (float) (oldT + ((targetT - oldT) / mass) * power); + return true; + } +} diff --git a/Resources/Locale/en-US/_CP14/guidebook/chemistry/effects.ftl b/Resources/Locale/en-US/_CP14/guidebook/chemistry/effects.ftl index 90579f3879..a8b2c8fb45 100644 --- a/Resources/Locale/en-US/_CP14/guidebook/chemistry/effects.ftl +++ b/Resources/Locale/en-US/_CP14/guidebook/chemistry/effects.ftl @@ -3,3 +3,9 @@ cp14-reagent-effect-guidebook-temp-affect = [1] Changes *[other] changes } the temperature of the solution by {$temperature} degrees + +cp14-reagent-effect-guidebook-inverse-effect = + { $chance -> + [1] Inverts + *[other] to invert + } the effect of the solution \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_CP14/guidebook/chemistry/effects.ftl b/Resources/Locale/ru-RU/_CP14/guidebook/chemistry/effects.ftl index cac95f9335..7bc8257725 100644 --- a/Resources/Locale/ru-RU/_CP14/guidebook/chemistry/effects.ftl +++ b/Resources/Locale/ru-RU/_CP14/guidebook/chemistry/effects.ftl @@ -3,3 +3,9 @@ cp14-reagent-effect-guidebook-temp-affect = [1] Изменяет *[other] изменить } температуру раствора на {$temperature} градусов + +cp14-reagent-effect-guidebook-inverse-effect = + { $chance -> + [1] Инвертирует + *[other] инвертировать + } эффект раствора \ No newline at end of file diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/tools.yml b/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/tools.yml index 084713d834..5aea923630 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/tools.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/tools.yml @@ -18,6 +18,7 @@ - state: liq-1 map: ["enum.SolutionContainerLayers.Fill"] visible: false + - type: CP14SolutionTemperature - type: SolutionContainerManager solutions: vat: @@ -103,6 +104,7 @@ solutions: mortar: maxVol: 30 + - type: CP14SolutionTemperature - type: Spillable solution: mortar - type: DrainableSolution @@ -177,6 +179,7 @@ solution: vial - type: SolutionItemStatus solution: vial + - type: CP14SolutionTemperature - type: SolutionContainerManager solutions: vial: diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vials.yml b/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vials.yml index 2b6d854350..eabb9a02fa 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vials.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vials.yml @@ -13,6 +13,7 @@ solutions: vial: maxVol: 1 + - type: CP14SolutionTemperature - type: MixableSolution solution: vial - type: FitsInDispenser diff --git a/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/normalizer.yml b/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/normalizer.yml index 61225abd48..6f7f5f6b6f 100644 --- a/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/normalizer.yml +++ b/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/normalizer.yml @@ -52,6 +52,7 @@ solutions: normalizer: maxVol: 50 + - type: CP14SolutionTemperature - type: DrainableSolution solution: normalizer - type: ExaminableSolution diff --git a/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/vat.yml b/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/vat.yml index 9912e3d328..277f62139d 100644 --- a/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/vat.yml +++ b/Resources/Prototypes/_CP14/Entities/Structures/Specific/Alchemy/vat.yml @@ -52,6 +52,7 @@ solutions: vat: maxVol: 500 + - type: CP14SolutionTemperature - type: SolutionContainerVisuals maxFillLevels: 6 fillBaseName: liq diff --git a/Resources/Prototypes/_CP14/Recipes/Reactions/Alchemy/chromium_inverse.yml b/Resources/Prototypes/_CP14/Recipes/Reactions/Alchemy/chromium_inverse.yml index d73646fd2e..9b46017c8b 100644 --- a/Resources/Prototypes/_CP14/Recipes/Reactions/Alchemy/chromium_inverse.yml +++ b/Resources/Prototypes/_CP14/Recipes/Reactions/Alchemy/chromium_inverse.yml @@ -1,113 +1,36 @@ # Idea: -# Chromium slime is a special reagent that inverts the USEFUL properties. +# Chromium slime is a special reagent that inverts solution properties. # Rules: # 1) all values must be multiples of 0.25 -# 2) all reactions should follow the same pattern -# 3) There should be no reactions here that invert useless properties (hallucinations or coughing) - type: reaction - id: CP14ChromiumInverseEffectHealBruteGroup + id: CP14ChromiumInverseEffect quantized: true minTemp: 350 conserveEnergy: false reactants: - CP14BasicEffectHealBrute: - amount: 0.5 CP14ChromiumSlime: - amount: 0.5 + amount: 1 + CP14BasicEffectEmpty: + amount: 1 products: - CP14BasicEffectDamageBrute: 0.25 - CP14BasicEffectEmpty: 0.75 + CP14BasicEffectEmpty: 2 effects: - - !type:CP14AffectSolutionTemperature - addTemperature: -350 - -- type: reaction - id: CP14ChromiumInverseEffectDamageBruteGroup - quantized: true - minTemp: 350 - conserveEnergy: false - reactants: - CP14BasicEffectDamageBrute: - amount: 0.5 - CP14ChromiumSlime: - amount: 0.5 - products: - CP14BasicEffectHealBrute: 0.25 - CP14BasicEffectEmpty: 0.75 - effects: - - !type:CP14AffectSolutionTemperature - addTemperature: -350 - -# - -- type: reaction - id: CP14ChromiumInverseEffectHealPoison - quantized: true - minTemp: 350 - conserveEnergy: false - reactants: - CP14BasicEffectHealPoison: - amount: 0.5 - CP14ChromiumSlime: - amount: 0.5 - products: - CP14BasicEffectDamagePoison: 0.25 - CP14BasicEffectEmpty: 0.75 - effects: - - !type:CP14AffectSolutionTemperature - addTemperature: -350 - -- type: reaction - id: CP14ChromiumInverseEffectDamagePoison - quantized: true - minTemp: 350 - conserveEnergy: false - reactants: - CP14BasicEffectDamagePoison: - amount: 0.5 - CP14ChromiumSlime: - amount: 0.5 - products: - CP14BasicEffectHealPoison: 0.25 - CP14BasicEffectEmpty: 0.75 - effects: - - !type:CP14AffectSolutionTemperature - addTemperature: -350 - -# - -- type: reaction - id: CP14ChromiumInverseEffectDamageCold - quantized: true - minTemp: 350 - conserveEnergy: false - reactants: - CP14BasicEffectDamageCold: - amount: 0.5 - CP14ChromiumSlime: - amount: 0.5 - products: - CP14BasicEffectHealCold: 0.25 - CP14BasicEffectEmpty: 0.75 - effects: - - !type:CP14AffectSolutionTemperature - addTemperature: -350 - -- type: reaction - id: CP14ChromiumInverseEffectHealCold - quantized: true - minTemp: 350 - conserveEnergy: false - reactants: - CP14BasicEffectHealCold: - amount: 0.5 - CP14ChromiumSlime: - amount: 0.5 - products: - CP14BasicEffectDamageCold: 0.25 - CP14BasicEffectEmpty: 0.75 - effects: - - !type:CP14AffectSolutionTemperature - addTemperature: -350 \ No newline at end of file + - !type:CP14InverseEffect + inversion: + CP14BasicEffectHealBrute: CP14BasicEffectDamageBrute + CP14BasicEffectDamageBrute: CP14BasicEffectHealBrute + # + CP14BasicEffectHealPoison: CP14BasicEffectDamagePoison + CP14BasicEffectDamagePoison: CP14BasicEffectHealPoison + # + CP14BasicEffectDamageCold: CP14BasicEffectHealCold + CP14BasicEffectHealCold: CP14BasicEffectDamageCold + # + CP14BasicEffectSatiateHunger: CP14BasicEffectVomit + CP14BasicEffectSatiateThirst: CP14BasicEffectSatiateHunger + CP14BasicEffectVomit: CP14BasicEffectSatiateThirst + # + #CP14BasicEffectRainbow: + #CP14BasicEffectEmoteCough: \ No newline at end of file