예제 #1
0
 private void RegisterMode(OverlayModes.Mode mode)
 {
     modeInfos[mode.ViewMode()] = new ModeInfo
     {
         mode = mode
     };
 }
예제 #2
0
 public void SetLegend(OverlayModes.Mode mode, bool refreshing = false)
 {
     if (currentMode == null || !(currentMode.ViewMode() == mode.ViewMode()) || refreshing)
     {
         ClearLegend();
         OverlayInfo legend = overlayInfoList.Find((OverlayInfo ol) => ol.mode == mode.ViewMode());
         currentMode = mode;
         SetLegend(legend);
     }
 }
예제 #3
0
 /// <summary>
 /// A replacement for the particular AddTargetIfVisible version using SaveLoadRoot.
 /// </summary>
 /// <param name="instance">The object under test.</param>
 /// <param name="visMin">The minimum visible cell coordinate.</param>
 /// <param name="visMax">The maximum visible cell coordinate.</param>
 /// <param name="targets">The location to add the target if it matches.</param>
 /// <param name="layer">The layer to move the target if it matches.</param>
 /// <param name="onAdded">The callback to invoke if it matches.</param>
 /// <param name="shouldAdd">The callback to invoke and check if it matches.</param>
 private static void AddTargetIfVisible(OverlayModes.Mode _, SaveLoadRoot instance,
                                        Vector2I visMin, Vector2I visMax, ICollection <SaveLoadRoot> targets, int layer,
                                        Action <SaveLoadRoot> onAdded, Func <KMonoBehaviour, bool> shouldAdd)
 {
     if (instance != null)
     {
         Vector2 min = instance.PosMin(), max = instance.PosMax();
         int     xMin = (int)min.x, yMin = (int)min.y, yMax = (int)max.y, xMax = (int)max.x;
         if (xMax >= visMin.x && yMax >= visMin.y && xMin <= visMax.x && yMin <= visMax.
             y && !targets.Contains(instance))
         {
             bool found = !PropertyTextures.IsFogOfWarEnabled;
             int  curWorld = ClusterManager.Instance.activeWorldId, w = Grid.
                                                                        WidthInCells, cell = w * yMin + xMin;
             int width = xMax - xMin + 1, height = yMax - yMin + 1;
             // Iterate the extents of the object to see if any cell is visible
             w -= width;
             for (int y = height; y > 0 && !found; y--)
             {
                 for (int x = width; x > 0 && !found; x--)
                 {
                     // 20 is hardcoded in original method
                     if (Grid.IsValidCell(cell) && Grid.Visible[cell] > 20 &&
                         Grid.WorldIdx[cell] == curWorld)
                     {
                         found = true;
                     }
                     cell++;
                 }
                 cell += w;
             }
             if (found)
             {
                 var kmb = instance as KMonoBehaviour;
                 if (shouldAdd == null || kmb == null || shouldAdd(kmb))
                 {
                     // Add to list and trigger overlay mode update
                     if (kmb != null)
                     {
                         if (kmb.TryGetComponent(out KBatchedAnimController kbac))
                         {
                             kbac.SetLayer(layer);
                         }
                         if (kmb.TryGetComponent(out UpdateGraphIfEntombed updateGraph))
                         {
                             updateGraph.UpdateOverlay(true);
                         }
                     }
                     targets.Add(instance);
                     onAdded?.Invoke(instance);
                 }
             }
         }
     }
 }
예제 #4
0
 public OverlayInfo GetOverlayInfo(OverlayModes.Mode mode)
 {
     for (int i = 0; i < overlayInfoList.Count; i++)
     {
         if (overlayInfoList[i].mode == mode.ViewMode())
         {
             return(overlayInfoList[i]);
         }
     }
     return(null);
 }