Великая жарка мяса (#788)
* temperature transform * Update CP14TemperatureSystem.cs * fix heating entities * cooking! * fix cooking * aaa * foodsequence remove * fix * fix
This commit is contained in:
@@ -130,12 +130,8 @@ public sealed class TemperatureSystem : EntitySystem
|
||||
public void ChangeHeat(EntityUid uid, float heatAmount, bool ignoreHeatResistance = false,
|
||||
TemperatureComponent? temperature = null)
|
||||
{
|
||||
//CrystallEdge may try place on heater and entity, and solutions
|
||||
//if (!Resolve(uid, ref temperature, false))
|
||||
// return;
|
||||
if (temperature == null)
|
||||
if (!Resolve(uid, ref temperature, false))
|
||||
return;
|
||||
//CrystallEdge may try place on heater and entity, and solutions END
|
||||
|
||||
if (!ignoreHeatResistance)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Server.Temperature.Systems;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Placeable;
|
||||
using Content.Shared.Temperature;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server._CP14.Temperature;
|
||||
@@ -14,21 +15,65 @@ public sealed partial class CP14TemperatureSystem : EntitySystem
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly TemperatureSystem _temperature = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
|
||||
private readonly TimeSpan _updateTick = TimeSpan.FromSeconds(1f);
|
||||
private TimeSpan _timeToNextUpdate = TimeSpan.Zero;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14TemperatureTransformationComponent, OnTemperatureChangeEvent>(OnTemperatureChanged);
|
||||
}
|
||||
|
||||
private void OnTemperatureChanged(Entity<CP14TemperatureTransformationComponent> start,
|
||||
ref OnTemperatureChangeEvent args)
|
||||
{
|
||||
var xform = Transform(start);
|
||||
foreach (var entry in start.Comp.Entries)
|
||||
{
|
||||
if (args.CurrentTemperature > entry.TemperatureRange.X &&
|
||||
args.CurrentTemperature < entry.TemperatureRange.Y)
|
||||
{
|
||||
if (entry.TransformTo is not null)
|
||||
{
|
||||
var result = SpawnAtPosition(entry.TransformTo, xform.Coordinates);
|
||||
|
||||
//Try putting in container
|
||||
_transform.DropNextTo(result, (start, xform));
|
||||
|
||||
if (_solutionContainer.TryGetSolution(result,
|
||||
start.Comp.Solution,
|
||||
out var resultSoln,
|
||||
out _)
|
||||
&& _solutionContainer.TryGetSolution(start.Owner,
|
||||
start.Comp.Solution,
|
||||
out var startSoln,
|
||||
out var startSolution))
|
||||
{
|
||||
_solutionContainer.RemoveAllSolution(resultSoln.Value); //Remove all YML reagents
|
||||
resultSoln.Value.Comp.Solution.MaxVolume = startSoln.Value.Comp.Solution.MaxVolume;
|
||||
_solutionContainer.TryAddSolution(resultSoln.Value, startSolution);
|
||||
}
|
||||
}
|
||||
|
||||
Del(start);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
FlammableEntityHeating(frameTime);
|
||||
|
||||
if (_timing.CurTime <= _timeToNextUpdate)
|
||||
return;
|
||||
|
||||
_timeToNextUpdate = _timing.CurTime + _updateTick;
|
||||
|
||||
FlammableEntityHeating();
|
||||
FlammableSolutionHeating();
|
||||
NormalizeSolutionTemperature();
|
||||
}
|
||||
@@ -38,22 +83,6 @@ public sealed partial class CP14TemperatureSystem : EntitySystem
|
||||
return flammable.FireStacks * heater.DegreesPerStack;
|
||||
}
|
||||
|
||||
private void FlammableEntityHeating(float frameTime)
|
||||
{
|
||||
var flammableQuery = EntityQueryEnumerator<CP14FlammableEntityHeaterComponent, ItemPlacerComponent, FlammableComponent>();
|
||||
while (flammableQuery.MoveNext(out var uid, out var heater, out var placer, out var flammable))
|
||||
{
|
||||
if (!flammable.OnFire)
|
||||
return;
|
||||
|
||||
var energy = flammable.FireStacks * frameTime * heater.DegreesPerStack;
|
||||
foreach (var ent in placer.PlacedEntities)
|
||||
{
|
||||
_temperature.ChangeHeat(ent, energy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NormalizeSolutionTemperature()
|
||||
{
|
||||
var query = EntityQueryEnumerator<CP14SolutionTemperatureComponent, SolutionContainerManagerComponent>();
|
||||
@@ -61,12 +90,33 @@ public sealed partial class CP14TemperatureSystem : EntitySystem
|
||||
{
|
||||
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))
|
||||
if (TryAffectTemp(soln.Comp.Solution.Temperature,
|
||||
temp.StandardTemp,
|
||||
soln.Comp.Solution.Volume,
|
||||
out var newT,
|
||||
power: 0.05f))
|
||||
_solutionContainer.SetTemperature(soln, newT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FlammableEntityHeating()
|
||||
{
|
||||
var flammableQuery =
|
||||
EntityQueryEnumerator<CP14FlammableEntityHeaterComponent, ItemPlacerComponent, FlammableComponent>();
|
||||
while (flammableQuery.MoveNext(out _, out var heater, out var itemPlacer, out var flammable))
|
||||
{
|
||||
if (!flammable.OnFire)
|
||||
continue;
|
||||
|
||||
var energy = flammable.FireStacks * heater.DegreesPerStack;
|
||||
foreach (var ent in itemPlacer.PlacedEntities)
|
||||
{
|
||||
_temperature.ChangeHeat(ent, energy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FlammableSolutionHeating()
|
||||
{
|
||||
var query =
|
||||
@@ -83,7 +133,10 @@ public sealed partial class CP14TemperatureSystem : EntitySystem
|
||||
|
||||
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((heatingEntity, container)))
|
||||
{
|
||||
if (TryAffectTemp(soln.Comp.Solution.Temperature, GetTargetTemperature(flammable, heater), soln.Comp.Solution.Volume, out var newT))
|
||||
if (TryAffectTemp(soln.Comp.Solution.Temperature,
|
||||
GetTargetTemperature(flammable, heater),
|
||||
soln.Comp.Solution.Volume,
|
||||
out var newT))
|
||||
_solutionContainer.SetTemperature(soln, newT);
|
||||
}
|
||||
}
|
||||
@@ -97,7 +150,7 @@ public sealed partial class CP14TemperatureSystem : EntitySystem
|
||||
if (mass == 0)
|
||||
return false;
|
||||
|
||||
newT = (float) (oldT + (targetT - oldT) / mass * power);
|
||||
newT = (float)(oldT + (targetT - oldT) / mass * power);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._CP14.Temperature;
|
||||
|
||||
/// <summary>
|
||||
/// passively returns the solution temperature to the standard
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14TemperatureSystem))]
|
||||
public sealed partial class CP14TemperatureTransformationComponent : Component
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public List<CP14TemperatureTransformEntry> Entries = new();
|
||||
|
||||
/// <summary>
|
||||
/// solution where reagents will be added from newly added ingredients
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public string Solution = "food";
|
||||
}
|
||||
|
||||
[DataRecord]
|
||||
public record struct CP14TemperatureTransformEntry()
|
||||
{
|
||||
public EntProtoId? TransformTo { get; set; } = null;
|
||||
public Vector2 TemperatureRange { get; set; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user