private static RadialCell CreateChildCell(uGUI_CraftingMenu.Node node, RadialCell parent, int index) { var siblings = node.parent.childCount; var size = ComputeNewSize(parent); var radius = ComputeNewRadius(parent, size); var maxSiblings = GetPolygonLineCount(radius, size); if (siblings > maxSiblings) { size = GetPolygonLineSize(radius, siblings); var angleDelta1 = 2 * Mathf.PI / siblings; var angle1 = angleDelta1 * index + GetExtraAngleOffset(siblings); return(new RadialCell(radius, angle1, size, float.NaN, siblings, parent)); } var angleDelta = 2 * Mathf.PI / maxSiblings; var groupAngle = siblings > parent.siblings ? parent.groupAngle : parent.angle; if (float.IsNaN(groupAngle)) { groupAngle = parent.angle; } var angle = groupAngle + angleDelta * (index - (siblings - 1) / 2.0f); return(new RadialCell(radius, angle, size, groupAngle, siblings, parent)); }
public static void SetNodeChroma(uGUI_CraftNode node, bool enabled) { if (!node.icon) { return; } node.icon.SetForegroundChroma(enabled ? 1 : 0); node.icon.SetBackgroundChroma(enabled ? 1 : .2f); }
public static void PaintNodeColorAnimated(uGUI_CraftNode node) { #if SUBNAUTICA var frontColor = RecyclingData.IsBlackListed(node.techType0) ? Color.black : GUIFormatter.frontColor; #elif BELOWZERO var frontColor = RecyclingData.IsBlackListed(node.techType) ? Color.black : GUIFormatter.frontColor; #endif AnimateIconColor(node.icon, frontColor, backColor); }
private static void Postfix(uGUI_CraftingMenu __instance, uGUI_CraftingMenu.Node node) { if (!Active) { return; } if (__instance != CurrentMenu) { return; } GUIFormatter.SetNodeChroma(node, true); }
private static void ForeachChildRecursively(uGUI_CraftNode node, Action <uGUI_CraftNode> action) { if (node == null) { return; } foreach (var child in node) { action(child); ForeachChildRecursively(child, action); } }
private static void Postfix(uGUI_CraftNode __instance) { if (!Active) { return; } if (__instance.view != CurrentMenu) { return; } GUIFormatter.PaintNodeColor(__instance); }
private static void Postfix(uGUI_CraftingMenu.Node node) { if (node.icon == null) { return; } RadialCell radialCell = RadialCell.Create(node, LastIndex); Vector2 targetPosition = node.expanded ? radialCell.Position : radialCell.parent.Position; float speed = (radialCell.radius + radialCell.size) * (float)Config.AnimationSpeedMult; float fadeDistance = radialCell.size * (float)Config.AnimationFadeDistanceMult; GhostMoving newAnimation = new GhostMoving(speed, fadeDistance, targetPosition); ItemIconAnimation.Play(node.icon, newAnimation); }
private static void Postfix(uGUI_CraftingMenu.Node node) { RadialCell radialCell = RadialCell.Create(node, LastIndex); var icon = node.icon; var vector = new Vector2(radialCell.size, radialCell.size); icon.SetBackgroundSize(vector); icon.SetActiveSize(vector); float num = radialCell.size * (float)Config.IconForegroundSizeMult; icon.SetForegroundSize(num, num, true); icon.SetBackgroundRadius(radialCell.size / 2f); icon.rectTransform.SetParent(node.icon.canvas.transform); icon.SetPosition(radialCell.parent.Position); }
private static void Postfix(uGUI_CraftingMenu __instance, uGUI_CraftingMenu.Node sender) { bool client = __instance.client != null; bool interactable = __instance.interactable; if (!client || !interactable || !__instance.ActionAvailable(sender)) { if (sender.icon == null) { return; } float duration = 1f + UnityEngine.Random.Range(-0.2f, 0.2f); sender.icon.PunchScale(5f, 0.5f, duration, 0f); } }
private static void Deactivate() { if (!Active) { return; } Active = false; int c = 0, n = 0; uGUI_CraftNode menuRoot = GUIHandler.CurrentMenu.icons; ForeachChildRecursively(menuRoot, x => ReplaceNodeTech(x)); menuRoot?.UpdateRecursively(ref c, ref n); ForeachChildRecursively(menuRoot, x => GUIFormatter.RevertNodeColorAnimated(x)); }
private static RadialCell CreateChildCellWithOneElementAtRoot(uGUI_CraftingMenu.Node node, RadialCell parent, int index) { var siblings = node.parent.childCount; var size = ComputeNewSize(parent); var radius = ComputeNewRadius(parent, size); var maxSiblings = GetPolygonLineCount(radius, size); if (siblings > maxSiblings) { size = GetPolygonLineSize(radius, siblings); } var angleDelta = 2 * Mathf.PI / siblings; var angle = angleDelta * index + GetExtraAngleOffset(siblings); return(new RadialCell(radius, angle, size, float.NaN, siblings, parent)); }
private static void Postfix(uGUI_CraftNode __instance, bool available) { if (!Active) { return; } if (__instance.view != CurrentMenu) { return; } if (__instance.visible) { var enabled = available && !__instance.IsLockedInHierarchy(); GUIFormatter.SetNodeChroma(__instance, enabled); } }
//private void CreateIcon(uGUI_CraftingMenu.Node node, RectTransform canvas, float size, float x, float y) public static void CreateIcon_Postfix(uGUI_CraftingMenu __instance, uGUI_CraftingMenu.Node node, RectTransform canvas, float size, float x, float y) { if (node != null && node.action == TreeAction.Expand) { if (__instance != null && node.icon != null) { // If current node belongs to one of our custom fabricators if (__instance.id == "DecorationsFabricator" && DecorationNodes.Contains(node.id)) { node.icon.SetBackgroundColors(DNormal, DHover, DPressed); } else if (__instance.id == "FloraFabricator" && FloraNodes.Contains(node.id)) { node.icon.SetBackgroundColors(FNormal, FHover, FPressed); } } } }
public static RadialCell Create(uGUI_CraftingMenu.Node node, int index) { if (node.parent == null) { return(InvalidCell); } var parentCell = Create(node.parent as uGUI_CraftingMenu.Node, index); if (parentCell == InvalidCell) { return(CreateRootCell(node, index)); } return(parentCell.radius == 0 ? CreateChildCellWithOneElementAtRoot(node, parentCell, index) : CreateChildCell(node, parentCell, index)); }
private static void ReplaceNodeTech(uGUI_CraftNode node) { if (node.action != TreeAction.Craft) { return; } if (!node.techType0.ToString().StartsWith("Defabricated") && RecyclingData.TryGet(node.techType0, out TechType recyclingTech)) { node.techType0 = recyclingTech; } else if (node.techType0.ToString().StartsWith("Defabricated")) { TechTypeExtensions.FromString(node.techType0.ToString().Replace("Defabricated", ""), out TechType original, true); node.techType0 = original; } else { ErrorMessage.AddMessage($"Failed to change {node.techType0}"); } }
private static RadialCell CreateRootCell(uGUI_CraftingMenu.Node node, int index) { var siblings = node.parent.childCount; var size = (float)Config.RootIconSize; if (siblings <= 1) { return(new RadialCell(0, 0, size, float.NaN, siblings, InvalidCell)); } var radius = GetPolygonRadius(size, siblings); if (siblings > Config.MaxRootIconCount) { radius = GetPolygonRadius(size, Config.MaxRootIconCount); size = GetPolygonLineSize(radius, siblings); } var angleDelta = 2 * Mathf.PI / siblings; var angle = angleDelta * index + GetExtraAngleOffset(siblings); return(new RadialCell(radius, angle, size, float.NaN, siblings, InvalidCell)); }
public static void RevertNodeColorAnimated(uGUI_CraftNode node) { AnimateIconColor(node.icon, Color.white, Color.white); }
private static void Postfix(RectTransform canvas, uGUI_CraftingMenu.Node node, int index, int siblings) { LastIndex = index; }
public static void RevertNodeColor(uGUI_CraftNode node) { SetIconColors(node.icon, Color.white, Color.white); }
private static void Postfix(uGUI_CraftingMenu __instance, ref bool __result, uGUI_CraftNode sender) { if (!Active) { return; } if (CurrentMenu != __instance) { return; } if (sender.action != TreeAction.Craft) { return; } #if SUBNAUTICA __result &= !RecyclingData.IsBlackListed(sender.techType0); #elif BELOWZERO __result &= !RecyclingData.IsBlackListed(sender.techType); #endif }