/// <summary>
        /// Adds a newly found reachable item to the world inventory.
        /// </summary>
        /// <param name="pickupable">The item to add.</param>
        /// <param name="inventory">The inventory where it should be added.</param>
        private static void AddFetchable(Pickupable pickupable, InventoryDict inventory)
        {
            var kpid      = pickupable.KPrefabID;
            var prefabTag = kpid.PrefabTag;

            if (!inventory.ContainsKey(prefabTag))
            {
                var category = DiscoveredResources.GetCategoryForEntity(kpid);
                if (!category.IsValid)
                {
                    PUtil.LogWarning(pickupable.name +
                                     " was found by WorldInventory, but has no category! Add it to the element definition.");
                }
                else
                {
                    DiscoveredResources.Instance.Discover(prefabTag, category);
                }
            }
            foreach (var itemTag in kpid.Tags)
            {
                if (BackgroundWorldInventory.IsAcceptable(itemTag))
                {
                    if (!inventory.TryGetValue(itemTag, out HashSet <Pickupable> entry))
                    {
                        inventory[itemTag] = entry = new HashSet <Pickupable>();
                    }
                    entry.Add(pickupable);
                }
            }
        }
            /// <summary>
            /// Applied after CreatePrefab runs.
            /// </summary>
            internal static void Postfix(GameObject __result)
            {
                var prefabID = __result.GetComponent <KPrefabID>();
                // ExtendEntityToFertileCreature requires an egg prefab
                var fm = __result.AddOrGetDef <LiveFertilityMonitor.Def>();

                fm.initialBreedingWeights = new List <FertilityMonitor.BreedingChance>()
                {
                    new FertilityMonitor.BreedingChance()
                    {
                        egg    = BabyMooConfig.ID_TAG,
                        weight = 1.0f
                    }
                };
                // Reduce to 2kg meat for adult
                var butcherable = __result.GetComponent <Butcherable>();

                if (butcherable != null)
                {
                    butcherable.SetDrops(new string[] { MeatConfig.ID, MeatConfig.ID });
                }
                // Hardcoded in CreateMoo, 6/10ths of the max age
                fm.baseFertileCycles    = 45.0f;
                prefabID.prefabSpawnFn += (inst) => {
                    // Needs to be changed for vanilla
                    DiscoveredResources.Instance.Discover(BabyMooConfig.ID_TAG,
                                                          DiscoveredResources.GetCategoryForTags(prefabID.Tags));
                };
                UpdateMooChores(__result);
            }
Example #3
0
            private static void Discover(DiscoveredResources di, Pickupable pickupable)
            {
                int cell = Grid.PosToCell(pickupable);
                Tag tag;
                var prefabID = pickupable.GetComponent <KPrefabID>();

                if (prefabID != null && !di.IsDiscovered(tag = prefabID.PrefabTag) && Grid.
                    IsValidCell(cell) && Grid.Revealed[cell])
                {
                    di.Discover(tag, DiscoveredResources.GetCategoryForEntity(prefabID));
                }
            }
Example #4
0
 internal static void Postfix(DiscoveredResources __instance)
 {
     if (!AllDiscovered)
     {
         foreach (var item in Components.Pickupables)
         {
             if (item is Pickupable pickupable && pickupable != null)
             {
                 Discover(__instance, pickupable);
             }
         }
         AllDiscovered = true;
     }
 }