/// <summary> /// Cycles through critters of this type. /// </summary> internal void OnCycleThrough() { int id = ClusterManager.Instance.activeWorldId; var matching = ListPool <CreatureBrain, PinnedCritterEntry> .Allocate(); // Compile a list of critters matching this species CritterInventoryUtils.GetCritters(id, (creature) => { if (creature.GetCritterType() == CritterType) { matching.Add(creature); } }, Species); int n = matching.Count; if (selectionIndex >= n) { selectionIndex = 0; } else { selectionIndex = (selectionIndex + 1) % n; } if (n > 0) { PUtil.CenterAndSelect(matching[selectionIndex]); } matching.Recycle(); }
/// <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 before OnClick runs. /// </summary> internal static bool Prefix(ResourceEntry __instance, ref int ___selectionIdx) { var entry = __instance.gameObject.GetComponentSafe <CritterResourceEntry>(); bool cont = entry == null; if (!cont) { var creaturesOfType = entry.CachedCritters; // Build list if empty entry.UpdateLastClick(); if (creaturesOfType == null) { creaturesOfType = entry.PopulateCache(); entry.StartCoroutine(entry.ClearCacheAfterThreshold()); } int count = creaturesOfType.Count; if (count > 0) { // Rotate through valid indexes PUtil.CenterAndSelect(creaturesOfType[___selectionIdx++ % count]); } } return(cont); }
/// <summary> /// Selects trapped duplicants on notification select. /// </summary> /// <param name="parameter">The duplicant which is trapped.</param> protected void SelectDuplicant(object parameter) { PUtil.CenterAndSelect(Victim); }
/// <summary> /// Selects trapped or confined duplicants when a notification is clicked. /// </summary> private void SelectDuplicant(object _) { PUtil.CenterAndSelect(master); }