Skip to content

Commit

Permalink
this doesn't even build lol ignore this
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyScarecrow committed Aug 9, 2024
1 parent 014efe5 commit e7e4b55
Show file tree
Hide file tree
Showing 35 changed files with 518 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Chat/SuicideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public bool Suicide(EntityUid victim)
if (suicideEvent.AttemptBlocked)
return false;

DefaultSuicideHandler(victim, suicideEvent);
DefaultSuicideHandler(victim, Event);

ApplyDeath(victim, suicideEvent.Kind!.Value);
_adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(victim):player} suicided{(environmentSuicide ? " (environment)" : "")}");
Expand Down
13 changes: 13 additions & 0 deletions Content.Server/Kitchen/Components/ActiveKettleComponent.cs
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 Content.Server/Kitchen/Components/ActivelyBoilingComponent.cs
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
{
}
62 changes: 62 additions & 0 deletions Content.Server/Kitchen/Components/KettleComponent.cs
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;
}
}
}
177 changes: 177 additions & 0 deletions Content.Server/Kitchen/EntitySystems/KettleSystem.cs
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);
}
}
}
12 changes: 12 additions & 0 deletions Content.Shared/Kitchen/Components/SharedKettle.cs
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
}
}
58 changes: 58 additions & 0 deletions Content.Shared/Kitchen/KettleRecipePrototype.cs
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;
}
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed partial class FoodRecipePrototype : IPrototype
[DataField("name")]
private string _name = string.Empty;

[DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<FixedPoint2, ReagentPrototype>))]
[DataField("reagents", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, ReagentPrototype>))]
private Dictionary<string, FixedPoint2> _ingsReagents = new();

[DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, EntityPrototype>))]
Expand Down
Binary file not shown.
Binary file added Resources/Audio/Items/Kettle/kettle_done.ogg
Binary file not shown.
Binary file added Resources/Audio/Items/Kettle/kettle_switch_on.ogg
Binary file not shown.
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/flavors/flavor-profiles.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ flavor-complex-antifreeze = warm
### This is exactly what pilk tastes like. I'm not even joking. I might've been a little drunk though
flavor-complex-pilk = like sweet milk
## Tastes
flavor-complex-azalea-tea = like sweet flowers
# Medicine/chemical-specific flavors.

## Generic flavors.
Expand Down
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/reagents/meta/physical-desc.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ reagent-physical-desc-alkaline = alkaline
reagent-physical-desc-aromatic = aromatic
reagent-physical-desc-bee-guts = bee guts
reagent-physical-desc-blazing = blazing
reagent-physical-desc-bright = bright
reagent-physical-desc-bubbling = bubbling
reagent-physical-desc-bubbly = bubbly
reagent-physical-desc-burning = burning
Expand Down Expand Up @@ -93,7 +94,6 @@ reagent-physical-desc-tangy = tangy
reagent-physical-desc-tart = tart
reagent-physical-desc-thick = thick
reagent-physical-desc-thick-and-grainy = thick and grainy
reagent-physical-desc-translucent = translucent
reagent-physical-desc-tropical = tropical
reagent-physical-desc-vibrant = vibrant
reagent-physical-desc-viscous = viscous
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/reagents/meta/tea.ftl
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.
Loading

0 comments on commit e7e4b55

Please sign in to comment.