Ejemplo n.º 1
0
        public static void Reinit()
        {
            var layerCount = Common.NetLayerCount();

            netGrid = new AirNet[layerCount][];

            for (var i = 0; i < layerCount; i++)
            {
                netGrid[i] = new AirNet[CellIndices.NumGridCells];
            }
#if DEBUG
            Log.Message("RedistHeat: Initialized AirNetGrid.");
#endif
        }
Ejemplo n.º 2
0
        static AirOverlayMat()
        {
            LinkedOverlayGraphic = new Graphic[Common.NetLayerCount()];

            TransmitterShader = ShaderDatabase.MetaOverlay;

            var graphicLower = GraphicDatabase.Get <Graphic_Single>("Things/Special/AirPipeOverlayLower",
                                                                    TransmitterShader);
            var graphicUpper = GraphicDatabase.Get <Graphic_Single>("Things/Special/AirPipeOverlayUpper",
                                                                    TransmitterShader);

            LinkedOverlayGraphic[(int)NetLayer.Lower] = new Grahpic_LinkedAirPipeOverlay(graphicLower);
            LinkedOverlayGraphic[(int)NetLayer.Upper] = new Grahpic_LinkedAirPipeOverlay(graphicUpper);
            graphicLower.MatSingle.renderQueue        = 3800;
            graphicUpper.MatSingle.renderQueue        = 4000;
        }
Ejemplo n.º 3
0
        static AirNetManager()
        {
            var layerCount = Common.NetLayerCount();

            allNets  = new List <AirNet> [layerCount];
            newComps = new List <CompAir> [layerCount];
            oldComps = new List <CompAir> [layerCount];
            updatees = new List <IntVec3>();

            for (var i = 0; i < layerCount; i++)
            {
                allNets[i]  = new List <AirNet>();
                newComps[i] = new List <CompAir>();
                oldComps[i] = new List <CompAir>();
            }
        }
Ejemplo n.º 4
0
        public static void Reinit()
        {
            for (var i = 0; i < Common.NetLayerCount(); i++)
            {
                allNets[i]  = new List <AirNet>();
                newComps[i] = new List <CompAir>();
                oldComps[i] = new List <CompAir>();
            }

            foreach (var current in Find.Map.listerBuildings.allBuildingsColonist)
            {
                var compAir = current.TryGetComp <CompAir>();
                if (compAir != null)
                {
                    newComps[(int)compAir.currentLayer].Add(compAir);
                    updatees.Add(current.Position);
                }
            }
#if DEBUG
            Log.Message("RedistHeat: Initialized AirNetManager.");
#endif
            isReady = true;
        }
Ejemplo n.º 5
0
        public static void AirNetsUpdate()
        {
            for (var layerInt = 0; layerInt < Common.NetLayerCount(); layerInt++)
            {
                if (!newComps[layerInt].Any() && !oldComps[layerInt].Any())
                {
                    continue;
                }

                //Deregister the whole net that should be merged (deregister adjacent AirNet)
                foreach (var current in newComps[layerInt])
                {
#if DEBUG
                    Log.Message("Cleaning.");
#endif
                    //Check for adjacent cells
                    foreach (var adjPos in GenAdj.CellsAdjacentCardinal(current.parent))
                    {
                        if (!adjPos.InBounds())
                        {
                            continue;
                        }

                        var oldNet = AirNetGrid.NetAt(adjPos, (NetLayer)layerInt);

                        if (oldNet != null)
                        {
                            DeregisterAirNet(oldNet);
                        }
                    }
                }

                //Deregister comps marked as old
                foreach (var current in oldComps[layerInt])
                {
#if DEBUG
                    Log.Message("Deleting.");
#endif
                    var oldNet = AirNetGrid.NetAt(current.parent.Position, (NetLayer)layerInt);

                    if (oldNet != null)
                    {
                        DeregisterAirNet(oldNet);
                    }
                }


                //Make a new, merged net
                foreach (var current in newComps[layerInt])
                {
#if DEBUG
                    Log.Message("Merging.");
#endif
                    if (AirNetGrid.NetAt(current.parent.Position, (NetLayer)layerInt) == null)
                    {
                        RegisterAirNet(AirNetMaker.NewAirNetStartingFrom((Building)current.parent,
                                                                         (NetLayer)layerInt));
                    }
                }

                //Split nets
                foreach (var current in oldComps[layerInt])
                {
#if DEBUG
                    Log.Message("Splitting.");
#endif
                    foreach (var adjPos in GenAdj.CellsAdjacentCardinal(current.parent))
                    {
                        if (!adjPos.InBounds())
                        {
                            continue;
                        }

                        var airNode = GetAirNodeAt(adjPos, (NetLayer)layerInt);
                        if (airNode != null)
                        {
                            RegisterAirNet(AirNetMaker.NewAirNetStartingFrom(airNode, (NetLayer)layerInt));
                        }
                    }
                }

                newComps[layerInt].Clear();
                oldComps[layerInt].Clear();
            }
        }