public bool UpdateChanges(short id, string property, string value) { ItemChange temp; if (Changes.TryGetValue(id, out temp)) { temp[property] = value; if (!temp.HasChanges) { Changes.Remove(id); } else { return(true); } } else if (!string.IsNullOrEmpty(value)) { string name = Reader.DefaultsByID[id].Object; temp = new ItemChange(name); Changes.Add(id, temp); temp[property] = value; return(true); } return(false); }
public static void ApplyChanges(Grid grid, Dictionary <string, string> changes = null) { if (changes == null) { changes = grid.Info["tiles"]; } if (changes == null) { return; } Dictionary <short, ItemChange> itemChanges = grid.Changes; itemChanges.Clear(); foreach (KeyValuePair <string, string> pair in changes) { if (pair.Key.IndexOf("object") == 0) { int index = pair.Key.IndexOf('_'); string objectName = pair.Key.Substring(0, index); ItemChange item; Item defaultItem = DefaultsByObject[objectName]; short id = defaultItem.ID; if (!itemChanges.TryGetValue(id, out item)) { item = new ItemChange(objectName); itemChanges.Add(id, item); } string property = pair.Key.Substring(index + 1).ToLower(); item[property] = pair.Value; if (property == "image" && !Sprites.ContainsKey(pair.Value)) { item["image"] = defaultItem.Sprite; } } } grid.ApplyChanges(); }