コード例 #1
0
        public override void MapComponentTick()
        {
            base.MapComponentTick();

            if (DirtyCells.Count != 0)
            {
                HashSet <Building_Window> windowsToUpdate = new HashSet <Building_Window>();
                foreach (var c in DirtyCells)
                {
                    try
                    {
                        foreach (var window in WindowCells[c])
                        {
                            windowsToUpdate.Add(window);
                        }
                    } catch
                    {
                        DirtyCells.Remove(c);
                    }
                }

                foreach (var window in windowsToUpdate)
                {
                    UpdateWindowCells(window, false);
                    // when we attempt to resolve the facing, we also query cells, and push them to the calculation
                    window.Cells = WindowUtility.CalculateWindowLightCells(window, window.WindowComp.TryResolveFacing());
                    UpdateWindowCells(window, true);

                    DirtyCells.Clear();
                }
            }
        }
コード例 #2
0
 public void RegisterWindow(Building_Window window)
 {
     if (!windows.Contains(window))
     {
         windows.Add(window);
         // when we attempt to resolve the facing, we also query cells, and push them to the calculation
         if (window.WindowComp.facing == LinkDirections.None)
         {
             window.Cells = WindowUtility.CalculateWindowLightCells(window, window.WindowComp.TryResolveFacing());
         }
         UpdateWindowCells(window, true);
     }
 }
コード例 #3
0
        private void UpdateWindow()
        {
            WindowCache.WindowComponent.UpdateWindowCells(Parent, false);
            Parent.Cells = WindowUtility.CalculateWindowLightCells(Parent);
            WindowCache.WindowComponent.UpdateWindowCells(Parent, true);

            Find.CurrentMap.mapDrawer.MapMeshDirty(Parent.Position, MapMeshFlag.GroundGlow);

            if (ElifsDecorationsSettings.BeautyEnabled)
            {
                GetBeauty();
            }
        }
コード例 #4
0
        public void GetBeauty()
        {
            CachedBeauty = 0f;

            if (state == State.Closed || ElifsDecorationsSettings.BeautyEnabled)
            {
                return;
            }

            var things = new List <Thing>();

            foreach (var cell in WindowUtility.GetWindowCells(Parent, true).Except(Parent.Cells))
            {
                CachedBeauty += BeautyUtility.CellBeauty(cell, Parent.Map, things);
            }


            CachedBeauty *= .9f;
        }
コード例 #5
0
        // in short, get all the cells in the 'radius' of the window, whichever 'side' of the window has less roof cells becomes the side that is being faced, i.e. light goes to the side with more roofs
        public List <IntVec3> TryResolveFacing()
        {
            var cells = WindowUtility.GetWindowCells(Parent, true);

            int count     = 0;
            int leftCount = 0;
            var map       = Parent.Map;

            foreach (var c in cells)
            {
                if (Parent.Rotation.IsHorizontal)
                {
                    if (c.x > Parent.Position.x)
                    {
                        if (c.Roofed(map))
                        {
                            leftCount++;
                        }
                        else
                        if (c.Roofed(map))
                        {
                            count++;
                        }
                    }
                }
                else
                {
                    if (c.z > Parent.Position.z)
                    {
                        if (c.Roofed(map))
                        {
                            leftCount++;
                        }
                        else
                        if (c.Roofed(map))
                        {
                            count++;
                        }
                    }
                }
            }

            if (count > leftCount)
            {
                if (Parent.Rotation.IsHorizontal)
                {
                    facing = LinkDirections.Left;
                }
                else
                {
                    facing = LinkDirections.Down;
                }
            }
            else if (count < leftCount)
            {
                if (Parent.Rotation.IsHorizontal)
                {
                    facing = LinkDirections.Right;
                }
                else
                {
                    facing = LinkDirections.Up;
                }
            }
            else
            {
                facing = LinkDirections.None;
            }

            return(cells);
        }