2021-01-23 19:37:28 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using Content.Shared.Chemistry;
|
|
|
|
|
|
using Content.Shared.Maps;
|
|
|
|
|
|
using Robust.Shared.ContentPack;
|
|
|
|
|
|
using Robust.Shared.Interfaces.Map;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
|
using Robust.Shared.Localization.Macros;
|
|
|
|
|
|
using Robust.Shared.Log;
|
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared
|
2017-08-04 14:24:01 +02:00
|
|
|
|
{
|
|
|
|
|
|
public class EntryPoint : GameShared
|
|
|
|
|
|
{
|
2020-05-02 20:01:06 +02:00
|
|
|
|
// If you want to change your codebase's language, do it here.
|
|
|
|
|
|
private const string Culture = "en-US";
|
|
|
|
|
|
|
2020-08-24 14:10:28 +02:00
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
2019-04-03 21:20:26 +02:00
|
|
|
|
|
2020-05-02 20:01:06 +02:00
|
|
|
|
public override void PreInit()
|
2017-08-04 14:24:01 +02:00
|
|
|
|
{
|
2019-04-03 21:20:26 +02:00
|
|
|
|
IoCManager.InjectDependencies(this);
|
2020-05-02 20:01:06 +02:00
|
|
|
|
|
2020-05-28 00:58:57 +02:00
|
|
|
|
var textMacroFactory = IoCManager.Resolve<ITextMacroFactory>();
|
|
|
|
|
|
textMacroFactory.DoAutoRegistrations();
|
|
|
|
|
|
|
2020-05-02 20:01:06 +02:00
|
|
|
|
// Default to en-US.
|
2020-09-27 01:30:13 +12:00
|
|
|
|
Loc.LoadCulture(new CultureInfo(Culture));
|
2020-05-02 20:01:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Init()
|
|
|
|
|
|
{
|
2017-08-04 14:24:01 +02:00
|
|
|
|
}
|
2019-04-03 21:20:26 +02:00
|
|
|
|
|
|
|
|
|
|
public override void PostInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.PostInit();
|
|
|
|
|
|
|
|
|
|
|
|
_initTileDefinitions();
|
2021-01-23 19:37:28 +01:00
|
|
|
|
CheckReactions();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CheckReactions()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var reaction in _prototypeManager.EnumeratePrototypes<ReactionPrototype>())
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var reactant in reaction.Reactants.Keys)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_prototypeManager.HasIndex<ReagentPrototype>(reactant))
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.ErrorS(
|
|
|
|
|
|
"chem", "Reaction {reaction} has unknown reactant {reagent}.",
|
|
|
|
|
|
reaction.ID, reactant);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var product in reaction.Products.Keys)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_prototypeManager.HasIndex<ReagentPrototype>(product))
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.ErrorS(
|
|
|
|
|
|
"chem", "Reaction {reaction} has unknown product {product}.",
|
|
|
|
|
|
reaction.ID, product);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-04-03 21:20:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _initTileDefinitions()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Register space first because I'm a hard coding hack.
|
|
|
|
|
|
var spaceDef = _prototypeManager.Index<ContentTileDefinition>("space");
|
|
|
|
|
|
|
|
|
|
|
|
_tileDefinitionManager.Register(spaceDef);
|
|
|
|
|
|
|
|
|
|
|
|
var prototypeList = new List<ContentTileDefinition>();
|
|
|
|
|
|
foreach (var tileDef in _prototypeManager.EnumeratePrototypes<ContentTileDefinition>())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tileDef.Name == "space")
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2021-01-23 19:37:28 +01:00
|
|
|
|
|
2019-04-03 21:20:26 +02:00
|
|
|
|
prototypeList.Add(tileDef);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sort ordinal to ensure it's consistent client and server.
|
|
|
|
|
|
// So that tile IDs match up.
|
|
|
|
|
|
prototypeList.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal));
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var tileDef in prototypeList)
|
|
|
|
|
|
{
|
|
|
|
|
|
_tileDefinitionManager.Register(tileDef);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_tileDefinitionManager.Initialize();
|
|
|
|
|
|
}
|
2017-08-04 14:24:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|