Files
tbd-station-14/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/NodeGroupFactory.cs
py01 7b12d4e08c PipeNet (#1626)
* PipeNode

* Pipe prototypes

* Fixes Default NodeGroup not being registered by NodeGroupFactory

* GasNet

* PumpComponent

* IPipeNet

* PipeComponent

* misc naming, yaml

* PipeComponent rework

* PipeNet gas transfer from pipes

* PipeNet correctly combines gas on combining with other group

* Client ignores piping components

* AfterRemake

* PipeNet remake simplification

* IGasMixtureHolder on PipeComponent, IPipeNet

* PipeContainerComponent

* BasePump

* DebugPump

* IgnoredComponent fix

* Pipe LocalAir and Air

* comments

* Pump fix

* PipeNet fix

* name simplification

* PipeDirection name changes

* BaseVentComponent and DebugVentComponent

* Moves Pipe to own file

* DebugVentComponent moved to own file

* BaseScrubberComponent

* DebugScrubberComponent

* IgnoredComponents update

* scrubber prototype

* vent prototype fix

* comments

* Removes vent and scrubber PipeDirection check

* PipeContainer, Pipe, and PipeNode refactor

* Yaml cleanup

* pump prototype fix

* Removes AssumeAir usage from old IGasMixtureHolders

* Simplfies Vent & Scrubber to use AtmosHelper methods

* Vents and scrubbers invalidate the coordinate they changed the gas of

* UpdatedPipingComponent

* ScrubberComponent renamed to SiphonComponent

* Removes PumpSystem

* Removes framTime from UpdatedPiping

* PipeNetDevices

* PipeNetDevice updated by GridAtmosphereComponent

* PipeNets react from update in GridAtmosphereComponent

* GridAtmosphereComponent stores PipeNets/PipeNetDevices to be updated in queue

* diff fix

* Removes debug gas starting in pipes

* type safety in IPipeNet when combining groups

* null checks

* GridAtmos stores PipeNets and PipeNetDevices in List

* comments

* rogue curly bracket

* ProcessPipeNets update fix

* RemovePipeNet fix

* PipeNet update() unique index

* fix diff

* Integration test fixes

* Error Logging

* error fix

Co-authored-by: py01 <pyronetics01@gmail.com>
2020-08-27 17:45:27 +02:00

68 lines
2.2 KiB
C#
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
{
public interface INodeGroupFactory
{
/// <summary>
/// Performs reflection to associate <see cref="INodeGroup"/> implementations with the
/// string specified in their <see cref="NodeGroupAttribute"/>.
/// </summary>
void Initialize();
/// <summary>
/// Returns a new <see cref="INodeGroup"/> instance.
/// </summary>
INodeGroup MakeNodeGroup(Node sourceNode);
}
public class NodeGroupFactory : INodeGroupFactory
{
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
[Dependency] private readonly IDynamicTypeFactory _typeFactory = default!;
private readonly Dictionary<NodeGroupID, Type> _groupTypes = new Dictionary<NodeGroupID, Type>();
public void Initialize()
{
var nodeGroupTypes = _reflectionManager.GetAllChildren<INodeGroup>();
foreach (var nodeGroupType in nodeGroupTypes)
{
var att = nodeGroupType.GetCustomAttribute<NodeGroupAttribute>();
if (att != null)
{
foreach (var groupID in att.NodeGroupIDs)
{
_groupTypes.Add(groupID, nodeGroupType);
}
}
}
}
public INodeGroup MakeNodeGroup(Node sourceNode)
{
if (_groupTypes.TryGetValue(sourceNode.NodeGroupID, out var type))
{
var nodeGroup = _typeFactory.CreateInstance<INodeGroup>(type);
nodeGroup.Initialize(sourceNode);
return nodeGroup;
}
throw new ArgumentException($"{sourceNode.NodeGroupID} did not have an associated {nameof(INodeGroup)}.");
}
}
public enum NodeGroupID
{
Default,
HVPower,
MVPower,
Apc,
Pipe,
}
}