diff --git a/Content.Client/Kitchen/Components/MicrowaveComponent.cs b/Content.Client/Kitchen/Components/MicrowaveComponent.cs deleted file mode 100644 index 7b666f9182..0000000000 --- a/Content.Client/Kitchen/Components/MicrowaveComponent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Content.Shared.Kitchen.Components; -using Robust.Shared.Audio; - -namespace Content.Client.Kitchen.Components -{ - [RegisterComponent] - public sealed class MicrowaveComponent : SharedMicrowaveComponent - { - public IPlayingAudioStream? PlayingStream { get; set; } - - [DataField("loopingSound")] - public SoundSpecifier LoopingSound = new SoundPathSpecifier("/Audio/Machines/microwave_loop.ogg"); - } -} diff --git a/Content.Client/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Client/Kitchen/EntitySystems/MicrowaveSystem.cs deleted file mode 100644 index 16e8579840..0000000000 --- a/Content.Client/Kitchen/EntitySystems/MicrowaveSystem.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Content.Client.Kitchen.Components; -using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.Player; - -namespace Content.Client.Kitchen.EntitySystems -{ - public sealed class MicrowaveSystem : EntitySystem - { - public void StartSoundLoop(MicrowaveComponent microwave) - { - StopSoundLoop(microwave); - - microwave.PlayingStream = SoundSystem.Play(microwave.LoopingSound.GetSound(), Filter.Local(), - microwave.Owner, AudioParams.Default.WithMaxDistance(5).WithLoop(true)); - } - - public void StopSoundLoop(MicrowaveComponent microwave) - { - microwave.PlayingStream?.Stop(); - } - } -} diff --git a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs index 5397bbcb87..be2f8440c7 100644 --- a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs +++ b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs @@ -10,7 +10,6 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Prototypes; -using static Content.Shared.Kitchen.Components.SharedMicrowaveComponent; namespace Content.Client.Kitchen.UI { diff --git a/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs b/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs deleted file mode 100644 index 93d66e0d3d..0000000000 --- a/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Content.Client.Kitchen.Components; -using Content.Client.Kitchen.EntitySystems; -using Content.Shared.Kitchen.Components; -using Content.Shared.Power; -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Log; - -namespace Content.Client.Kitchen.Visualizers -{ - [UsedImplicitly] - public sealed class MicrowaveVisualizer : AppearanceVisualizer - { - [Obsolete("Subscribe to AppearanceChangeEvent instead.")] - public override void OnChangeData(AppearanceComponent component) - { - base.OnChangeData(component); - var entMan = IoCManager.Resolve(); - var sprite = entMan.GetComponent(component.Owner); - - var microwaveComponent = entMan.GetComponentOrNull(component.Owner); - - if (!component.TryGetData(PowerDeviceVisuals.VisualState, out MicrowaveVisualState state)) - { - state = MicrowaveVisualState.Idle; - } - // The only reason we get the entity system so late is so that tests don't fail... Amazing, huh? - switch (state) - { - case MicrowaveVisualState.Broken: - sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mwb"); - if(microwaveComponent != null) - EntitySystem.Get().StopSoundLoop(microwaveComponent); - break; - - case MicrowaveVisualState.Idle: - sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw"); - sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit"); - if(microwaveComponent != null) - EntitySystem.Get().StopSoundLoop(microwaveComponent); - break; - - case MicrowaveVisualState.Cooking: - sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw"); - sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_running_unlit"); - if(microwaveComponent != null) - EntitySystem.Get().StartSoundLoop(microwaveComponent); - break; - - default: - Logger.Debug($"Something terrible happened in {this}"); - break; - - } - - var glowingPartsVisible = !(component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) && !powered); - sprite.LayerSetVisible(MicrowaveVisualizerLayers.BaseUnlit, glowingPartsVisible); - } - - private enum MicrowaveVisualizerLayers : byte - { - Base, - BaseUnlit - } - } - - -} diff --git a/Content.Client/Kitchen/Visualizers/MicrowaveVisuals.cs b/Content.Client/Kitchen/Visualizers/MicrowaveVisuals.cs new file mode 100644 index 0000000000..539cd0560c --- /dev/null +++ b/Content.Client/Kitchen/Visualizers/MicrowaveVisuals.cs @@ -0,0 +1,8 @@ +namespace Content.Client.Kitchen.Visualizers; + +public enum MicrowaveVisualizerLayers : byte +{ + Base, + BaseUnlit +} + diff --git a/Content.IntegrationTests/Tests/PrototypeSaveTest.cs b/Content.IntegrationTests/Tests/PrototypeSaveTest.cs index 617d55069d..8522b72a91 100644 --- a/Content.IntegrationTests/Tests/PrototypeSaveTest.cs +++ b/Content.IntegrationTests/Tests/PrototypeSaveTest.cs @@ -129,7 +129,6 @@ public sealed class PrototypeSaveTest "UniformPrinter", "OreProcessor", "MedicalScanner", - "KitchenMicrowave", "MagazinePistolSubMachineGunTopMounted", "Recycler", "EpinephrineChemistryBottle", @@ -235,7 +234,7 @@ public sealed class PrototypeSaveTest { uid = entityMan.SpawnEntity(prototype.ID, testLocation); server.RunTicks(1); - + // get default prototype data Dictionary protoData = new(); try diff --git a/Content.Server/Kitchen/Components/ActiveMicrowaveComponent.cs b/Content.Server/Kitchen/Components/ActiveMicrowaveComponent.cs new file mode 100644 index 0000000000..e8cfe86ab3 --- /dev/null +++ b/Content.Server/Kitchen/Components/ActiveMicrowaveComponent.cs @@ -0,0 +1,19 @@ +using Content.Shared.Kitchen; + +namespace Content.Server.Kitchen.Components; + +/// +/// Attached to a microwave that is currently in the process of cooking +/// +[RegisterComponent] +public sealed class ActiveMicrowaveComponent : Component +{ + [ViewVariables(VVAccess.ReadWrite)] + public float CookTimeRemaining; + + [ViewVariables(VVAccess.ReadWrite)] + public float TotalTime; + + [ViewVariables] + public (FoodRecipePrototype?, int) PortionedRecipe; +} diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 60e2facc2c..1a613aad15 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -1,49 +1,34 @@ -using System.Linq; -using Content.Server.Chemistry.Components.SolutionManager; -using Content.Server.Chemistry.EntitySystems; -using Content.Server.Power.Components; -using Content.Server.Temperature.Components; -using Content.Server.Temperature.Systems; -using Content.Server.UserInterface; -using Content.Shared.FixedPoint; -using Content.Shared.Kitchen; -using Content.Shared.Kitchen.Components; -using Content.Shared.Power; -using Content.Shared.Tag; -using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; -using Robust.Shared.Player; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Kitchen.Components { [RegisterComponent] - public sealed class MicrowaveComponent : SharedMicrowaveComponent + public sealed class MicrowaveComponent : Component { - [Dependency] private readonly IEntityManager _entities = default!; - - [Dependency] private readonly RecipeManager _recipeManager = default!; - - #region YAMLSERIALIZE - - [DataField("cookTime")] private uint _cookTimeDefault = 5; - [DataField("cookTimeMultiplier")] private int _cookTimeMultiplier = 1000; //For upgrades and stuff I guess? - [DataField("failureResult")] private string _badRecipeName = "FoodBadRecipe"; - - [DataField("beginCookingSound")] private SoundSpecifier _startCookingSound = - new SoundPathSpecifier("/Audio/Machines/microwave_start_beep.ogg"); - - [DataField("foodDoneSound")] private SoundSpecifier _cookingCompleteSound = - new SoundPathSpecifier("/Audio/Machines/microwave_done_beep.ogg"); + [DataField("cookTimeMultiplier")] + public int CookTimeMultiplier = 1; //For upgrades and stuff I guess? don't ask me. + [DataField("failureResult", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string BadRecipeEntityId = "FoodBadRecipe"; + #region audio + [DataField("beginCookingSound")] + public SoundSpecifier StartCookingSound = new SoundPathSpecifier("/Audio/Machines/microwave_start_beep.ogg"); + [DataField("foodDoneSound")] + public SoundSpecifier FoodDoneSound = new SoundPathSpecifier("/Audio/Machines/microwave_done_beep.ogg"); [DataField("clickSound")] - private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); - + public SoundSpecifier ClickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("ItemBreakSound")] public SoundSpecifier ItemBreakSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg"); - #endregion YAMLSERIALIZE + public IPlayingAudioStream? PlayingStream { get; set; } + [DataField("loopingSound")] + public SoundSpecifier LoopingSound = new SoundPathSpecifier("/Audio/Machines/microwave_loop.ogg"); + #endregion - [ViewVariables] private bool _busy = false; + [ViewVariables] public bool Broken; /// @@ -51,7 +36,8 @@ namespace Content.Server.Kitchen.Components /// The cook times for all recipes should be divisible by 5,with a minimum of 1 second. /// For right now, I don't think any recipe cook time should be greater than 60 seconds. /// - [ViewVariables] private uint _currentCookTimerTime = 1; + [DataField("currentCookTimerTime"), ViewVariables(VVAccess.ReadWrite)] + public uint CurrentCookTimerTime = 5; /// /// The max temperature that this microwave can heat objects to. @@ -59,403 +45,9 @@ namespace Content.Server.Kitchen.Components [DataField("temperatureUpperThreshold")] public float TemperatureUpperThreshold = 373.15f; - public bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered; - - private bool HasContents => Storage.ContainedEntities.Count > 0; - - public bool UIDirty = true; - private bool _lostPower; - private int _currentCookTimeButtonIndex; - - public void DirtyUi() - { - UIDirty = true; - } + public int CurrentCookTimeButtonIndex; public Container Storage = default!; - - [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MicrowaveUiKey.Key); - - protected override void Initialize() - { - base.Initialize(); - - _currentCookTimerTime = _cookTimeDefault; - - Storage = ContainerHelpers.EnsureContainer(Owner, "microwave_entity_container", - out _); - - if (UserInterface != null) - { - UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage; - } - } - - public void SetCookTime(uint cookTime) - { - _currentCookTimerTime = cookTime; - UIDirty = true; - } - - private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message) - { - if (!Powered || _busy) - { - return; - } - - switch (message.Message) - { - case MicrowaveStartCookMessage: - Wzhzhzh(); - break; - case MicrowaveEjectMessage: - if (HasContents) - { - EjectSolids(); - ClickSound(); - UIDirty = true; - } - - break; - case MicrowaveEjectSolidIndexedMessage msg: - if (HasContents) - { - EjectSolid(msg.EntityID); - ClickSound(); - UIDirty = true; - } - break; - - case MicrowaveSelectCookTimeMessage msg: - _currentCookTimeButtonIndex = msg.ButtonIndex; - _currentCookTimerTime = msg.NewCookTime; - ClickSound(); - UIDirty = true; - break; - } - } - - public void OnUpdate() - { - if (!Powered) - { - //TODO:If someone cuts power currently, microwave magically keeps going. FIX IT! - SetAppearance(MicrowaveVisualState.Idle); - } - - if (_busy && !Powered) - { - //we lost power while we were cooking/busy! - _lostPower = true; - EjectSolids(); - _busy = false; - UIDirty = true; - } - - if (_busy && Broken) - { - SetAppearance(MicrowaveVisualState.Broken); - //we broke while we were cooking/busy! - _lostPower = true; - EjectSolids(); - _busy = false; - UIDirty = true; - } - - if (UIDirty) - { - UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState - ( - Storage.ContainedEntities.Select(item => item).ToArray(), - _busy, - _currentCookTimeButtonIndex, - _currentCookTimerTime - )); - UIDirty = false; - } - } - - public void SetAppearance(MicrowaveVisualState state) - { - var finalState = state; - if (Broken) - { - finalState = MicrowaveVisualState.Broken; - } - - if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearance)) - { - appearance.SetData(PowerDeviceVisuals.VisualState, finalState); - } - } - - // ReSharper disable once InconsistentNaming - // ReSharper disable once IdentifierTypo - public void Wzhzhzh() - { - if (!HasContents) - { - return; - } - - _busy = true; - // Convert storage into Dictionary of ingredients - var solidsDict = new Dictionary(); - var reagentDict = new Dictionary(); - foreach (var item in Storage.ContainedEntities) - { - // special behavior when being microwaved ;) - var ev = new BeingMicrowavedEvent(Owner); - _entities.EventBus.RaiseLocalEvent(item, ev, false); - - if (ev.Handled) - { - _busy = false; - UIDirty = true; - return; - } - - var tagSys = EntitySystem.Get(); - - if (tagSys.HasTag(item, "MicrowaveMachineUnsafe") - || tagSys.HasTag(item, "Metal")) - { - // destroy microwave - Broken = true; - SetAppearance(MicrowaveVisualState.Broken); - SoundSystem.Play(ItemBreakSound.GetSound(), Filter.Pvs(Owner), Owner); - return; - } - - if (tagSys.HasTag(item, "MicrowaveSelfUnsafe") - || tagSys.HasTag(item, "Plastic")) - { - _entities.SpawnEntity(_badRecipeName, - _entities.GetComponent(Owner).Coordinates); - _entities.QueueDeleteEntity(item); - } - - var metaData = _entities.GetComponent(item); - if (metaData.EntityPrototype == null) - { - continue; - } - - if (solidsDict.ContainsKey(metaData.EntityPrototype.ID)) - { - solidsDict[metaData.EntityPrototype.ID]++; - } - else - { - solidsDict.Add(metaData.EntityPrototype.ID, 1); - } - - if (!_entities.TryGetComponent(item, out var solMan)) - continue; - - foreach (var (_, solution) in solMan.Solutions) - { - foreach (var reagent in solution.Contents) - { - if (reagentDict.ContainsKey(reagent.ReagentId)) - reagentDict[reagent.ReagentId] += reagent.Quantity; - else - reagentDict.Add(reagent.ReagentId, reagent.Quantity); - } - } - } - - // Check recipes - (FoodRecipePrototype, int) portionedRecipe = _recipeManager.Recipes.Select( - r => CanSatisfyRecipe(r, solidsDict, reagentDict)).Where(r => r.Item2 > 0).FirstOrDefault(); - FoodRecipePrototype? recipeToCook = portionedRecipe.Item1; - - SetAppearance(MicrowaveVisualState.Cooking); - var time = _currentCookTimerTime * _cookTimeMultiplier; - SoundSystem.Play(_startCookingSound.GetSound(), Filter.Pvs(Owner), Owner, AudioParams.Default); - Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), () => - { - if (_lostPower) - { - return; - } - - AddTemperature(time); - - if (recipeToCook != null) - { - for (int i = 0; i < portionedRecipe.Item2; i++) - { - SubtractContents(recipeToCook); - _entities.SpawnEntity(recipeToCook.Result, - _entities.GetComponent(Owner).Coordinates); - } - } - - EjectSolids(); - - SoundSystem.Play(_cookingCompleteSound.GetSound(), Filter.Pvs(Owner), - Owner, AudioParams.Default.WithVolume(-1f)); - - SetAppearance(MicrowaveVisualState.Idle); - _busy = false; - - UIDirty = true; - }); - _lostPower = false; - UIDirty = true; - } - - /// - /// Adds temperature to every item in the microwave, - /// based on the time it took to microwave. - /// - /// The time on the microwave, in seconds. - public void AddTemperature(float time) - { - var solutionContainerSystem = EntitySystem.Get(); - foreach (var entity in Storage.ContainedEntities) - { - if (_entities.TryGetComponent(entity, out TemperatureComponent? temp)) - { - EntitySystem.Get().ChangeHeat(entity, time / 10, false, temp); - } - - if (_entities.TryGetComponent(entity, out SolutionContainerManagerComponent? solutions)) - { - foreach (var (_, solution) in solutions.Solutions) - { - if (solution.Temperature > TemperatureUpperThreshold) - continue; - - solutionContainerSystem.AddThermalEnergy(entity, solution, time / 10); - } - } - } - } - - private void EjectSolids() - { - for (var i = Storage.ContainedEntities.Count - 1; i >= 0; i--) - { - Storage.Remove(Storage.ContainedEntities.ElementAt(i)); - } - } - - private void EjectSolid(EntityUid entityId) - { - if (_entities.EntityExists(entityId)) - { - Storage.Remove(entityId); - } - } - - private void SubtractContents(FoodRecipePrototype recipe) - { - var totalReagentsToRemove = new Dictionary(recipe.IngredientsReagents); - var solutionContainerSystem = EntitySystem.Get(); - - // this is spaghetti ngl - foreach (var item in Storage.ContainedEntities) - { - if (!_entities.TryGetComponent(item, out var solMan)) - continue; - - // go over every solution - foreach (var (_, solution) in solMan.Solutions) - { - foreach (var (reagent, _) in recipe.IngredientsReagents) - { - // removed everything - if (!totalReagentsToRemove.ContainsKey(reagent)) - continue; - - if (!solution.ContainsReagent(reagent)) - continue; - - var quant = solution.GetReagentQuantity(reagent); - - if (quant >= totalReagentsToRemove[reagent]) - { - quant = totalReagentsToRemove[reagent]; - totalReagentsToRemove.Remove(reagent); - } - else - { - totalReagentsToRemove[reagent] -= quant; - } - - solutionContainerSystem.TryRemoveReagent(item, solution, reagent, quant); - } - } - } - - foreach (var recipeSolid in recipe.IngredientsSolids) - { - for (var i = 0; i < recipeSolid.Value; i++) - { - foreach (var item in Storage.ContainedEntities) - { - var metaData = _entities.GetComponent(item); - if (metaData.EntityPrototype == null) - { - continue; - } - - if (metaData.EntityPrototype.ID == recipeSolid.Key) - { - Storage.Remove(item); - _entities.DeleteEntity(item); - break; - } - } - } - } - } - - private (FoodRecipePrototype, int) CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary solids, Dictionary reagents) - { - int portions = 0; - - if(_currentCookTimerTime % recipe.CookTime != 0) - { - //can't be a multiple of this recipe - return (recipe, 0); - } - - foreach (var solid in recipe.IngredientsSolids) - { - if (!solids.ContainsKey(solid.Key)) - return (recipe, 0); - - if (solids[solid.Key] < solid.Value) - return (recipe, 0); - else - portions = portions == 0 ? solids[solid.Key] / solid.Value.Int() - : Math.Min(portions, solids[solid.Key] / solid.Value.Int()); - } - - foreach (var reagent in recipe.IngredientsReagents) - { - if (!reagents.ContainsKey(reagent.Key)) - return (recipe, 0); - - if (reagents[reagent.Key] < reagent.Value) - return (recipe, 0); - else - portions = portions == 0 ? reagents[reagent.Key].Int() / reagent.Value.Int() - : Math.Min(portions, reagents[reagent.Key].Int() / reagent.Value.Int()); - } - - //cook only as many of those portions as time allows - return (recipe, (int)Math.Min(portions, _currentCookTimerTime / recipe.CookTime)); - } - - public void ClickSound() - { - SoundSystem.Play(_clickSound.GetSound(), Filter.Pvs(Owner), Owner, AudioParams.Default.WithVolume(-2f)); - } } public sealed class BeingMicrowavedEvent : HandledEntityEventArgs diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 78d762d98f..97e0fac8ca 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -1,45 +1,187 @@ +using System.Linq; +using Content.Server.Chemistry.Components.SolutionManager; using Content.Server.Chemistry.EntitySystems; using Content.Server.Construction; using Content.Server.Kitchen.Components; -using Content.Server.Popups; using Content.Shared.Destructible; using Content.Shared.Interaction; using Content.Shared.Item; using Content.Shared.Kitchen.Components; using Robust.Shared.Player; -using JetBrains.Annotations; using Content.Shared.Interaction.Events; using Content.Shared.Body.Components; using Content.Shared.Body.Part; -using Content.Shared.Popups; using Content.Server.Hands.Systems; +using Content.Server.Power.Components; +using Content.Server.Temperature.Components; +using Content.Server.Temperature.Systems; +using Content.Shared.FixedPoint; +using Content.Shared.Kitchen; +using Content.Shared.Popups; +using Content.Shared.Power; +using Content.Shared.Tag; +using Robust.Server.Containers; +using Robust.Server.GameObjects; +using Robust.Shared.Audio; +using Robust.Shared.Containers; namespace Content.Server.Kitchen.EntitySystems { - [UsedImplicitly] - internal sealed class MicrowaveSystem : EntitySystem + public sealed class MicrowaveSystem : EntitySystem { - [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly ContainerSystem _container = default!; + [Dependency] private readonly SharedPopupSystem _popupSystem = default!; + [Dependency] private readonly RecipeManager _recipeManager = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedContainerSystem _sharedContainer = default!; + [Dependency] private readonly SolutionContainerSystem _solutionContainer = default!; + [Dependency] private readonly TagSystem _tag = default!; + [Dependency] private readonly TemperatureSystem _temperature = default!; + [Dependency] private readonly UserInterfaceSystem _userInterface = default!; [Dependency] private readonly HandsSystem _handsSystem = default!; public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnSolutionChange); SubscribeLocalEvent(OnInteractUsing, after: new[]{typeof(AnchorableSystem)}); SubscribeLocalEvent(OnBreak); + SubscribeLocalEvent(OnPowerChanged); SubscribeLocalEvent(OnSuicide); + + SubscribeLocalEvent((u,c,_) => Wzhzhzh(u,c)); + SubscribeLocalEvent(OnEjectMessage); + SubscribeLocalEvent(OnEjectIndex); + SubscribeLocalEvent(OnSelectTime); + + SubscribeLocalEvent(OnCookStart); + SubscribeLocalEvent(OnCookStop); + } + + private void OnCookStart(EntityUid uid, ActiveMicrowaveComponent component, ComponentStartup args) + { + if (!TryComp(uid, out var microwaveComponent)) + return; + SetAppearance(microwaveComponent, MicrowaveVisualState.Cooking); + + microwaveComponent.PlayingStream = + _audio.Play(microwaveComponent.LoopingSound, Filter.Pvs(uid), uid, AudioParams.Default.WithLoop(true).WithMaxDistance(5)); + } + + private void OnCookStop(EntityUid uid, ActiveMicrowaveComponent component, ComponentShutdown args) + { + if (!TryComp(uid, out var microwaveComponent)) + return; + SetAppearance(microwaveComponent, MicrowaveVisualState.Idle); + + microwaveComponent.PlayingStream?.Stop(); + } + + /// + /// Adds temperature to every item in the microwave, + /// based on the time it took to microwave. + /// + /// The microwave that is heating up. + /// The time on the microwave, in seconds. + private void AddTemperature(MicrowaveComponent component, float time) + { + foreach (var entity in component.Storage.ContainedEntities) + { + if (TryComp(entity, out var tempComp)) + _temperature.ChangeHeat(entity, time / 10, false, tempComp); + + if (!TryComp(entity, out var solutions)) + continue; + foreach (var (_, solution) in solutions.Solutions) + { + if (solution.Temperature > component.TemperatureUpperThreshold) + continue; + + _solutionContainer.AddThermalEnergy(entity, solution, time / 10); + } + } + } + + private void SubtractContents(MicrowaveComponent component, FoodRecipePrototype recipe) + { + var totalReagentsToRemove = new Dictionary(recipe.IngredientsReagents); + + // this is spaghetti ngl + foreach (var item in component.Storage.ContainedEntities) + { + if (!TryComp(item, out var solMan)) + continue; + + // go over every solution + foreach (var (_, solution) in solMan.Solutions) + { + foreach (var (reagent, _) in recipe.IngredientsReagents) + { + // removed everything + if (!totalReagentsToRemove.ContainsKey(reagent)) + continue; + + if (!solution.ContainsReagent(reagent)) + continue; + + var quant = solution.GetReagentQuantity(reagent); + + if (quant >= totalReagentsToRemove[reagent]) + { + quant = totalReagentsToRemove[reagent]; + totalReagentsToRemove.Remove(reagent); + } + else + { + totalReagentsToRemove[reagent] -= quant; + } + + _solutionContainer.TryRemoveReagent(item, solution, reagent, quant); + } + } + } + + foreach (var recipeSolid in recipe.IngredientsSolids) + { + for (var i = 0; i < recipeSolid.Value; i++) + { + foreach (var item in component.Storage.ContainedEntities) + { + var metaData = MetaData(item); + if (metaData.EntityPrototype == null) + { + continue; + } + + if (metaData.EntityPrototype.ID == recipeSolid.Key) + { + component.Storage.Remove(item); + EntityManager.DeleteEntity(item); + break; + } + } + } + } + } + + private void OnInit(EntityUid uid, MicrowaveComponent component, ComponentInit ags) + { + component.Storage = _container.EnsureContainer(uid,"microwave_entity_container"); } private void OnSuicide(EntityUid uid, MicrowaveComponent component, SuicideEvent args) { - if (args.Handled) return; + if (args.Handled) + return; + args.SetHandled(SuicideKind.Heat); var victim = args.Victim; var headCount = 0; - if (TryComp(victim, out var body)) + if (TryComp(victim, out var body)) { var headSlots = body.GetSlotsOfType(BodyPartType.Head); @@ -69,36 +211,29 @@ namespace Content.Server.Kitchen.EntitySystems ? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim)) : Loc.GetString("microwave-component-suicide-others-message", ("victim", victim)); - victim.PopupMessageOtherClients(othersMessage); - var selfMessage = headCount > 1 ? Loc.GetString("microwave-component-suicide-multi-head-message") : Loc.GetString("microwave-component-suicide-message"); - victim.PopupMessage(selfMessage); - component.ClickSound(); - component.SetCookTime(10); - component.Wzhzhzh(); + _popupSystem.PopupEntity(othersMessage, victim, Filter.PvsExcept(victim)); + _popupSystem.PopupEntity(selfMessage, victim, Filter.Entities(victim)); + + _audio.PlayPvs(component.ClickSound, uid, AudioParams.Default.WithVolume(-2)); + component.CurrentCookTimerTime = 10; + Wzhzhzh(uid, component); + UpdateUserInterfaceState(uid, component); } private void OnSolutionChange(EntityUid uid, MicrowaveComponent component, SolutionChangedEvent args) { - component.DirtyUi(); - } - - public override void Update(float frameTime) - { - base.Update(frameTime); - foreach (var comp in EntityManager.EntityQuery()) - { - comp.OnUpdate(); - } + UpdateUserInterfaceState(uid, component); } private void OnInteractUsing(EntityUid uid, MicrowaveComponent component, InteractUsingEvent args) { - if(args.Handled) return; - if (!component.Powered) + if(args.Handled) + return; + if (!(TryComp(uid, out var apc) && apc.Powered)) { _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-no-power"), uid, Filter.Entities(args.User)); return; @@ -118,13 +253,236 @@ namespace Content.Server.Kitchen.EntitySystems args.Handled = true; _handsSystem.TryDropIntoContainer(args.User, args.Used, component.Storage); - component.DirtyUi(); + UpdateUserInterfaceState(uid, component); } private void OnBreak(EntityUid uid, MicrowaveComponent component, BreakageEventArgs args) { component.Broken = true; - component.SetAppearance(MicrowaveVisualState.Broken); + SetAppearance(component, MicrowaveVisualState.Broken); + RemComp(uid); + _sharedContainer.EmptyContainer(component.Storage); + UpdateUserInterfaceState(uid, component); } + + private void OnPowerChanged(EntityUid uid, MicrowaveComponent component, PowerChangedEvent args) + { + if (!args.Powered) + { + SetAppearance(component, MicrowaveVisualState.Idle); + RemComp(uid); + _sharedContainer.EmptyContainer(component.Storage); + } + UpdateUserInterfaceState(uid, component); + } + + public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component) + { + var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key); + if (ui == null) + return; + var state = new MicrowaveUpdateUserInterfaceState( + component.Storage.ContainedEntities.ToArray(), + HasComp(uid), + component.CurrentCookTimeButtonIndex, + component.CurrentCookTimerTime + ); + _userInterface.SetUiState(ui, state); + } + + public void SetAppearance(MicrowaveComponent component, MicrowaveVisualState state) + { + var display = component.Broken ? MicrowaveVisualState.Broken : state; + _appearance.SetData(component.Owner, PowerDeviceVisuals.VisualState, display); + } + + public bool HasContents(MicrowaveComponent component) + { + return component.Storage.ContainedEntities.Any(); + } + + /// + /// Starts Cooking + /// + /// + /// It does not make a "wzhzhzh" sound, it makes a "mmmmmmmm" sound! + /// -emo + /// + public void Wzhzhzh(EntityUid uid, MicrowaveComponent component) + { + if (!HasContents(component) || HasComp(uid)) + return; + + var solidsDict = new Dictionary(); + var reagentDict = new Dictionary(); + foreach (var item in component.Storage.ContainedEntities) + { + // special behavior when being microwaved ;) + var ev = new BeingMicrowavedEvent(uid); + RaiseLocalEvent(item, ev); + + if (ev.Handled) + { + UpdateUserInterfaceState(uid, component); + return; + } + + // destroy microwave + if (_tag.HasTag(item, "MicrowaveMachineUnsafe") || _tag.HasTag(item, "Metal")) + { + component.Broken = true; + SetAppearance(component, MicrowaveVisualState.Broken); + _audio.PlayPvs(component.ItemBreakSound, uid); + return; + } + + if (_tag.HasTag(item, "MicrowaveSelfUnsafe") || _tag.HasTag(item, "Plastic")) + { + var junk = Spawn(component.BadRecipeEntityId, Transform(uid).Coordinates); + component.Storage.Insert(junk); + QueueDel(item); + } + + var metaData = MetaData(item); //this simply begs for cooking refactor + if (metaData.EntityPrototype == null) + continue; + + if (solidsDict.ContainsKey(metaData.EntityPrototype.ID)) + { + solidsDict[metaData.EntityPrototype.ID]++; + } + else + { + solidsDict.Add(metaData.EntityPrototype.ID, 1); + } + + if (!TryComp(item, out var solMan)) + continue; + + foreach (var (_, solution) in solMan.Solutions) + { + foreach (var reagent in solution.Contents) + { + if (reagentDict.ContainsKey(reagent.ReagentId)) + reagentDict[reagent.ReagentId] += reagent.Quantity; + else + reagentDict.Add(reagent.ReagentId, reagent.Quantity); + } + } + } + + // Check recipes + var portionedRecipe = _recipeManager.Recipes.Select(r => + CanSatisfyRecipe(component, r, solidsDict, reagentDict)).FirstOrDefault(r => r.Item2 > 0); + + _audio.PlayPvs(component.StartCookingSound, uid); + var activeComp = AddComp(uid); //microwave is now cooking + activeComp.CookTimeRemaining = component.CurrentCookTimerTime * component.CookTimeMultiplier; + activeComp.TotalTime = component.CurrentCookTimerTime * component.CookTimeMultiplier; + activeComp.PortionedRecipe = portionedRecipe; + UpdateUserInterfaceState(uid, component); + } + + public (FoodRecipePrototype, int) CanSatisfyRecipe(MicrowaveComponent component, FoodRecipePrototype recipe, Dictionary solids, Dictionary reagents) + { + var portions = 0; + + if(component.CurrentCookTimerTime % recipe.CookTime != 0) + { + //can't be a multiple of this recipe + return (recipe, 0); + } + + foreach (var solid in recipe.IngredientsSolids) + { + if (!solids.ContainsKey(solid.Key)) + return (recipe, 0); + + if (solids[solid.Key] < solid.Value) + return (recipe, 0); + + portions = portions == 0 + ? solids[solid.Key] / solid.Value.Int() + : Math.Min(portions, solids[solid.Key] / solid.Value.Int()); + } + + foreach (var reagent in recipe.IngredientsReagents) + { + if (!reagents.ContainsKey(reagent.Key)) + return (recipe, 0); + + if (reagents[reagent.Key] < reagent.Value) + return (recipe, 0); + + portions = portions == 0 + ? reagents[reagent.Key].Int() / reagent.Value.Int() + : Math.Min(portions, reagents[reagent.Key].Int() / reagent.Value.Int()); + } + + //cook only as many of those portions as time allows + return (recipe, (int)Math.Min(portions, component.CurrentCookTimerTime / recipe.CookTime)); + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + foreach (var (active, microwave) in EntityManager.EntityQuery()) + { + //check if there's still cook time left + active.CookTimeRemaining -= frameTime; + if (active.CookTimeRemaining > 0) + continue; + + //this means the microwave has finished cooking. + AddTemperature(microwave, active.TotalTime); + + if (active.PortionedRecipe.Item1 != null) + { + var coords = Transform(microwave.Owner).Coordinates; + for (var i = 0; i < active.PortionedRecipe.Item2; i++) + { + SubtractContents(microwave, active.PortionedRecipe.Item1); + Spawn(active.PortionedRecipe.Item1.Result, coords); + } + } + + _sharedContainer.EmptyContainer(microwave.Storage); + UpdateUserInterfaceState(microwave.Owner, microwave); + EntityManager.RemoveComponentDeferred(active.Owner); + _audio.PlayPvs(microwave.FoodDoneSound, microwave.Owner, AudioParams.Default.WithVolume(-1)); + } + } + + #region ui + private void OnEjectMessage(EntityUid uid, MicrowaveComponent component, MicrowaveEjectMessage args) + { + if (!HasContents(component) || HasComp(uid)) + return; + + _sharedContainer.EmptyContainer(component.Storage); + _audio.PlayPvs(component.ClickSound, uid, AudioParams.Default.WithVolume(-2)); + UpdateUserInterfaceState(uid, component); + } + + private void OnEjectIndex(EntityUid uid, MicrowaveComponent component, MicrowaveEjectSolidIndexedMessage args) + { + if (!HasContents(component) || HasComp(uid)) + return; + + component.Storage.Remove(args.EntityID); + UpdateUserInterfaceState(uid, component); + } + + private void OnSelectTime(EntityUid uid, MicrowaveComponent component, MicrowaveSelectCookTimeMessage args) + { + if (!HasContents(component) || HasComp(uid) || !(TryComp(uid, out var apc) && apc.Powered)) + return; + + component.CurrentCookTimeButtonIndex = args.ButtonIndex; + component.CurrentCookTimerTime = args.NewCookTime; + _audio.PlayPvs(component.ClickSound, uid, AudioParams.Default.WithVolume(-2)); + UpdateUserInterfaceState(uid, component); + } + #endregion } } diff --git a/Content.Shared/Kitchen/Components/SharedMicrowave.cs b/Content.Shared/Kitchen/Components/SharedMicrowave.cs new file mode 100644 index 0000000000..6a5c10efa5 --- /dev/null +++ b/Content.Shared/Kitchen/Components/SharedMicrowave.cs @@ -0,0 +1,82 @@ +using Content.Shared.Chemistry.Components; +using Robust.Shared.Serialization; + +namespace Content.Shared.Kitchen.Components +{ + [Serializable, NetSerializable] + public sealed class MicrowaveStartCookMessage : BoundUserInterfaceMessage + { + } + + [Serializable, NetSerializable] + public sealed class MicrowaveEjectMessage : BoundUserInterfaceMessage + { + + } + + [Serializable, NetSerializable] + public sealed class MicrowaveEjectSolidIndexedMessage : BoundUserInterfaceMessage + { + public EntityUid EntityID; + public MicrowaveEjectSolidIndexedMessage(EntityUid entityId) + { + EntityID = entityId; + } + } + + [Serializable, NetSerializable] + public sealed class MicrowaveVaporizeReagentIndexedMessage : BoundUserInterfaceMessage + { + public Solution.ReagentQuantity ReagentQuantity; + public MicrowaveVaporizeReagentIndexedMessage(Solution.ReagentQuantity reagentQuantity) + { + ReagentQuantity = reagentQuantity; + } + } + + [Serializable, NetSerializable] + public sealed class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage + { + public int ButtonIndex; + public uint NewCookTime; + public MicrowaveSelectCookTimeMessage(int buttonIndex, uint inputTime) + { + ButtonIndex = buttonIndex; + NewCookTime = inputTime; + } + } + + [NetSerializable, Serializable] + public sealed class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState + { + public EntityUid[] ContainedSolids; + public bool IsMicrowaveBusy; + public int ActiveButtonIndex; + public uint CurrentCookTime; + + public MicrowaveUpdateUserInterfaceState(EntityUid[] containedSolids, + bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime) + { + ContainedSolids = containedSolids; + IsMicrowaveBusy = isMicrowaveBusy; + ActiveButtonIndex = activeButtonIndex; + CurrentCookTime = currentCookTime; + } + + } + + [Serializable, NetSerializable] + public enum MicrowaveVisualState + { + Idle, + Cooking, + Broken + } + + [NetSerializable, Serializable] + public enum MicrowaveUiKey + { + Key + } + +} diff --git a/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs b/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs deleted file mode 100644 index 4749b27a95..0000000000 --- a/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Content.Shared.Chemistry.Components; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; - -namespace Content.Shared.Kitchen.Components -{ - - [NetworkedComponent()] - public abstract class SharedMicrowaveComponent : Component - { - [Serializable, NetSerializable] - public sealed class MicrowaveStartCookMessage : BoundUserInterfaceMessage - { - public MicrowaveStartCookMessage() - { - } - } - - [Serializable, NetSerializable] - public sealed class MicrowaveEjectMessage : BoundUserInterfaceMessage - { - public MicrowaveEjectMessage() - { - } - } - - [Serializable, NetSerializable] - public sealed class MicrowaveEjectSolidIndexedMessage : BoundUserInterfaceMessage - { - - public EntityUid EntityID; - public MicrowaveEjectSolidIndexedMessage(EntityUid entityID) - { - EntityID = entityID; - } - } - - [Serializable, NetSerializable] - public sealed class MicrowaveVaporizeReagentIndexedMessage : BoundUserInterfaceMessage - { - - public Solution.ReagentQuantity ReagentQuantity; - public MicrowaveVaporizeReagentIndexedMessage(Solution.ReagentQuantity reagentQuantity) - { - ReagentQuantity = reagentQuantity; - } - } - [Serializable, NetSerializable] - public sealed class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage - { - public int ButtonIndex; - public uint NewCookTime; - public MicrowaveSelectCookTimeMessage(int buttonIndex, uint inputTime) - { - ButtonIndex = buttonIndex; - NewCookTime = inputTime; - } - } - } - - [NetSerializable, Serializable] - public sealed class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState - { - public EntityUid[] ContainedSolids; - public bool IsMicrowaveBusy; - public int ActiveButtonIndex; - public uint CurrentCookTime; - - public MicrowaveUpdateUserInterfaceState(EntityUid[] containedSolids, - bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime) - { - ContainedSolids = containedSolids; - IsMicrowaveBusy = isMicrowaveBusy; - ActiveButtonIndex = activeButtonIndex; - CurrentCookTime = currentCookTime; - } - - } - - [Serializable, NetSerializable] - public enum MicrowaveVisualState - { - Idle, - Cooking, - Broken - } - - [NetSerializable, Serializable] - public enum MicrowaveUiKey - { - Key - } - -} diff --git a/Resources/Maps/bagel.yml b/Resources/Maps/bagel.yml index 66ecc3e3b0..ea64de9d4b 100644 --- a/Resources/Maps/bagel.yml +++ b/Resources/Maps/bagel.yml @@ -38450,10 +38450,6 @@ entities: - pos: -63.5,-11.5 parent: 60 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2049 type: BodyBag_Container components: @@ -42656,10 +42652,6 @@ entities: - pos: 25.5,-30.5 parent: 60 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2609 type: Table components: @@ -42684,10 +42676,6 @@ entities: - pos: 25.5,-34.5 parent: 60 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2613 type: KitchenReagentGrinder components: @@ -83863,10 +83851,6 @@ entities: - pos: -34.5,2.5 parent: 60 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 8381 type: ShuttersNormalOpen components: @@ -114937,10 +114921,6 @@ entities: - pos: 51.5,18.5 parent: 60 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 13215 type: Table components: @@ -132555,10 +132535,6 @@ entities: - pos: 6.5,21.5 parent: 60 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 15714 type: FoodBoxDonkpocketPizza components: diff --git a/Resources/Maps/box.yml b/Resources/Maps/box.yml index 11557e2f77..31bab46b11 100644 --- a/Resources/Maps/box.yml +++ b/Resources/Maps/box.yml @@ -4442,10 +4442,6 @@ entities: - pos: 26.5,-86.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 595 type: ComputerPowerMonitoring components: @@ -35750,10 +35746,6 @@ entities: - pos: 13.5,30.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 5577 type: DonkpocketBoxSpawner components: @@ -50184,10 +50176,6 @@ entities: - pos: 39.5,-4.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 7234 type: TableReinforced components: @@ -50228,10 +50216,6 @@ entities: - pos: 38.5,-4.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 7238 type: PoweredSmallLight components: @@ -89462,10 +89446,6 @@ entities: - pos: -10.5,41.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 9068 type: KitchenReagentGrinder components: @@ -126236,10 +126216,6 @@ entities: - pos: -33.5,18.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 13239 type: TableWood components: @@ -146363,10 +146339,6 @@ entities: - pos: -38.5,-45.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 15578 type: Barricade components: @@ -158083,10 +158055,6 @@ entities: - pos: 7.5,-50.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 17019 type: Table components: @@ -164461,10 +164429,6 @@ entities: - pos: -29.5,-15.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 17762 type: Table components: @@ -176840,10 +176804,6 @@ entities: - pos: 34.5,-52.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 19245 type: FoodBoxDonkpocket components: @@ -177196,10 +177156,6 @@ entities: - pos: 46.5,-47.5 parent: 8364 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 19295 type: FoodBoxDonkpocket components: diff --git a/Resources/Maps/centcomm.yml b/Resources/Maps/centcomm.yml index a89dc6897b..5b8e5a9532 100644 --- a/Resources/Maps/centcomm.yml +++ b/Resources/Maps/centcomm.yml @@ -24507,10 +24507,6 @@ entities: - pos: 43.5,38.5 parent: 55 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2881 type: KitchenReagentGrinder components: diff --git a/Resources/Maps/infiltrator.yml b/Resources/Maps/infiltrator.yml index 538e41a388..c0e7a9f3fa 100644 --- a/Resources/Maps/infiltrator.yml +++ b/Resources/Maps/infiltrator.yml @@ -4451,10 +4451,6 @@ entities: - pos: 3.5,-19.5 parent: 73 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 531 type: FoodBoxDonkpocketPizza components: diff --git a/Resources/Maps/lighthouse.yml b/Resources/Maps/lighthouse.yml index 60d0c10ad8..67edecfaac 100644 --- a/Resources/Maps/lighthouse.yml +++ b/Resources/Maps/lighthouse.yml @@ -23745,10 +23745,6 @@ entities: - pos: -12.5,-7.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 134 type: GasValve components: @@ -30930,10 +30926,6 @@ entities: - pos: -27.5,23.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 1212 type: Table components: @@ -35365,10 +35357,6 @@ entities: - pos: 0.5,47.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 1832 type: WaterCooler components: @@ -36878,10 +36866,6 @@ entities: - pos: 29.5,47.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2035 type: Barricade components: @@ -58148,10 +58132,6 @@ entities: - pos: -9.5,43.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 5146 type: BoxMouthSwab components: @@ -58236,10 +58216,6 @@ entities: - pos: -38.5,-8.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 5158 type: DonkpocketBoxSpawner components: @@ -125315,10 +125291,6 @@ entities: - pos: -2.5,-28.5 parent: 100 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 13882 type: trayScanner components: diff --git a/Resources/Maps/marathon.yml b/Resources/Maps/marathon.yml index e1515f70cd..eb47e32d6d 100644 --- a/Resources/Maps/marathon.yml +++ b/Resources/Maps/marathon.yml @@ -25906,20 +25906,12 @@ entities: - pos: -14.5,11.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 484 type: KitchenMicrowave components: - pos: -15.5,11.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 485 type: KitchenReagentGrinder components: @@ -73172,10 +73164,6 @@ entities: - pos: -38.5,-4.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 7300 type: DrinkMug components: @@ -86671,10 +86659,6 @@ entities: - pos: 1.5,-28.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 9177 type: DonkpocketBoxSpawner components: @@ -95175,10 +95159,6 @@ entities: - pos: -49.5,63.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 10414 type: WheatSeeds components: @@ -158332,10 +158312,6 @@ entities: - pos: -79.5,-55.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 19539 type: KitchenReagentGrinder components: @@ -168811,10 +168787,6 @@ entities: - pos: -58.5,52.5 parent: 30 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 21156 type: StoolBar components: diff --git a/Resources/Maps/meta.yml b/Resources/Maps/meta.yml index 7206095025..cc604f563c 100644 --- a/Resources/Maps/meta.yml +++ b/Resources/Maps/meta.yml @@ -37535,10 +37535,6 @@ entities: - pos: -4.5,-16.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 1633 type: WallSolid components: @@ -43106,20 +43102,12 @@ entities: - pos: 26.5,-10.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2483 type: KitchenMicrowave components: - pos: 30.5,-10.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2484 type: KitchenReagentGrinder components: @@ -50409,10 +50397,6 @@ entities: - pos: -28.5,12.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 3524 type: DonkpocketBoxSpawner components: @@ -77325,10 +77309,6 @@ entities: - pos: -12.5,55.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 7219 type: ReinforcedWindow components: @@ -99072,10 +99052,6 @@ entities: - pos: 13.5,42.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 10455 type: Rack components: @@ -112170,10 +112146,6 @@ entities: - pos: 53.5,8.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 12307 type: SignSecureMed components: @@ -153128,10 +153100,6 @@ entities: - pos: -48.5,-16.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 18397 type: FoodCondimentBottleEnzyme components: @@ -160633,10 +160601,6 @@ entities: - pos: 14.5,-38.5 parent: 0 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 19515 type: DonkpocketBoxSpawner components: diff --git a/Resources/Maps/nss_pillar.yml b/Resources/Maps/nss_pillar.yml index d39cdae24d..31ef3bdb1f 100644 --- a/Resources/Maps/nss_pillar.yml +++ b/Resources/Maps/nss_pillar.yml @@ -22360,10 +22360,6 @@ entities: - pos: 17.5,10.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 371 type: KitchenSpike components: @@ -24299,10 +24295,6 @@ entities: - pos: -29.5,30.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 661 type: Table components: @@ -35166,10 +35158,6 @@ entities: - pos: 45.5,24.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2239 type: WallSolid components: @@ -35668,10 +35656,6 @@ entities: - pos: 18.5,-17.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2308 type: Chair components: @@ -83871,10 +83855,6 @@ entities: - pos: 16.5,10.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 8747 type: WallReinforced components: @@ -120415,10 +120395,6 @@ entities: - pos: -69.5,-13.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 13576 type: DonkpocketBoxSpawner components: @@ -151260,10 +151236,6 @@ entities: - pos: 33.5,-17.5 parent: 130 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 17915 type: Table components: diff --git a/Resources/Maps/packedstation.yml b/Resources/Maps/packedstation.yml index 0e19d9b4fc..45a91d3d5d 100644 --- a/Resources/Maps/packedstation.yml +++ b/Resources/Maps/packedstation.yml @@ -22434,10 +22434,6 @@ entities: - pos: 37.5,-9.5 parent: 2 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 1606 type: FoodBoxDonkpocket components: @@ -27403,10 +27399,6 @@ entities: - pos: 37.5,36.5 parent: 2 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 2308 type: WardrobePrison components: @@ -73232,10 +73224,6 @@ entities: - pos: 107.5,-10.5 parent: 2 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 8861 type: FoodBoxDonkpocketGondola components: diff --git a/Resources/Maps/saltern.yml b/Resources/Maps/saltern.yml index 7616d3c1ec..4c49ddbc72 100644 --- a/Resources/Maps/saltern.yml +++ b/Resources/Maps/saltern.yml @@ -16462,10 +16462,6 @@ entities: pos: -14.5,-1.5 parent: 852 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 894 type: Table components: @@ -40865,10 +40861,6 @@ entities: - pos: -7.5,-28.5 parent: 852 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 4222 type: GasPipeStraight components: diff --git a/Resources/Maps/splitstation.yml b/Resources/Maps/splitstation.yml index b44e29e0b4..e4dd62f46c 100644 --- a/Resources/Maps/splitstation.yml +++ b/Resources/Maps/splitstation.yml @@ -70861,10 +70861,6 @@ entities: - pos: -23.5,-22.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 6411 type: GasPipeStraight components: @@ -83526,10 +83522,6 @@ entities: - pos: 58.5,-84.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 8061 type: DonkpocketBoxSpawner components: @@ -83733,10 +83725,6 @@ entities: - pos: -18.5,-22.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 8091 type: KitchenReagentGrinder components: @@ -108616,10 +108604,6 @@ entities: - pos: 23.5,-85.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 11561 type: DonkpocketBoxSpawner components: @@ -112828,10 +112812,6 @@ entities: - pos: -26.5,-77.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 12121 type: DonkpocketBoxSpawner components: @@ -136242,10 +136222,6 @@ entities: - pos: 50.5,-41.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 15343 type: Table components: @@ -167221,10 +167197,6 @@ entities: - pos: 49.5,-24.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 19376 type: DonkpocketBoxSpawner components: @@ -177561,10 +177533,6 @@ entities: - pos: -32.5,-125.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 20552 type: DonkpocketBoxSpawner components: @@ -198567,10 +198535,6 @@ entities: - pos: -42.5,0.5 parent: 69 type: Transform - - containers: - microwave_entity_container: !type:Container - ents: [] - type: ContainerContainer - uid: 23488 type: DonkpocketBoxSpawner components: diff --git a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml index 43a1446f9a..e8c21ac699 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml @@ -5,15 +5,22 @@ description: It's magic. components: - type: Microwave - - type: SolutionContainerManager - solutions: - microwave: - maxVol: 100 - - type: RefillableSolution - solution: microwave - type: Appearance + - type: GenericVisualizer visuals: - - type: MicrowaveVisualizer + enum.PowerDeviceVisuals.VisualState: + enum.MicrowaveVisualizerLayers.Base: + Idle: { state: "mw" } + Broken: { state: "mwb" } + Cooking: { state: "mw" } + enum.MicrowaveVisualizerLayers.BaseUnlit: + Idle: { state: "mw_unlit" } + Broken: { state: "mw_unlit" } + Cooking: { state: "mw_running_unlit" } + enum.PowerDeviceVisuals.Powered: + enum.MicrowaveVisualizerLayers.BaseUnlit: + True: { visible: true } + False: { visible: false } - type: ActivatableUI key: enum.MicrowaveUiKey.Key - type: UserInterface @@ -51,3 +58,6 @@ acts: ["Breakage"] - type: ApcPowerReceiver powerLoad: 400 + - type: ContainerContainer + containers: + microwave_entity_container: !type:Container \ No newline at end of file