diff --git a/Content.Client/GameObjects/Components/Kitchen/MicrowaveVisualizer.cs b/Content.Client/GameObjects/Components/Kitchen/MicrowaveVisualizer.cs new file mode 100644 index 0000000000..7cfcd07253 --- /dev/null +++ b/Content.Client/GameObjects/Components/Kitchen/MicrowaveVisualizer.cs @@ -0,0 +1,50 @@ +using Content.Shared.GameObjects.Components.Power; +using Content.Shared.Kitchen; +using Robust.Client.Animations; +using Robust.Client.GameObjects; +using Robust.Client.Interfaces.GameObjects.Components; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Content.Client.GameObjects.Components.Kitchen +{ + public sealed class MicrowaveVisualizer : AppearanceVisualizer + { + public override void OnChangeData(AppearanceComponent component) + { + base.OnChangeData(component); + var sprite = component.Owner.GetComponent(); + if (!component.TryGetData(PowerDeviceVisuals.VisualState, out MicrowaveVisualState state)) + { + state = MicrowaveVisualState.PoweredIdle; + } + switch (state) + { + case MicrowaveVisualState.PoweredIdle: + sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw"); + sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit"); + break; + + case MicrowaveVisualState.Cooking: + sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw"); + sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_running_unlit"); + break; + + } + + var glowingPartsVisible = !(component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) && !powered); + sprite.LayerSetVisible(MicrowaveVisualizerLayers.BaseUnlit, glowingPartsVisible); + + + } + + public enum MicrowaveVisualizerLayers + { + Base, + BaseUnlit + } + } + + +} diff --git a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs index 8ccaa8c91a..93cf571478 100644 --- a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs @@ -8,6 +8,11 @@ using Robust.Shared.Serialization; using Robust.Shared.Interfaces.GameObjects; using Content.Shared.Prototypes.Kitchen; using Content.Shared.Kitchen; +using Robust.Shared.Timers; +using Robust.Server.GameObjects; +using Content.Shared.GameObjects.Components.Power; +using Robust.Server.GameObjects.EntitySystems; +using Content.Server.GameObjects.Components.Power; namespace Content.Server.GameObjects.Components.Kitchen { @@ -17,19 +22,28 @@ namespace Content.Server.GameObjects.Components.Kitchen { #pragma warning disable 649 + [Dependency] private readonly IEntitySystemManager _entitySystemManager; [Dependency] private readonly IEntityManager _entityManager; [Dependency] private readonly RecipeManager _recipeManager; #pragma warning restore 649 public override string Name => "Microwave"; + private int _cookTimeSeconds; + private string _badRecipeName; [ViewVariables] private SolutionComponent _contents; + private AppearanceComponent _appearance; + + private AudioSystem _audioSystem; + + private PowerDeviceComponent _powerDevice; public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); - + serializer.DataField(ref _badRecipeName, "failureResult", "FoodBadRecipe"); + serializer.DataField(ref _cookTimeSeconds, "cookTime", 5000); } public override void Initialize() @@ -46,23 +60,43 @@ namespace Content.Server.GameObjects.Components.Kitchen _contents = Owner.AddComponent(); } } + + _appearance = Owner.GetComponent(); + _powerDevice = Owner.GetComponent(); + _audioSystem = _entitySystemManager.GetEntitySystem(); } void IActivate.Activate(ActivateEventArgs eventArgs) { - if(_contents.ReagentList.Count > 0) + if (_contents.ReagentList.Count == 0 || !_powerDevice.Powered) { - foreach(var r in _recipeManager.Recipes) + return; + } + foreach(var r in _recipeManager.Recipes) + { + if(CanSatisfyRecipe(r)) { - if(CanSatisfyRecipe(r)) + SetAppearance(MicrowaveVisualState.Cooking); + Timer.Spawn(_cookTimeSeconds, () => { RemoveContents(r); - var resultPrototype = r.Result; - _entityManager.SpawnEntity(resultPrototype, Owner.Transform.GridPosition); - return; - } + _entityManager.SpawnEntity(r.Result, Owner.Transform.GridPosition); + + _audioSystem.Play("/Audio/machines/ding.ogg"); + SetAppearance(MicrowaveVisualState.PoweredIdle); + }); + return; } } + + SetAppearance(MicrowaveVisualState.Cooking); + Timer.Spawn(_cookTimeSeconds, () => + { + _contents.RemoveAllSolution(); + _entityManager.SpawnEntity(_badRecipeName, Owner.Transform.GridPosition); + _audioSystem.Play("/Audio/machines/ding.ogg"); + SetAppearance(MicrowaveVisualState.PoweredIdle); + }); } private bool CanSatisfyRecipe(FoodRecipePrototype recipe) @@ -91,6 +125,10 @@ namespace Content.Server.GameObjects.Components.Kitchen } } - + private void SetAppearance(MicrowaveVisualState state) + { + if (_appearance != null || Owner.TryGetComponent(out _appearance)) + _appearance.SetData(PowerDeviceVisuals.VisualState, state); + } } } diff --git a/Content.Shared/GameObjects/Components/Research/SharedLatheComponent.cs b/Content.Shared/GameObjects/Components/Research/SharedLatheComponent.cs index dabae088fb..6b290d551d 100644 --- a/Content.Shared/GameObjects/Components/Research/SharedLatheComponent.cs +++ b/Content.Shared/GameObjects/Components/Research/SharedLatheComponent.cs @@ -1,4 +1,4 @@ -// Only unused on .NET Core due to KeyValuePair.Deconstruct +// Only unused on .NET Core due to KeyValuePair.Deconstruct // ReSharper disable once RedundantUsingDirective using Robust.Shared.Utility; using System; diff --git a/Content.Shared/Kitchen/SharedMicrowave.cs b/Content.Shared/Kitchen/SharedMicrowave.cs new file mode 100644 index 0000000000..94ac50e1cc --- /dev/null +++ b/Content.Shared/Kitchen/SharedMicrowave.cs @@ -0,0 +1,18 @@ +using Robust.Shared.Serialization; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Content.Shared.Kitchen +{ + + [Serializable, NetSerializable] + public enum MicrowaveVisualState + { + Off, + PoweredIdle, + Cooking + } + + +} diff --git a/Resources/Audio/machines/ding.ogg b/Resources/Audio/machines/ding.ogg new file mode 100644 index 0000000000..ff1e3ebbc9 Binary files /dev/null and b/Resources/Audio/machines/ding.ogg differ diff --git a/Resources/Prototypes/Entities/kitchen.yml b/Resources/Prototypes/Entities/kitchen.yml index 064550b61b..806ef99b7f 100644 --- a/Resources/Prototypes/Entities/kitchen.yml +++ b/Resources/Prototypes/Entities/kitchen.yml @@ -9,6 +9,9 @@ - type: Solution maxVol: 100 caps: 1 + - type: Appearance + visuals: + - type: MicrowaveVisualizer - type: Collidable shapes: @@ -19,7 +22,12 @@ - type: Sprite netsync: false sprite: Objects/Kitchen/microwave.rsi - state: mw0 + layers: + - state: mw0 + map: ["enum.MicrowaveVisualizerLayers.Base"] + - state: mw_unlit + shader: unshaded + map: ["enum.MicrowaveVisualizerLayers.BaseUnlit"] - type: PowerDevice - type: Icon sprite: Objects/Kitchen/microwave.rsi diff --git a/Resources/Prototypes/Kitchen/meal_recipes.yml b/Resources/Prototypes/Kitchen/meal_recipes.yml index a383a7fbce..f763dc616b 100644 --- a/Resources/Prototypes/Kitchen/meal_recipes.yml +++ b/Resources/Prototypes/Kitchen/meal_recipes.yml @@ -5,3 +5,11 @@ ingredients: chem.H2O: 15 chem.Nutriment: 5 + +- type: microwaveMealRecipe + id: RecipeFlashlight + name: Flashlight Recipe + result: FoodCheeseWedge + ingredients: + chem.H2O: 15 + chem.Glucose: 5 diff --git a/Resources/Textures/Objects/Kitchen/microwave.dmi b/Resources/Textures/Objects/Kitchen/microwave.dmi index 0b96c553c0..a3cb98f9c1 100644 Binary files a/Resources/Textures/Objects/Kitchen/microwave.dmi and b/Resources/Textures/Objects/Kitchen/microwave.dmi differ diff --git a/Resources/Textures/Objects/Kitchen/microwave.rsi/meta.json b/Resources/Textures/Objects/Kitchen/microwave.rsi/meta.json index b03b51e24c..e1c3ede466 100644 --- a/Resources/Textures/Objects/Kitchen/microwave.rsi/meta.json +++ b/Resources/Textures/Objects/Kitchen/microwave.rsi/meta.json @@ -1 +1,105 @@ -{"version": 1, "size": {"x": 32, "y": 32}, "license": "AGPL v3", "copyright": "Taken from https://github.com/discordia-space/CEV-Eris", "states": [{"name": "mw", "directions": 1, "delays": [[1.0]]}, {"name": "mw0", "directions": 1, "delays": [[1.0]]}, {"name": "mw1", "directions": 1, "delays": [[0.1, 0.1]]}, {"name": "mwb", "directions": 1, "delays": [[1.0]]}, {"name": "mwbloody", "directions": 1, "delays": [[1.0]]}, {"name": "mwbloody0", "directions": 1, "delays": [[1.0]]}, {"name": "mwbloody1", "directions": 1, "delays": [[0.1, 0.1]]}, {"name": "mwbloodyo", "directions": 1, "delays": [[0.1, 0.1]]}, {"name": "mwo", "directions": 1, "delays": [[0.1, 0.1]]}]} \ No newline at end of file +{ + "version": 1, + "size": { + "x": 32, + "y": 32 + }, + "license": "AGPL v3", + "copyright": "Taken from https://github.com/discordia-space/CEV-Eris", + "states": [ + { + "name": "mw", + "directions": 1, + "delays": [ + [ + 1.0 + ] + ] + }, + { + "name": "mw_unlit", + "directions": 1, + "delays": [ + [ + 1.0 + ] + ] + }, + { + "name": "mw0", + "directions": 1, + "delays": [ + [ + 1.0 + ] + ] + }, + { + "name": "mw_running_unlit", + "directions": 1, + "delays": [ + [ + 1.0, + 1.0 + ] + ] + }, + { + "name": "mwb", + "directions": 1, + "delays": [ + [ + 1.0 + ] + ] + }, + { + "name": "mwbloody", + "directions": 1, + "delays": [ + [ + 1.0 + ] + ] + }, + { + "name": "mwbloody0", + "directions": 1, + "delays": [ + [ + 1.0 + ] + ] + }, + { + "name": "mwbloody1", + "directions": 1, + "delays": [ + [ + 0.1, + 0.1 + ] + ] + }, + { + "name": "mwbloodyo", + "directions": 1, + "delays": [ + [ + 0.1, + 0.1 + ] + ] + }, + { + "name": "mwo", + "directions": 1, + "delays": [ + [ + 0.1, + 0.1 + ] + ] + } + ] +} diff --git a/Resources/Textures/Objects/Kitchen/microwave.rsi/mw_running_unlit.png b/Resources/Textures/Objects/Kitchen/microwave.rsi/mw_running_unlit.png new file mode 100644 index 0000000000..d259712b6d Binary files /dev/null and b/Resources/Textures/Objects/Kitchen/microwave.rsi/mw_running_unlit.png differ diff --git a/Resources/Textures/Objects/Kitchen/microwave.rsi/mw_unlit.png b/Resources/Textures/Objects/Kitchen/microwave.rsi/mw_unlit.png new file mode 100644 index 0000000000..4ad790b4e8 Binary files /dev/null and b/Resources/Textures/Objects/Kitchen/microwave.rsi/mw_unlit.png differ