private void Sync(WarpChest stat, WarpChest change) { //Monitor.Log("Syncing Chests.", LogLevel.Debug); IList <Item> removes = new List <Item>(); foreach (Item item in stat.container.items) { if (!change.HasItem(item)) { removes.Add(item); //Monitor.Log("Removing Item: " + item.DisplayName, LogLevel.Debug); } } foreach (Item item in removes) { stat.container.items.Remove(item); } foreach (Item item in change.container.items) { if (!stat.HasItem(item)) { stat.container.addItem(item); //Monitor.Log("Adding Item: " + item.DisplayName, LogLevel.Debug); } } }
private void DualSync(WarpChest warp1, WarpChest warp2) { //Monitor.Log("Syncing Chests.", LogLevel.Debug); IEnumerable <Item> warp1Added = warp1.state.Where(item => !warp1.HasItem(item)); IEnumerable <Item> warp1Removed = warp1.container.items.Where(item => !warp1.HadItem(item)); IEnumerable <Item> warp2Added = warp2.state.Where(item => !warp2.HasItem(item)); IEnumerable <Item> warp2Removed = warp2.container.items.Where(item => !warp2.HadItem(item)); foreach (Item item in warp1Removed) { warp2.container.items.Remove(item); //Monitor.Log("Removing Item: " + item.DisplayName, LogLevel.Debug); } foreach (Item item in warp2Removed) { warp1.container.items.Remove(item); //Monitor.Log("Removing Item: " + item.DisplayName, LogLevel.Debug); } foreach (Item item in warp1Added) { warp2.container.addItem(item); } foreach (Item item in warp2Added) { warp1.container.addItem(item); } }