Unfuck mostly everything.
This commit is contained in:
@@ -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<IServerPreferencesManager>().StartInit();
|
||||
|
||||
}
|
||||
|
||||
public override void PostInit()
|
||||
@@ -79,6 +81,7 @@ namespace Content.Server
|
||||
_gameTicker.Initialize();
|
||||
IoCManager.Resolve<ISandboxManager>().Initialize();
|
||||
IoCManager.Resolve<IServerPreferencesManager>().FinishInit();
|
||||
IoCManager.Resolve<RecipeManager>().Initialize();
|
||||
}
|
||||
|
||||
public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs)
|
||||
|
||||
@@ -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<MicrowaveMealRecipePrototype> _allRecipes;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
if(_allRecipes == null)
|
||||
{
|
||||
_allRecipes = new List<MicrowaveMealRecipePrototype>();
|
||||
foreach (var recipe in _prototypeManager.EnumeratePrototypes<MicrowaveMealRecipePrototype>())
|
||||
{
|
||||
|
||||
_allRecipes.Add(recipe);
|
||||
|
||||
}
|
||||
_allRecipes.Sort(new RecipeComparer());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class RecipeComparer : IComparer<MicrowaveMealRecipePrototype>
|
||||
{
|
||||
int IComparer<MicrowaveMealRecipePrototype>.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)
|
||||
{
|
||||
|
||||
@@ -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<ICargoOrderDataManager, CargoOrderDataManager>();
|
||||
IoCManager.Register<IModuleManager, ServerModuleManager>();
|
||||
IoCManager.Register<IServerPreferencesManager, ServerPreferencesManager>();
|
||||
IoCManager.Register<RecipeManager, RecipeManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
52
Content.Shared/Kitchen/RecipeManager.cs
Normal file
52
Content.Shared/Kitchen/RecipeManager.cs
Normal file
@@ -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<MealRecipePrototype> Recipes { get; private set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Recipes = new List<MealRecipePrototype>();
|
||||
foreach (var item in _prototypeManager.EnumeratePrototypes<MealRecipePrototype>())
|
||||
{
|
||||
Recipes.Add(item);
|
||||
}
|
||||
|
||||
Recipes.Sort(new RecipeComparer());
|
||||
}
|
||||
private class RecipeComparer : IComparer<MealRecipePrototype>
|
||||
{
|
||||
int IComparer<MealRecipePrototype>.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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.Kitchen
|
||||
namespace Content.Shared.Prototypes.Kitchen
|
||||
{
|
||||
/// <summary>
|
||||
/// 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;
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user