예제 #1
0
 public void RegisterGlower(CompGlower newGlow)
 {
     this.litGlowers.Add(newGlow);
     this.MarkGlowGridDirty(newGlow.parent.Position);
     if (Current.ProgramState != ProgramState.Playing)
     {
         this.initialGlowerLocs.Add(newGlow.parent.Position);
     }
 }
예제 #2
0
 public void DeRegisterGlower(CompGlower oldGlow)
 {
     this.litGlowers.Remove(oldGlow);
     this.MarkGlowGridDirty(oldGlow.parent.Position);
 }
예제 #3
0
        public void AddFloodGlowFor(CompGlower theGlower, Color32[] glowGrid)
        {
            this.cellIndices      = this.map.cellIndices;
            this.glowGrid         = glowGrid;
            this.glower           = theGlower;
            this.attenLinearSlope = -1f / theGlower.Props.glowRadius;
            Building[] innerArray = this.map.edificeGrid.InnerArray;
            IntVec3    position   = theGlower.parent.Position;
            int        num        = Mathf.RoundToInt(this.glower.Props.glowRadius * 100f);
            int        num2       = this.cellIndices.CellToIndex(position);
            int        num3       = 0;
            bool       flag       = UnityData.isDebugBuild && DebugViewSettings.drawGlow;

            this.InitStatusesAndPushStartNode(ref num2, position);
            while (this.openSet.Count != 0)
            {
                num2 = this.openSet.Pop();
                IntVec3 c = this.cellIndices.IndexToCell(num2);
                this.calcGrid[num2].status = this.statusFinalizedValue;
                this.SetGlowGridFromDist(num2);
                if (flag)
                {
                    this.map.debugDrawer.FlashCell(c, (float)this.calcGrid[num2].intDist / 10f, this.calcGrid[num2].intDist.ToString("F2"), 50);
                    num3++;
                }
                for (int i = 0; i < 8; i++)
                {
                    uint num4 = (uint)(c.x + (int)GlowFlooder.Directions[i, 0]);
                    uint num5 = (uint)(c.z + (int)GlowFlooder.Directions[i, 1]);
                    if ((ulong)num4 < (ulong)((long)this.mapSizeX) && (ulong)num5 < (ulong)((long)this.mapSizeZ))
                    {
                        int x    = (int)num4;
                        int z    = (int)num5;
                        int num6 = this.cellIndices.CellToIndex(x, z);
                        if (this.calcGrid[num6].status != this.statusFinalizedValue)
                        {
                            this.blockers[i] = innerArray[num6];
                            if (this.blockers[i] != null)
                            {
                                if (this.blockers[i].def.blockLight)
                                {
                                    goto IL_3A4;
                                }
                                this.blockers[i] = null;
                            }
                            int num7;
                            if (i < 4)
                            {
                                num7 = 100;
                            }
                            else
                            {
                                num7 = 141;
                            }
                            int num8 = this.calcGrid[num2].intDist + num7;
                            if (num8 <= num)
                            {
                                if (i >= 4)
                                {
                                    switch (i)
                                    {
                                    case 4:
                                        if (this.blockers[0] != null && this.blockers[1] != null)
                                        {
                                            goto IL_3A4;
                                        }
                                        break;

                                    case 5:
                                        if (this.blockers[1] != null && this.blockers[2] != null)
                                        {
                                            goto IL_3A4;
                                        }
                                        break;

                                    case 6:
                                        if (this.blockers[2] != null && this.blockers[3] != null)
                                        {
                                            goto IL_3A4;
                                        }
                                        break;

                                    case 7:
                                        if (this.blockers[0] != null && this.blockers[3] != null)
                                        {
                                            goto IL_3A4;
                                        }
                                        break;
                                    }
                                }
                                if (this.calcGrid[num6].status <= this.statusUnseenValue)
                                {
                                    this.calcGrid[num6].intDist = 999999;
                                    this.calcGrid[num6].status  = this.statusOpenValue;
                                }
                                if (num8 < this.calcGrid[num6].intDist)
                                {
                                    this.calcGrid[num6].intDist = num8;
                                    this.calcGrid[num6].status  = this.statusOpenValue;
                                    this.openSet.Push(num6);
                                }
                            }
                        }
                    }
                    IL_3A4 :;
                }
            }
        }
