Exemple #1
0
            protected Item FindRandomContainer(ICollection <Traitor> traitors, ItemPrefab targetPrefabCandidate, bool includeNew, bool includeExisting)
            {
                List <Item> suitableItems = new List <Item>();

                foreach (Item item in Item.ItemList)
                {
                    if (item.Submarine == null || traitors.All(traitor => item.Submarine.TeamID != traitor.Character.TeamID))
                    {
                        continue;
                    }
                    if (item.GetComponent <ItemContainer>() != null && allowedContainerIdentifiers.Contains(item.prefab.Identifier))
                    {
                        if ((includeNew && !item.OwnInventory.IsFull()) || (includeExisting && item.OwnInventory.FindItemByIdentifier(targetPrefabCandidate.Identifier) != null))
                        {
                            suitableItems.Add(item);
                        }
                    }
                }

                if (suitableItems.Count == 0)
                {
                    return(null);
                }
                return(suitableItems[TraitorMission.Random(suitableItems.Count)]);
            }