private void _storageDB_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { CargoStorageByTypeVM storeType = new CargoStorageByTypeVM(_gameVM); KeyValuePair <Guid, object> kvp = (KeyValuePair <Guid, object>)e.NewItems[0]; storeType.Initalise(_storageDB, kvp.Key); CargoStore.Add(storeType); } }
public void Initialise(Entity entity) { _storageDB = entity.GetDataBlob <CargoStorageDB>(); foreach (var item in _storageDB.CargoCapicity) { CargoStorageByTypeVM storeType = new CargoStorageByTypeVM(_gameVM); storeType.Initalise(_storageDB, item.Key); CargoStore.Add(storeType); } _storageDB.CargoCapicity.CollectionChanged += _storageDB_CollectionChanged; _storageDB.StoredEntities.CollectionChanged += StoredEntities_CollectionChanged; }