public static bool Prefix([HarmonyArgument(0)] int colorId, [HarmonyArgument(1)] Renderer rend) { if (CustomColorExtensions.TryGetCustomColorById(colorId, out var customColor) && customColor.Type == CustomColorTypes.Cyclic) { rend.gameObject.SetCyclicVisorColor(customColor as CyclicColor); return(false); } rend.gameObject.ClearCyclicColor(); return(true); }
public static void Postfix(PlayerTab __instance) { __instance.ColorTabPrefab.transform.localScale = new Vector3(1f, 1f, 1f); __instance.XRange.min += 0.1f; __instance.XRange.max -= 0.1f; foreach (var colorChip in __instance.ColorChips) { colorChip.gameObject.Destroy(); } __instance.ColorChips.Clear(); for (var i = 0; i < Palette.PlayerColors.Length; i++) { var isCustomColor = CustomColorExtensions.TryGetCustomColorById(i, out var customColor); if (isCustomColor && customColor.Hidden) { continue; } var x = __instance.XRange.Lerp(i % 5 / 4f); var y = __instance.YStart - i / 5 * 0.5f; var colorChip = UnityEngine.Object.Instantiate(__instance.ColorTabPrefab, __instance.ColorTabArea); colorChip.transform.localPosition = new Vector3(x, y, -1f); var j = i; colorChip.Button.OnClick.AddListener((Action) delegate { __instance.SelectColor(j); }); if (isCustomColor && customColor.Type == CustomColorTypes.Cyclic) { colorChip.gameObject.SetCyclicColor(customColor as CyclicColor); } else { colorChip.gameObject.ClearCyclicColor(); } colorChip.Inner.color = Palette.PlayerColors[i]; __instance.ColorChips.Add(colorChip); } }