Example #1
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            CompPipe = GetComp <CompPipe>();
            pipeInt  = (int)CompPipe.PipeType;

            base.SpawnSetup(map, respawningAfterLoad);
        }
Example #2
0
        public void RegisterPipe(CompPipe pipe, bool respawningAfterLoad)
        {
            foreach (IntVec3 item in GenAdj.CellsAdjacentCardinal(pipe.parent))
            {
                TryDestroyPipeNet(item, pipe.PipeType);
            }

            TryCreatePipeNet(pipe.parent.Position, pipe.PipeType);
        }
Example #3
0
        public void DeregisterPipe(CompPipe pipe)
        {
            TryDestroyPipeNet(pipe.parent.Position, pipe.PipeType);

            foreach (IntVec3 item in GenAdj.CellsAdjacentCardinal(pipe.parent.Position, pipe.parent.Rotation, pipe.parent.def.size))
            {
                TryCreatePipeNet(item, pipe.PipeType);
            }
        }
Example #4
0
        public void TryCreatePipeNet(IntVec3 pipe, PipeType type)
        {
            if (!pipe.InBounds(map) || PipeNetAt(pipe) != null)
            {
                return;
            }

            int pipeTypeInt = (int)type;

            PipelineNet newNet = new PipelineNet
            {
                GasManager = this,
                NetType    = type
            };

            Predicate <IntVec3> predicate = delegate(IntVec3 c)
            {
                foreach (var item in GridsUtility.GetThingList(c, map))
                {
                    CompPipe compPipe2 = item.TryGetComp <CompPipe>();
                    if (compPipe2 != null)
                    {
                        if (compPipe2.PipeType == type)
                        {
                            compPipe2.pipeNet = newNet;
                            newNet.PipesThings.Add(compPipe2.parent);

                            CellRect cellRect = compPipe2.parent.OccupiedRect();
                            foreach (var cell in cellRect)
                            {
                                int num = map.cellIndices.CellToIndex(cell.x, cell.z);
                                PipeGrid[pipeTypeInt, map.cellIndices.CellToIndex(c)] = 1;
                                PipeNets[num] = newNet;
                            }
                        }

                        if (compPipe2.GasProps.ConnectEverything)
                        {
                            newNet.PipesThings.Add(compPipe2.parent);
                        }
                        return(true);
                    }
                }
                return(false);
            };

            map.floodFiller.FloodFill(pipe, predicate, delegate(IntVec3 x) { });
            PipelineSet[type].Add(newNet);
            AllPipeNets.Add(newNet);

            newNet.InitNet();
        }