* frying pan start * fix data saving * Refactor cooking system and add localization support Refactored food data handling in the cooking system to use Visuals instead of FoodData on holders, improved food transfer logic, and added popups and examine messages for user feedback. Added English and Russian localization files for cooking examine and meal descriptions, and updated prototype files to increase plate solution volume and add a whitelist for the cooking furnace. * Refactor cooking system solution handling Removed Solution field from CP14FoodData and updated CP14SharedCookingSystem to use solution containers directly. Improved solution transfer, mixing, and overflow handling during cooking. Increased pan max volume from 30 to 100 in cooking_furnace.yml. * Improve cooking system trash handling and update food sprites Enhanced trash distribution in CP14SharedCookingSystem to randomly assign trash to plates, only adding all trash to the last plate. Updated meat_dish and salad prototypes to use new wooden plate sprites. Added wideAnimationRotation and DrainableSolution to cooking_furnace for improved functionality. * Remove unused usings and redundant comments in cooking components Cleaned up CP14 cooking-related components by removing unused using directives and empty XML comments. This improves code readability and maintainability. * Add tag-based cooking requirements and new meal recipes Introduces tag-based cooking requirement classes (TagRequired, TagBlocked, SolutionRequired) and updates the cooking system to support tag checks. Adds new tags for food items, updates food and meal prototypes to include relevant tags, and implements new meal recipes (Zellasian Breakfast, Monster Egg) with corresponding sprites and localization. Also refactors and renames some tag and structure prototype files for better organization. * Refactor and expand CP14 cooking recipes and tags Reworked meal recipes to use tag-based requirements, added new tags for food categorization (meat, cheese, vegetables, etc.), and removed hardcoded entity recipes for ham in cheese and stuffed potato. Updated and added new meal recipes (bread plate, ham in cheese, stuffed potato), localized their names and descriptions, and migrated/added corresponding sprites. Deprecated SolutionRequired requirement, cleaned up unused tags, and improved TagRequired/TagBlocked logic. Updated prototype files to use new tags and added missing tags to food entities. * Refactor and expand green salad recipes and assets Replaces the old green salad entity and workbench recipe with new cooking recipes for green salad and green salad with meat. Updates English and Russian localization, moves and adds new salad textures, and removes obsolete salad assets and trading request. * mashed potatoes * Add mashed potatoes with herbs meal Introduced a new 'mashed potatoes with herbs' meal, including English and Russian localization, recipe definition, and associated sprite. Updated the texture metadata and added the new image asset. * Update dye.yml * Fix frying pan item size and update plate recipe Moved the 'size: Ginormous' property to the correct component in frying_pen.yml. Renamed the plate recipe and result from 'CP14Plate' to 'CP14PlateWooden' in misc.yml for clarity. * Update meals.yml * Update migration.yml * fixes * fix heating food sounds * Nyranu temperature transmission * Update plate.yml * Cooking DoAfter works * burning logic * cooking more work * auto transform transformable * Update CP14SharedCookingSystem.DoAfter.cs * cool burning visuals! * Add MIT license headers to cooking system files Added sublicensing notice and MIT license header to all files in the CP14 cooking system. Also made minor code cleanups, such as removing unnecessary default initializations and improving XML documentation for clarity. * constant heating required * cooking visuals improve! * sandwiches with processed cheese + reagent burnt fuckuping * inhand pan sprites + FIRE fuckup * crafting & buying pan * fix predicting * random food spawner + chef closet * mapping update * Update frying_pen.yml * move WIP to blacksmith lol
167 lines
5.9 KiB
C#
167 lines
5.9 KiB
C#
using System.Linq;
|
|
using Content.Server.Atmos.Components;
|
|
using Content.Server.Temperature.Systems;
|
|
using Content.Shared._CP14.Temperature;
|
|
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.Containers;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server._CP14.Temperature;
|
|
|
|
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!;
|
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
|
|
|
private readonly TimeSpan _updateTick = TimeSpan.FromSeconds(1f);
|
|
private TimeSpan _timeToNextUpdate = TimeSpan.Zero;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<CP14TemperatureTransformationComponent, OnTemperatureChangeEvent>(OnTemperatureChanged);
|
|
SubscribeLocalEvent<CP14TemperatureTransmissionComponent, OnTemperatureChangeEvent>(OnTemperatureTransmite);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The main idea is that we do not simulate the interaction between the temperature of the container and its contents.
|
|
/// We directly change the temperature of the entire contents of the container.
|
|
/// </summary>
|
|
private void OnTemperatureTransmite(Entity<CP14TemperatureTransmissionComponent> ent,
|
|
ref OnTemperatureChangeEvent args)
|
|
{
|
|
if (!_container.TryGetContainer(ent, ent.Comp.ContainerId, out var container))
|
|
return;
|
|
|
|
var heatAmount = args.TemperatureDelta * _temperature.GetHeatCapacity(ent);
|
|
|
|
// copy the list to avoid modifying it while iterating
|
|
var containedEntities = container.ContainedEntities.ToList();
|
|
|
|
var entityCount = containedEntities.Count;
|
|
foreach (var contained in containedEntities)
|
|
{
|
|
_temperature.ChangeHeat(contained, heatAmount / entityCount);
|
|
}
|
|
}
|
|
|
|
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 == null)
|
|
continue;
|
|
|
|
SpawnNextToOrDrop(entry.TransformTo, start);
|
|
Del(start);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
if (_timing.CurTime <= _timeToNextUpdate)
|
|
return;
|
|
|
|
_timeToNextUpdate = _timing.CurTime + _updateTick;
|
|
|
|
FlammableEntityHeating();
|
|
FlammableSolutionHeating();
|
|
NormalizeSolutionTemperature();
|
|
}
|
|
|
|
private float GetTargetTemperature(FlammableComponent flammable, CP14FlammableSolutionHeaterComponent heater)
|
|
{
|
|
return flammable.FireStacks * heater.DegreesPerStack;
|
|
}
|
|
|
|
private void NormalizeSolutionTemperature()
|
|
{
|
|
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 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 =
|
|
EntityQueryEnumerator<CP14FlammableSolutionHeaterComponent, ItemPlacerComponent, FlammableComponent>();
|
|
while (query.MoveNext(out _, out var heater, out var itemPlacer, out var flammable))
|
|
{
|
|
if (!flammable.OnFire)
|
|
continue;
|
|
|
|
foreach (var heatingEntity in itemPlacer.PlacedEntities)
|
|
{
|
|
if (!TryComp<SolutionContainerManagerComponent>(heatingEntity, out var container))
|
|
continue;
|
|
|
|
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((heatingEntity, container)))
|
|
{
|
|
if (TryAffectTemp(soln.Comp.Solution.Temperature,
|
|
GetTargetTemperature(flammable, heater),
|
|
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;
|
|
}
|
|
}
|