* Now the name of the target craft items is taken directly from the prototypes * Deleting unnecessary fields * Deleting unnecessary fields * Added suffix field * Added override via localization keys * My favorite ItemList and TextureRect have been replaced with ListContainer and EntityPrototypeView * Fix suffix * Fix construction ghosts... maybe * Remove suffix from UI * Suffixes have been removed from prototypes * Added a description for the secret door * Fix search..? * The Icon field of ConstructionPrototype has been removed * StackPrototypes used in the construction menu have been localized * TagConstructionGraphStep used in the construction menu have been localized * The search bar has been localized * Fix localization and prototypes * Recipes are now only loaded when the crafting window is opened. * Fix crooked merge grid of the crafting menu. * Localization update * Fix cyborg graph * Revert "Recipes are now only loaded when the crafting window is opened." This reverts commit 97749483542c2d6272bda16edf49612c69a0761a. * Fix loc * fix merge * Fix upstream * Some of the logic has been moved to Shared * fix * Small adjustments * Very small change --------- Co-authored-by: EmoGarbage404 <retron404@gmail.com>
94 lines
3.6 KiB
C#
94 lines
3.6 KiB
C#
using Content.Server.Construction.Components;
|
|
using Content.Server.Stack;
|
|
using Content.Shared.Construction;
|
|
using Content.Shared.DoAfter;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.Containers;
|
|
using Robust.Shared.Random;
|
|
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
|
|
|
|
namespace Content.Server.Construction
|
|
{
|
|
/// <summary>
|
|
/// The server-side implementation of the construction system, which is used for constructing entities in game.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed partial class ConstructionSystem : SharedConstructionSystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
|
[Dependency] private readonly ContainerSystem _container = default!;
|
|
[Dependency] private readonly StackSystem _stackSystem = default!;
|
|
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
InitializeComputer();
|
|
InitializeGraphs();
|
|
InitializeGuided();
|
|
InitializeInteractions();
|
|
InitializeInitial();
|
|
InitializeMachines();
|
|
|
|
SubscribeLocalEvent<ConstructionComponent, ComponentInit>(OnConstructionInit);
|
|
SubscribeLocalEvent<ConstructionComponent, ComponentStartup>(OnConstructionStartup);
|
|
}
|
|
|
|
private void OnConstructionInit(Entity<ConstructionComponent> ent, ref ComponentInit args)
|
|
{
|
|
var construction = ent.Comp;
|
|
if (GetCurrentGraph(ent, construction) is not {} graph)
|
|
{
|
|
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
|
|
return;
|
|
}
|
|
|
|
if (GetNodeFromGraph(graph, construction.Node) is not {} node)
|
|
{
|
|
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
|
|
return;
|
|
}
|
|
|
|
ConstructionGraphEdge? edge = null;
|
|
if (construction.EdgeIndex is {} edgeIndex)
|
|
{
|
|
if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
|
|
{
|
|
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
|
|
return;
|
|
}
|
|
|
|
edge = currentEdge;
|
|
}
|
|
|
|
if (construction.TargetNode is {} targetNodeId)
|
|
{
|
|
if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
|
|
{
|
|
Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
|
|
return;
|
|
}
|
|
|
|
UpdatePathfinding(ent, graph, node, targetNode, edge, construction);
|
|
}
|
|
}
|
|
|
|
private void OnConstructionStartup(EntityUid uid, ConstructionComponent construction, ComponentStartup args)
|
|
{
|
|
if (GetCurrentNode(uid, construction) is not {} node)
|
|
return;
|
|
|
|
PerformActions(uid, null, node.Actions);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
UpdateInteractions();
|
|
}
|
|
}
|
|
}
|