/// <summary> /// Applied after OnClick runs. /// </summary> /// <param name="__instance">The current resource entry.</param> /// <param name="___selectionIdx">The current selection index.</param> internal static void Postfix(ResourceEntry __instance, ref int ___selectionIdx) { var info = __instance.gameObject.GetComponentSafe <CritterResourceInfo>(); if (info != null) { var creaturesOfType = ListPool <CreatureBrain, ResourceCategoryHeader> . Allocate(); CritterType type = info.CritterType; var species = __instance.Resource; // Get a list of creatures that match this type CritterInventoryUtils.IterateCreatures((creature) => { if (creature.PrefabID() == species && type.Matches(creature)) { creaturesOfType.Add(creature); } }); int count = creaturesOfType.Count; if (count > 0) { // Rotate through valid indexes // Select the object and center it PUtil.CenterAndSelect(creaturesOfType[___selectionIdx++ % count]); } creaturesOfType.Recycle(); } }
/// <summary> /// Applied after Hover runs. /// </summary> /// <param name="__instance">The current resource entry.</param> /// <param name="is_hovering">true if the user is hovering, or false otherwise</param> /// <param name="___HighlightColor">The highlight color from the instance.</param> internal static void Postfix(ResourceEntry __instance, bool is_hovering, Color ___HighlightColor) { var info = __instance.gameObject.GetComponent<CritterResourceInfo>(); if (info != null) { var hlc = ___HighlightColor; CritterType type = info.CritterType; Tag species = __instance.Resource; CritterInventoryUtils.IterateCreatures((creature) => { if (creature.PrefabID() == species && type.Matches(creature)) PUtil.HighlightEntity(creature, is_hovering ? hlc : Color.black); }); } }
/// <summary> /// Applied after Hover runs. /// </summary> /// <param name="__instance">The current resource category header.</param> /// <param name="is_hovering">true if the user is hovering, or false otherwise.</param> /// <param name="___highlightColour">The highlight color from the instance.</param> internal static void Postfix(ResourceCategoryHeader __instance, bool is_hovering, Color ___highlightColour) { var info = __instance.gameObject.GetComponent<CritterResourceInfo>(); if (info != null) { CritterType type = info.CritterType; // It is a creature header, highlight all matching CritterInventoryUtils.IterateCreatures((creature) => { if (type.Matches(creature)) PUtil.HighlightEntity(creature, is_hovering ? ___highlightColour : Color.black); }); } }