Exemple #1
0
 public override void Initialize()
 {
     base.Initialize();
     if (!Owner.TryGetComponent <NodeContainerComponent>(out var container))
     {
         JoinedGridAtmos?.RemovePipeNetDevice(this);
         Logger.Error($"{typeof(GasCanisterPortComponent)} on entity {Owner.Uid} did not have a {nameof(NodeContainerComponent)}.");
         return;
     }
     _gasPort = container.Nodes.OfType <PipeNode>().FirstOrDefault();
     if (_gasPort == null)
     {
         JoinedGridAtmos?.RemovePipeNetDevice(this);
         Logger.Error($"{typeof(GasCanisterPortComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
         return;
     }
     if (Owner.TryGetComponent <SnapGridComponent>(out var snapGrid))
     {
         var anchoredCanister = snapGrid.GetLocal()
                                .Select(entity => entity.TryGetComponent <GasCanisterComponent>(out var canister) ? canister : null)
                                .Where(canister => canister != null)
                                .Where(canister => canister.Anchored)
                                .Where(canister => !canister.ConnectedToPort)
                                .FirstOrDefault();
         if (anchoredCanister != null)
         {
             anchoredCanister.TryConnectToPort();
         }
     }
 }
Exemple #2
0
 public override void Initialize()
 {
     base.Initialize();
     _atmosSystem = EntitySystem.Get <AtmosphereSystem>();
     if (!Owner.TryGetComponent <NodeContainerComponent>(out var container))
     {
         JoinedGridAtmos?.RemovePipeNetDevice(this);
         Logger.Error($"{typeof(BaseSiphonComponent)} on entity {Owner.Uid} did not have a {nameof(NodeContainerComponent)}.");
         return;
     }
     _scrubberOutlet = container.Nodes.OfType <PipeNode>().FirstOrDefault();
     if (_scrubberOutlet == null)
     {
         JoinedGridAtmos?.RemovePipeNetDevice(this);
         Logger.Error($"{typeof(BaseSiphonComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
         return;
     }
 }
Exemple #3
0
        public override void Initialize()
        {
            base.Initialize();
            if (!Owner.TryGetComponent <NodeContainerComponent>(out var container))
            {
                JoinedGridAtmos?.RemovePipeNetDevice(this);
                Logger.Error($"{typeof(BasePumpComponent)} on entity {Owner.Uid} did not have a {nameof(NodeContainerComponent)}.");
                return;
            }
            var pipeNodes = container.Nodes.OfType <PipeNode>();

            _inletPipe  = pipeNodes.Where(pipe => pipe.PipeDirection == _inletDirection).FirstOrDefault();
            _outletPipe = pipeNodes.Where(pipe => pipe.PipeDirection == _outletDirection).FirstOrDefault();
            if (_inletPipe == null | _outletPipe == null)
            {
                JoinedGridAtmos?.RemovePipeNetDevice(this);
                Logger.Error($"{typeof(BasePumpComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
                return;
            }
        }