예제 #4
0
        public void AddFloodGlowFor(CompGlower theGlower, Color32[] glowGrid)
        {
            cellIndices      = map.cellIndices;
            this.glowGrid    = glowGrid;
            glower           = theGlower;
            attenLinearSlope = -1f / theGlower.Props.glowRadius;
            Building[] innerArray = map.edificeGrid.InnerArray;
            IntVec3    position   = theGlower.parent.Position;
            int        num        = Mathf.RoundToInt(glower.Props.glowRadius * 100f);
            int        curIndex   = cellIndices.CellToIndex(position);

            InitStatusesAndPushStartNode(ref curIndex, position);
            while (openSet.Count != 0)
            {
                curIndex = openSet.Pop();
                IntVec3 intVec = cellIndices.IndexToCell(curIndex);
                calcGrid[curIndex].status = statusFinalizedValue;
                SetGlowGridFromDist(curIndex);
                for (int i = 0; i < 8; i++)
                {
                    uint num2 = (uint)(intVec.x + Directions[i, 0]);
                    uint num3 = (uint)(intVec.z + Directions[i, 1]);
                    if (num2 >= mapSizeX || num3 >= mapSizeZ)
                    {
                        continue;
                    }
                    int x    = (int)num2;
                    int z    = (int)num3;
                    int num4 = cellIndices.CellToIndex(x, z);
                    if (calcGrid[num4].status == statusFinalizedValue)
                    {
                        continue;
                    }
                    blockers[i] = innerArray[num4];
                    if (blockers[i] != null)
                    {
                        if (blockers[i].def.blockLight)
                        {
                            continue;
                        }
                        blockers[i] = null;
                    }
                    int num5 = ((i >= 4) ? 141 : 100);
                    int num6 = calcGrid[curIndex].intDist + num5;
                    if (num6 > num)
                    {
                        continue;
                    }
                    switch (i)
                    {
                    case 4:
                        if (blockers[0] != null && blockers[1] != null)
                        {
                            continue;
                        }
                        break;

                    case 5:
                        if (blockers[1] != null && blockers[2] != null)
                        {
                            continue;
                        }
                        break;

                    case 6:
                        if (blockers[2] != null && blockers[3] != null)
                        {
                            continue;
                        }
                        break;

                    case 7:
                        if (blockers[0] != null && blockers[3] != null)
                        {
                            continue;
                        }
                        break;
                    }
                    if (calcGrid[num4].status <= statusUnseenValue)
                    {
                        calcGrid[num4].intDist = 999999;
                        calcGrid[num4].status  = statusOpenValue;
                    }
                    if (num6 < calcGrid[num4].intDist)
                    {
                        calcGrid[num4].intDist = num6;
                        calcGrid[num4].status  = statusOpenValue;
                        openSet.Push(num4);
                    }
                }
            }
        }
예제 #5
0
        public void AddFloodGlowFor(CompGlower theGlower, Color32[] glowGrid)
        {
            cellIndices      = map.cellIndices;
            this.glowGrid    = glowGrid;
            glower           = theGlower;
            attenLinearSlope = -1f / theGlower.Props.glowRadius;
            Building[] innerArray = map.edificeGrid.InnerArray;
            IntVec3    position   = theGlower.parent.Position;
            int        num        = Mathf.RoundToInt(glower.Props.glowRadius * 100f);
            int        curIndex   = cellIndices.CellToIndex(position);
            int        num2       = 0;
            bool       flag       = UnityData.isDebugBuild && DebugViewSettings.drawGlow;

            InitStatusesAndPushStartNode(ref curIndex, position);
            while (openSet.Count != 0)
            {
                curIndex = openSet.Pop();
                IntVec3 c = cellIndices.IndexToCell(curIndex);
                calcGrid[curIndex].status = statusFinalizedValue;
                SetGlowGridFromDist(curIndex);
                if (flag)
                {
                    map.debugDrawer.FlashCell(c, (float)calcGrid[curIndex].intDist / 10f, calcGrid[curIndex].intDist.ToString("F2"));
                    num2++;
                }
                for (int i = 0; i < 8; i++)
                {
                    uint num3 = (uint)(c.x + Directions[i, 0]);
                    uint num4 = (uint)(c.z + Directions[i, 1]);
                    if (num3 < mapSizeX && num4 < mapSizeZ)
                    {
                        int x    = (int)num3;
                        int z    = (int)num4;
                        int num5 = cellIndices.CellToIndex(x, z);
                        if (calcGrid[num5].status != statusFinalizedValue)
                        {
                            blockers[i] = innerArray[num5];
                            if (blockers[i] != null)
                            {
                                if (blockers[i].def.blockLight)
                                {
                                    continue;
                                }
                                blockers[i] = null;
                            }
                            int num6 = (i >= 4) ? 141 : 100;
                            int num7 = calcGrid[curIndex].intDist + num6;
                            if (num7 <= num)
                            {
                                switch (i)
                                {
                                case 4:
                                    if (blockers[0] != null && blockers[1] != null)
                                    {
                                        break;
                                    }
                                    goto default;

                                case 5:
                                    if (blockers[1] != null && blockers[2] != null)
                                    {
                                        break;
                                    }
                                    goto default;

                                case 6:
                                    if (blockers[2] != null && blockers[3] != null)
                                    {
                                        break;
                                    }
                                    goto default;

                                case 7:
                                    if (blockers[0] != null && blockers[3] != null)
                                    {
                                        break;
                                    }
                                    goto default;

                                default:
                                    if (calcGrid[num5].status <= statusUnseenValue)
                                    {
                                        calcGrid[num5].intDist = 999999;
                                        calcGrid[num5].status  = statusOpenValue;
                                    }
                                    if (num7 < calcGrid[num5].intDist)
                                    {
                                        calcGrid[num5].intDist = num7;
                                        calcGrid[num5].status  = statusOpenValue;
                                        openSet.Push(num5);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }