Alchemy fun mechanics (#246)
* heating solution refactor * chromium slime effect refactor * guidebook hint * hint chance fix * убираем ненужное
This commit is contained in:
@@ -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<CP14FlammableSolutionHeaterComponent, ItemPlacerComponent, FlammableComponent>();
|
||||
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<SolutionContainerManagerComponent>(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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ReagentPrototype>, ProtoId<ReagentPrototype>> 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<SolutionComponent>(args.SolutionEntity, out var solutionComp))
|
||||
return;
|
||||
|
||||
var solutionContainer = args.EntityManager.System<SharedSolutionContainerSystem>();
|
||||
|
||||
var ent = new Entity<SolutionComponent>(args.SolutionEntity, solutionComp);
|
||||
|
||||
Dictionary<ReagentId, FixedPoint2> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
|
||||
namespace Content.Server._CP14.Temperature;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(SolutionHeaterSystem))]
|
||||
[RegisterComponent, Access(typeof(CP14SolutionTemperatureSystem))]
|
||||
public sealed partial class CP14FlammableSolutionHeaterComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public float DegreesPerStack = 100f;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Content.Server._CP14.Temperature;
|
||||
|
||||
/// <summary>
|
||||
/// passively returns the solution temperature to the standard
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SolutionTemperatureSystem))]
|
||||
public sealed partial class CP14SolutionTemperatureComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public float StandardTemp = 300f;
|
||||
}
|
||||
@@ -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<CP14SolutionTemperatureComponent, SolutionContainerManagerComponent>();
|
||||
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<CP14FlammableSolutionHeaterComponent, ItemPlacerComponent, FlammableComponent>();
|
||||
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<SolutionContainerManagerComponent>(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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -3,3 +3,9 @@ cp14-reagent-effect-guidebook-temp-affect =
|
||||
[1] Изменяет
|
||||
*[other] изменить
|
||||
} температуру раствора на {$temperature} градусов
|
||||
|
||||
cp14-reagent-effect-guidebook-inverse-effect =
|
||||
{ $chance ->
|
||||
[1] Инвертирует
|
||||
*[other] инвертировать
|
||||
} эффект раствора
|
||||
@@ -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:
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
solutions:
|
||||
vial:
|
||||
maxVol: 1
|
||||
- type: CP14SolutionTemperature
|
||||
- type: MixableSolution
|
||||
solution: vial
|
||||
- type: FitsInDispenser
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
solutions:
|
||||
normalizer:
|
||||
maxVol: 50
|
||||
- type: CP14SolutionTemperature
|
||||
- type: DrainableSolution
|
||||
solution: normalizer
|
||||
- type: ExaminableSolution
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
solutions:
|
||||
vat:
|
||||
maxVol: 500
|
||||
- type: CP14SolutionTemperature
|
||||
- type: SolutionContainerVisuals
|
||||
maxFillLevels: 6
|
||||
fillBaseName: liq
|
||||
|
||||
@@ -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
|
||||
- !type:CP14InverseEffect
|
||||
inversion:
|
||||
CP14BasicEffectHealBrute: CP14BasicEffectDamageBrute
|
||||
CP14BasicEffectDamageBrute: CP14BasicEffectHealBrute
|
||||
#
|
||||
CP14BasicEffectHealPoison: CP14BasicEffectDamagePoison
|
||||
CP14BasicEffectDamagePoison: CP14BasicEffectHealPoison
|
||||
#
|
||||
CP14BasicEffectDamageCold: CP14BasicEffectHealCold
|
||||
CP14BasicEffectHealCold: CP14BasicEffectDamageCold
|
||||
#
|
||||
CP14BasicEffectSatiateHunger: CP14BasicEffectVomit
|
||||
CP14BasicEffectSatiateThirst: CP14BasicEffectSatiateHunger
|
||||
CP14BasicEffectVomit: CP14BasicEffectSatiateThirst
|
||||
#
|
||||
#CP14BasicEffectRainbow:
|
||||
#CP14BasicEffectEmoteCough:
|
||||
Reference in New Issue
Block a user