2021-02-11 01:13:03 -08:00
|
|
|
using System;
|
2021-01-23 19:37:28 +01:00
|
|
|
using System.Collections.Generic;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.CharacterAppearance;
|
|
|
|
|
using Content.Shared.Chemistry.Reaction;
|
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-06-13 14:52:40 +02:00
|
|
|
using Content.Shared.IoC;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Localizations;
|
2021-01-23 19:37:28 +01:00
|
|
|
using Content.Shared.Maps;
|
|
|
|
|
using Robust.Shared.ContentPack;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Log;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.Map;
|
2021-01-23 19:37:28 +01:00
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
2021-06-13 14:52:40 +02:00
|
|
|
namespace Content.Shared.Entry
|
2017-08-04 14:24:01 +02:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class EntryPoint : GameShared
|
2017-08-04 14:24:01 +02:00
|
|
|
{
|
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);
|
2021-03-28 08:26:32 +02:00
|
|
|
SharedContentIoC.Register();
|
2020-05-02 20:01:06 +02:00
|
|
|
|
2021-02-23 22:09:28 +01:00
|
|
|
Localization.Init();
|
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();
|
2021-03-28 08:26:32 +02:00
|
|
|
IoCManager.Resolve<SpriteAccessoryManager>().Initialize();
|
2021-01-23 19:37:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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>())
|
|
|
|
|
{
|
2022-01-04 16:26:07 -08:00
|
|
|
if (tileDef.ID == "space")
|
2019-04-03 21:20:26 +02:00
|
|
|
{
|
|
|
|
|
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.
|
2022-01-04 16:26:07 -08:00
|
|
|
prototypeList.Sort((a, b) => string.Compare(a.ID, b.ID, StringComparison.Ordinal));
|
2019-04-03 21:20:26 +02:00
|
|
|
|
|
|
|
|
foreach (var tileDef in prototypeList)
|
|
|
|
|
{
|
|
|
|
|
_tileDefinitionManager.Register(tileDef);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_tileDefinitionManager.Initialize();
|
|
|
|
|
}
|
2017-08-04 14:24:01 +02:00
|
|
|
}
|
|
|
|
|
}
|