/// <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); } } }
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)); } }