diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs index 7a97e2f538..6eb0c31d8c 100644 --- a/Content.Server/EntryPoint.cs +++ b/Content.Server/EntryPoint.cs @@ -4,6 +4,7 @@ using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.GameTicking; using Content.Server.Preferences; using Content.Server.Sandbox; +using Content.Shared.Kitchen; using Robust.Server.Interfaces.Player; using Robust.Shared.ContentPack; using Robust.Shared.Interfaces.GameObjects; @@ -70,6 +71,7 @@ namespace Content.Server logManager.GetSawmill("Storage").Level = LogLevel.Info; IoCManager.Resolve().StartInit(); + } public override void PostInit() @@ -79,6 +81,7 @@ namespace Content.Server _gameTicker.Initialize(); IoCManager.Resolve().Initialize(); IoCManager.Resolve().FinishInit(); + IoCManager.Resolve().Initialize(); } public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs) diff --git a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs index 878096cd5b..62dbda34ad 100644 --- a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs @@ -14,6 +14,7 @@ using Content.Server.GameObjects.Components.Chemistry; using Content.Shared.Chemistry; using Robust.Shared.Serialization; using Robust.Shared.Interfaces.GameObjects; +using Content.Shared.Prototypes.Kitchen; using Content.Shared.Kitchen; namespace Content.Server.GameObjects.Components.Kitchen @@ -24,61 +25,19 @@ namespace Content.Server.GameObjects.Components.Kitchen { #pragma warning disable 649 - [Dependency] private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly IEntityManager _entityManager; + [Dependency] private readonly RecipeManager _recipeManager; #pragma warning restore 649 public override string Name => "Microwave"; - private AppearanceComponent _appearanceComponent; - - [ViewVariables] - private string _useSound; - [ViewVariables] - private string _outputPrototype; [ViewVariables] private SolutionComponent _contents; - private static List _allRecipes; - public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); - if(_allRecipes == null) - { - _allRecipes = new List(); - foreach (var recipe in _prototypeManager.EnumeratePrototypes()) - { - _allRecipes.Add(recipe); - - } - _allRecipes.Sort(new RecipeComparer()); - } - - } - - private class RecipeComparer : IComparer - { - int IComparer.Compare(MicrowaveMealRecipePrototype x, MicrowaveMealRecipePrototype y) - { - if(x == null || y == null) - { - return 0; - } - - if (x.Ingredients.Count < y.Ingredients.Count) - { - return 1; - } - - if (x.Ingredients.Count > y.Ingredients.Count) - { - return -1; - } - - return 0; - } } public override void Initialize() @@ -101,12 +60,12 @@ namespace Content.Server.GameObjects.Components.Kitchen { if(_contents.ReagentList.Count > 0) { - foreach (var r in _allRecipes) + foreach(var r in _recipeManager.Recipes) { - if (CanSatisfyRecipe(r)) + if(CanSatisfyRecipe(r)) { - var outputFromRecipe = r.Result; - _entityManager.SpawnEntity(outputFromRecipe, Owner.Transform.GridPosition); + var resultPrototype = r.Result; + _entityManager.SpawnEntity(resultPrototype, Owner.Transform.GridPosition); return; } @@ -115,7 +74,7 @@ namespace Content.Server.GameObjects.Components.Kitchen } - private bool CanSatisfyRecipe(MicrowaveMealRecipePrototype recipe) + private bool CanSatisfyRecipe(MealRecipePrototype recipe) { foreach(var ingredient in recipe.Ingredients) { diff --git a/Content.Server/ServerContentIoC.cs b/Content.Server/ServerContentIoC.cs index f4bb04b9cc..7ca422e4c4 100644 --- a/Content.Server/ServerContentIoC.cs +++ b/Content.Server/ServerContentIoC.cs @@ -8,6 +8,7 @@ using Content.Server.Preferences; using Content.Server.Sandbox; using Content.Server.Utility; using Content.Shared.Chemistry; +using Content.Shared.Kitchen; using Content.Shared.Interfaces; using Content.Shared.Interfaces.Chemistry; using Robust.Shared.IoC; @@ -28,6 +29,7 @@ namespace Content.Server IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); + IoCManager.Register(); } } } diff --git a/Content.Shared/EntryPoint.cs b/Content.Shared/EntryPoint.cs index a9df20ff2a..8975f3fbb4 100644 --- a/Content.Shared/EntryPoint.cs +++ b/Content.Shared/EntryPoint.cs @@ -6,7 +6,7 @@ using Robust.Shared.IoC; using Robust.Shared.Prototypes; - namespace Content.Shared +namespace Content.Shared { public class EntryPoint : GameShared { @@ -55,5 +55,6 @@ _tileDefinitionManager.Initialize(); } + } } diff --git a/Content.Shared/Kitchen/RecipeManager.cs b/Content.Shared/Kitchen/RecipeManager.cs new file mode 100644 index 0000000000..81c15279c1 --- /dev/null +++ b/Content.Shared/Kitchen/RecipeManager.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using Content.Shared.Prototypes.Kitchen; +using Robust.Shared.IoC; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Kitchen +{ + + public class RecipeManager + { +#pragma warning disable 649 + [Dependency] private readonly IPrototypeManager _prototypeManager; +#pragma warning restore 649 + public List Recipes { get; private set; } + + public void Initialize() + { + Recipes = new List(); + foreach (var item in _prototypeManager.EnumeratePrototypes()) + { + Recipes.Add(item); + } + + Recipes.Sort(new RecipeComparer()); + } + private class RecipeComparer : IComparer + { + int IComparer.Compare(MealRecipePrototype x, MealRecipePrototype y) + { + if (x == null || y == null) + { + return 0; + } + + if (x.Ingredients.Count < y.Ingredients.Count) + { + return 1; + } + + if (x.Ingredients.Count > y.Ingredients.Count) + { + return -1; + } + + return 0; + } + + + } + } +} diff --git a/Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs b/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs similarity index 91% rename from Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs rename to Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs index c7a20faf8f..d61d11590d 100644 --- a/Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs +++ b/Content.Shared/Prototypes/Kitchen/MicrowaveMealRecipePrototype.cs @@ -7,7 +7,7 @@ using Robust.Shared.Serialization; using Robust.Shared.Utility; using YamlDotNet.RepresentationModel; -namespace Content.Shared.Kitchen +namespace Content.Shared.Prototypes.Kitchen { /// /// A recipe for space microwaves. @@ -15,7 +15,7 @@ namespace Content.Shared.Kitchen [Prototype("microwaveMealRecipe")] - public class MicrowaveMealRecipePrototype : IPrototype, IIndexedPrototype + public class MealRecipePrototype : IPrototype, IIndexedPrototype { private string _id; diff --git a/Resources/Prototypes/Entities/kitchen.yml b/Resources/Prototypes/Entities/kitchen.yml index d7d9f9803b..064550b61b 100644 --- a/Resources/Prototypes/Entities/kitchen.yml +++ b/Resources/Prototypes/Entities/kitchen.yml @@ -13,7 +13,7 @@ - type: Collidable shapes: - !type:PhysShapeAabb - bounds: "-0.5,0,0.5,1" + bounds: "-0.25,-0.4,0.25,0.4" layer: 15 IsScrapingFloor: true - type: Sprite