Exemplo n.º 1
0
        public override void runExtension(Database db)
        {
            foreach (DBItem dbItem in db.getSpawnableItems()) {
                if (!dbItem.propertyExists("changes"))
                    continue;

                Dictionary<string, List<string>> changesDict = (Dictionary<string, List<string>>)dbItem.getProperty("changes");
                // Find each item we can change via the mutables property
                foreach (string propertyName in changesDict.Keys) {
                    foreach (DBItem maybeChangee in db.getSpawnableItems()) {
                        if (!maybeChangee.propertyExists("mutables"))
                            continue;
                        List<string> mutables = (List<string>)maybeChangee.getProperty("mutables");
                        if (!mutables.Contains(propertyName))
                            continue;
                        if (maybeChangee.propertyExists("changedby")) {
                            List<string> changedby = (List<string>)maybeChangee.getProperty("changedby");
                            if (!changedby.Contains(dbItem.ClassName))
                                changedby.Add(dbItem.ClassName);
                        }
                        else {
                            maybeChangee.setProperty("changedby", new List<string>() { dbItem.ClassName });
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 // The Parent Extension is used to allow certain database items to inherit properties from other (abstract) items.
 public override void runExtension(Database db)
 {
     HashSet<string> closedNames = new HashSet<string>();
     foreach (string itemName in db.allItemNames()) {
         handleItem(itemName, db, closedNames);
     }
 }
Exemplo n.º 3
0
 public override void runExtension(Database db)
 {
     // Basically , take the "changes" property and change it from a List<KeyValuePair<string, string>>
     // To a Dictionary<string, List<string>>
     foreach (DBItem dbitem in db.getAllItems()) {
         if (dbitem.propertyExists("changes")) {
             List<KeyValuePair<string, string>> changesPairs = (List<KeyValuePair<string, string>>)dbitem.getProperty("changes");
             Dictionary<string, List<string>> changesDict = new Dictionary<string, List<string>>();
             foreach (KeyValuePair<string, string> changesPair in changesPairs) {
                 string changePropName = changesPair.Key;
                 string changePropVal = changesPair.Value;
                 if (changesDict.ContainsKey(changePropName))
                     changesDict[changePropName].Add(changePropVal);
                 else
                     changesDict[changePropName] = new List<string>() { changePropVal };
             }
             dbitem.setProperty("changes", changesDict);
         }
     }
 }
Exemplo n.º 4
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));
                    }
                }
            }
        }
Exemplo n.º 5
0
 public abstract void runExtension(Database db);