コード例 #1
0
            public static bool Prefix(
                StarmapRenderer __instance,
                StarSystemNode node,
                StarmapSystemRenderer renderer)
            {
                return(HarmonyManager.PrefixLogExceptions(() =>
                {
                    bool flag = __instance.starmap.CanTravelToNode(node, false);
                    RGBColor <float> color = new RGBColor <float>(1, 1, 1);

                    VisitedColors visitedColors = HarmonyManager.Settings.VisitedColors;

                    switch (CurrentMapType)
                    {
                    case MapType.None:
                        return true;

                    case MapType.Difficulty:
                        color = GetDifficultyColor(__instance, node);
                        break;

                    case MapType.Visited:
                        color = __instance.starmap.HasStarSystemBeenVisited(node)
                                        ? visitedColors.VisitedColor
                                        : visitedColors.NotVisitedColor;
                        break;

                    case MapType.MaxContracts:
                        color = GetDifficultyColor((int)node.System.CurMaxContracts);
                        break;

                    default:
                        throw new InvalidEnumArgumentException("'CurrentMapType' has invalid value. This should never happen. Please report this as a bug.");
                    }
                    if (renderer.Init(node, flag ? color.FromRGBColor() : __instance.unavailableColor, flag))
                    {
                        __instance.RefreshBorders();
                    }

                    // Don't call the original method, we've replaced it.
                    return false;
                }));
            }