-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this doesn't even build lol ignore this
- Loading branch information
1 parent
014efe5
commit e7e4b55
Showing
35 changed files
with
518 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Content.Server/Kitchen/Components/ActiveKettleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Content.Shared.Kitchen; | ||
|
||
namespace Content.Server.Kitchen.Components; | ||
|
||
/// <summary> | ||
/// Attached to a microwave that is currently in the process of cooking | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ActiveKettleComponent : Component | ||
{ | ||
[ViewVariables] | ||
public (DrinkRecipePrototype?, int) PortionedRecipe; | ||
} |
11 changes: 11 additions & 0 deletions
11
Content.Server/Kitchen/Components/ActivelyBoilingComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Content.Shared.Kitchen; | ||
|
||
namespace Content.Server.Kitchen.Components; | ||
|
||
/// <summary> | ||
/// Attached to an object that's actively being boiled into tea | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ActivelyBoilingComponent : Component | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Content.Shared.Construction.Prototypes; | ||
using Content.Shared.DeviceLinking; | ||
using Content.Shared.Item; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
||
namespace Content.Server.Kitchen.Components | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class KettleComponent : Component | ||
{ | ||
|
||
[DataField("baseHeatMultiplier"), ViewVariables(VVAccess.ReadWrite)] | ||
public float BaseHeatMultiplier = 100; | ||
|
||
public Container Storage = default!; | ||
|
||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public int Capacity = 3; | ||
|
||
[DataField("objectHeatMultiplier"), ViewVariables(VVAccess.ReadWrite)] | ||
public float ObjectHeatMultiplier = 100; | ||
|
||
[DataField("failureResult", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
public string BadRecipeEntityId = "FoodBadRecipe"; | ||
|
||
#region audio | ||
[DataField("beginBoilSound")] | ||
public SoundSpecifier StartBoilingSound = new SoundPathSpecifier("/Audio/Items/Kettle/kettle_switch_on.ogg"); | ||
|
||
[DataField("boilDoneSound")] | ||
public SoundSpecifier BoilDoneSound = new SoundPathSpecifier("/Audio/Machines/kettle_done.ogg"); | ||
|
||
public EntityUid? PlayingStream; | ||
|
||
[DataField("loopingSound")] | ||
public SoundSpecifier LoopingSound = new SoundPathSpecifier("/Audio/Machines/kettle_boiling_water.ogg"); | ||
#endregion | ||
|
||
|
||
/// <summary> | ||
/// Max Temp the kettle can heat to | ||
/// </summary> | ||
[DataField("temperatureLimit")] | ||
public float TemperatureUpperThreshold = 373.15f; // boiling point of water :v | ||
|
||
} | ||
|
||
public sealed class BeingBoiledEvent : HandledEntityEventArgs | ||
{ | ||
public EntityUid Kettle; | ||
public EntityUid? User; | ||
|
||
public BeingBoiledEvent(EntityUid kettle, EntityUid? user) | ||
{ | ||
Kettle = kettle; | ||
User = user; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
using Content.Server.Body.Systems; | ||
using Content.Server.Chemistry.Containers.EntitySystems; | ||
using Content.Server.Construction; | ||
using Content.Server.Explosion.EntitySystems; | ||
using Content.Server.DeviceLinking.Events; | ||
using Content.Server.DeviceLinking.Systems; | ||
using Content.Server.Hands.Systems; | ||
using Content.Server.Kitchen.Components; | ||
using Content.Server.Power.Components; | ||
using Content.Server.Power.EntitySystems; | ||
using Content.Server.Temperature.Components; | ||
using Content.Server.Temperature.Systems; | ||
using Content.Shared.Body.Components; | ||
using Content.Shared.Body.Part; | ||
using Content.Shared.Chemistry.Components.SolutionManager; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Construction.EntitySystems; | ||
using Content.Shared.Destructible; | ||
using Content.Shared.FixedPoint; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Interaction.Events; | ||
using Robust.Shared.Random; | ||
using Robust.Shared.Audio; | ||
using Content.Server.Lightning; | ||
using Content.Shared.Item; | ||
using Content.Shared.Kitchen; | ||
using Content.Shared.Kitchen.Components; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Power; | ||
using Content.Shared.Tag; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Audio.Systems; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.Player; | ||
using System.Linq; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server.Kitchen.EntitySystems | ||
{ | ||
public sealed class KettleSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
[Dependency] private readonly SharedContainerSystem _container = default!; | ||
[Dependency] private readonly RecipeManager _recipeManager = default!; | ||
[Dependency] private readonly TemperatureSystem _temperature = default!; | ||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; | ||
[Dependency] private readonly SharedItemSystem _item = default!; | ||
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ActiveKettleComponent, ComponentStartup>(OnBoilStart); | ||
SubscribeLocalEvent<ActiveKettleComponent, ComponentShutdown>(OnBoilStop); | ||
} | ||
|
||
public void OnBoilStart(Entity<ActiveKettleComponent> ent, ref ComponentStartup args) | ||
{ | ||
if (!TryComp<KettleComponent>(ent, out var kettleComponent)) | ||
return; | ||
SetAppearance(ent.Owner, KettleVisualState.Boiling, kettleComponent); | ||
|
||
kettleComponent.PlayingStream = | ||
_audio.PlayPvs(kettleComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5)).Value.Entity; | ||
} | ||
|
||
private void OnBoilStop(Entity<ActiveKettleComponent> ent, ref ComponentShutdown args) | ||
{ | ||
if (!TryComp<KettleComponent>(ent, out var kettleComponent)) | ||
return; | ||
|
||
SetAppearance(ent.Owner, KettleVisualState.Idle, kettleComponent); | ||
kettleComponent.PlayingStream = _audio.Stop(kettleComponent.PlayingStream); | ||
} | ||
|
||
private void AddTemperature(KettleComponent component, float time) | ||
{ | ||
var heatToAdd = time * component.BaseHeatMultiplier; | ||
foreach (var entity in component.Storage.ContainedEntities) | ||
{ | ||
if (TryComp<TemperatureComponent>(entity, out var tempComp)) | ||
_temperature.ChangeHeat(entity, heatToAdd * component.ObjectHeatMultiplier, false, tempComp); | ||
|
||
if (!TryComp<SolutionContainerManagerComponent>(entity, out var solutions)) | ||
continue; | ||
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((entity, solutions))) | ||
{ | ||
var solution = soln.Comp.Solution; | ||
if (solution.Temperature > component.TemperatureUpperThreshold) | ||
continue; | ||
|
||
_solutionContainer.AddThermalEnergy(soln, heatToAdd); | ||
} | ||
} | ||
} | ||
|
||
private void SubtractContents(KettleComponent component, DrinkRecipePrototype recipe) | ||
{ | ||
|
||
var totalReagentsToRemove = new Dictionary<string, FixedPoint2>(recipe.Reagents); | ||
|
||
// yoinked this spaghetti from microwaves :p | ||
foreach (var item in component.Storage.ContainedEntities) | ||
{ | ||
if (!TryComp<SolutionContainerManagerComponent>(item, out var solMan)) | ||
continue; | ||
|
||
// go over every solution | ||
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((item, solMan))) | ||
{ | ||
var solution = soln.Comp.Solution; | ||
foreach (var (reagent, _) in recipe.Reagents) | ||
{ | ||
// removed everything | ||
if (!totalReagentsToRemove.ContainsKey(reagent)) | ||
continue; | ||
|
||
var quant = solution.GetTotalPrototypeQuantity(reagent); | ||
|
||
if (quant >= totalReagentsToRemove[reagent]) | ||
{ | ||
quant = totalReagentsToRemove[reagent]; | ||
totalReagentsToRemove.Remove(reagent); | ||
} | ||
else | ||
{ | ||
totalReagentsToRemove[reagent] -= quant; | ||
} | ||
|
||
_solutionContainer.RemoveReagent(soln, reagent, quant); | ||
} | ||
} | ||
} | ||
|
||
foreach (var recipeLeaf in recipe.Leaves) | ||
{ | ||
for (var i = 0; i < recipeLeaf.Value; i++) | ||
{ | ||
foreach (var item in component.Storage.ContainedEntities) | ||
{ | ||
var metaData = MetaData(item); | ||
if (metaData.EntityPrototype == null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (metaData.EntityPrototype.ID == recipeLeaf.Key) | ||
{ | ||
_container.Remove(item, component.Storage); | ||
EntityManager.DeleteEntity(item); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static bool HasContents(KettleComponent component) | ||
{ | ||
return component.Storage.ContainedEntities.Any(); | ||
} | ||
private void OnInit(Entity<KettleComponent> ent, ref ComponentInit args) | ||
{ | ||
// this does have to be in ComponentInit, do I know why? No :3 | ||
ent.Comp.Storage = _container.EnsureContainer<Container>(ent, "storagebase"); | ||
} | ||
|
||
public void SetAppearance(EntityUid uid, KettleVisualState state, KettleComponent? component = null, AppearanceComponent? appearanceComponent = null) | ||
{ | ||
if (!Resolve(uid, ref component, ref appearanceComponent, false)) | ||
return; | ||
_appearance.SetData(uid, PowerDeviceVisuals.VisualState, state, appearanceComponent); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.Kitchen.Components | ||
{ | ||
|
||
[Serializable, NetSerializable] | ||
public enum KettleVisualState | ||
{ | ||
Idle, | ||
Boiling | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Content.Shared.Chemistry.Reagent; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; | ||
|
||
namespace Content.Shared.Kitchen | ||
{ | ||
/// <summary> | ||
/// Kettle Recipes, teas and stuff | ||
/// </summary> | ||
|
||
[Prototype("kettleDrinkRecipe")] | ||
public sealed partial class DrinkRecipePrototype : IPrototype | ||
{ | ||
[ViewVariables] | ||
[IdDataField] | ||
public string ID { get; private set; } = default!; | ||
|
||
|
||
[DataField("minTemp")] | ||
public float MinimumTemperature = 0.0f; | ||
|
||
[DataField("name")] | ||
private string _name = string.Empty; | ||
|
||
[DataField("reagents")] | ||
public Dictionary<string, FixedPoint2> Reagents { get; private set; } = new(); | ||
|
||
[DataField("leaves")] | ||
public IReadOnlyDictionary<string, FixedPoint2> Leaves => Leaves; | ||
|
||
[DataField("products")] | ||
public Dictionary<string, FixedPoint2> Products { get; private set; } = new(); | ||
|
||
public string Name => Loc.GetString(_name); | ||
|
||
[DataDefinition] | ||
public sealed partial class ReactantPrototype | ||
{ | ||
[DataField("amount")] | ||
private FixedPoint2 _amount = FixedPoint2.New(1); | ||
|
||
public FixedPoint2 Amount => _amount; | ||
} | ||
public FixedPoint2 IngredientCount() | ||
{ | ||
FixedPoint2 n = 0; | ||
n += Reagents.Count; // number of distinct reagents | ||
foreach (FixedPoint2 i in Leaves.Values) // sum the number of solid ingredients | ||
{ | ||
n += i; | ||
} | ||
return n; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
reagent-name-azaleatea = azalea tea | ||
reagent-desc-azaleatea = A tea made of azalea flowers. |
Oops, something went wrong.