예제 #1
0
            /// <summary>
            /// Applied before SearchFilter runs.
            /// </summary>
            internal static void Prefix(AllResourcesScreen __instance, string search)
            {
                var cr = __instance.GetComponent <CritterCategoryRows>();

                if (cr != null)
                {
                    cr.SearchFilter(search);
                }
            }
예제 #2
0
            /// <summary>
            /// Applied after RefreshRows runs.
            /// </summary>
            internal static void Postfix(AllResourcesScreen __instance)
            {
                var cr = __instance.GetComponent <CritterCategoryRows>();

                if (cr != null)
                {
                    cr.UpdateContents();
                }
            }
예제 #3
0
        /// <summary>
        /// Creates new rows if necessary for each critter species, and sorts them by name.
        /// </summary>
        /// <param name="allResources">The parent window for the rows.</param>
        internal void SpawnRows(AllResourcesScreen allResources)
        {
            var ci = ClusterManager.Instance.activeWorld.GetComponent <CritterInventory>();

            if (ci != null)
            {
                var allCritters = DictionaryPool <Tag, CritterTotals, CritterResourceRowGroup> .
                                  Allocate();

                ci.PopulateTotals(CritterType, allCritters);
                bool dirty = false;
                // Insert new rows where necessary
                foreach (var pair in allCritters)
                {
                    var species = pair.Key;
                    if (!resources.ContainsKey(species))
                    {
                        resources.Add(species, Create(allResources, species));
                        dirty = true;
                    }
                }
                // Iterate and place in SORTED order in the UI
                if (dirty)
                {
                    foreach (var resource in resources)
                    {
                        resource.Value.gameObject.transform.SetAsLastSibling();
                    }
                }
                allCritters.Recycle();
                if (dirty)
                {
                    UpdateContents();
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Applied after OnPrefabInit runs.
 /// </summary>
 internal static void Postfix(AllResourcesScreen __instance)
 {
     __instance.gameObject.AddOrGet <CritterCategoryRows>();
 }