Esempio n. 1
0
        private void handleItem(string itemName, Database db, HashSet <string> closedNames)
        {
            if (closedNames.Contains(itemName))
            {
                return;
            }
            closedNames.Add(itemName);
            if (!db.itemExistsInMasterList(itemName))
            {
                return;
            }

            // Want to receive properties from all of our parent types
            DBItem        dbItem      = db.getItemFromMasterList(itemName);
            List <string> parentNames = dbItem.getProperty("types") as List <string>;

            if (parentNames == null)
            {
                return;
            }
            foreach (string parentName in parentNames)
            {
                if (!db.itemExistsInMasterList(parentName))
                {
                    continue;
                }
                // Have to handle our parents first so they're up to date
                handleItem(parentName, db, closedNames);
                // Now grab the item and merge any properties we don't have
                DBItem parentItem = db.getItemFromMasterList(parentName);
                foreach (string propertyName in parentItem.getPropertyNames())
                {
                    // Special case for the mutables property
                    if (propertyName == "mutables")
                    {
                        if (dbItem.propertyExists("mutables"))
                        {
                            HashSet <string> currentMutables = new HashSet <string>((List <string>)dbItem.getProperty("mutables"));
                            HashSet <string> parentMutables  = new HashSet <string>((List <string>)parentItem.getProperty("mutables"));
                            currentMutables.UnionWith(parentMutables);
                            dbItem.setProperty("mutables", new List <string>(currentMutables));
                        }
                        else
                        {
                            dbItem.setProperty("mutables", new List <string>((List <string>)parentItem.getProperty("mutables")));
                        }
                    }
                    else if (!dbItem.propertyExists(propertyName))
                    {
                        dbItem.setProperty(propertyName, parentItem.getProperty(propertyName));
                    }
                }
            }
        }
Esempio n. 2
0
        public List <string> filterListByProperty(List <string> itemNames, string propertyName)
        {
            List <string> filteredList = new List <string>();

            foreach (string itemName in itemNames)
            {
                DBItem item = getItem(itemName);
                if (item != null && item.propertyExists(propertyName) && !item.Spawned)
                {
                    filteredList.Add(itemName);
                }
            }
            return(filteredList);
        }
Esempio n. 3
0
        protected bool satisfiesConstraints(DBItem dbitem)
        {
            foreach (string propertyName in _propertiesToFilter.Keys) {
                if (!dbitem.propertyExists(propertyName))
                    return false;
                else if (_propertiesToFilter[propertyName] != null) {
                    if (dbitem.getProperty(propertyName) is List<string>) {
                        if (!(dbitem.getProperty(propertyName) as List<string>).Contains(_propertiesToFilter[propertyName] as string))
                            return false;

                    }
                    else if (!_propertiesToFilter[propertyName].Equals(dbitem.getProperty(propertyName))) {
                        Debug.Log(string.Format("Item {0} failed filter for property {1} expected: {2} actual: {3}", dbitem.ClassName, propertyName, _propertiesToFilter[propertyName], dbitem.getProperty(propertyName)));
                        return false;
                    }
                }
            }
            return true;
        }