public void PostLoad() { DoInitIfNeeded(); string[] idsToAdd = this.inventoryItemsToAdd.Split(','); foreach (string id in idsToAdd) { Optional <IIdentifiable> found = God.GetByID(id); if (found.IsPresent()) { Optional <InventoryItem> toAdd = Optional <InventoryItem> .Empty(); try { toAdd = Optional <InventoryItem> .Of((InventoryItem)found.Get()); } catch (InvalidCastException) { Debug.Log("Failed to cast to inventory item: " + found.Get()); } if (toAdd.IsPresent()) { this.Bag.Add(toAdd.Get()); } } else { } } }
private bool SearchForChild() { Optional <IIdentifiable> possibleChild = God.GetByID(childID); if (possibleChild.IsPresent()) { child = (IPersistantObject)(possibleChild.Get()); gameChild = child.GetMono().gameObject; gameChild.SetActive(false); return(true); } return(false); }