/** Returns total demands for selected station and its connected stations */ public Dictionary <Item, int> GetCombinedStationsDemands(VehicleStation station, Dictionary <Item, int> demandsList = null, Dictionary <Item, int> unservicedDemands = null) { Dictionary <Item, int> result = demandsList ?? new Dictionary <Item, int>(); DemandHelper.GetNodesDemands(GetDemandNodes(station), result, unservicedDemands); return(result); }
private HashSet <IStorageNetworkNode> GetDemandNodes(VehicleStation station, bool additionalDemands = true) { if (!_demandNodesCache.TryGetValue((station, additionalDemands), out HashSet <IStorageNetworkNode> result)) { result = new HashSet <IStorageNetworkNode>(DemandHelper.GetStationDemandNodes(station, additionalDemands)); foreach (VehicleStation addStation in GetConnectedStationsEnum(station)) { result.UnionWith(DemandHelper.GetStationDemandNodes(addStation, false, false)); } _demandNodesCache.Add((station, additionalDemands), result); } return(result); }
public bool AddDemand(VehicleStationLocation location, IStorageNetworkNode demand) { if (demand is Store || demand is Lab) { if (DemandHelper.IsInBasicDemand(location.VehicleStation, demand)) { return(false); } _connectedBuildings.Add(demand.Building); bool result = GetOrCreateDemandsList(location.VehicleStation).Add(demand); if (result) { OnDemandChange(location.VehicleStation); } return(result); } throw new ArgumentException("Only Store and Lab can be added as a station demand", nameof(demand)); }
public bool AddConnectedStation(VehicleStation station, VehicleStation stationToAdd) { if (stationToAdd != station) { _connectedBuildings.Add(stationToAdd); bool result = GetOrCreateConnectedStationsList(station).Add(stationToAdd); if (result) { if (_additionalDemands.TryGetValue(station, out UniqueList <IStorageNetworkNode> additionalDemands)) { //remove demands of added station from additional demands of own station foreach (IStorageNetworkNode node in DemandHelper.GetStationDemandNodes(stationToAdd, false)) { additionalDemands.QuickRemove(node); } } OnConnectedStationChange(station); } return(result); } return(false); }