private IDictionary <int, RandomAccessSet <Vector> > GetResourceRegister(BuildingResourceProduction buildingResourceProduction) { if (buildingResourceProduction.IsProducer()) { return(this.producersForResource); } else if (buildingResourceProduction.IsConsumer()) { return(this.consumersForResource); } return(null); }
public Vector?GetRandomSupplyChainLink(BuildingResourceProduction buildingResourceProduction) { var resourceRegister = this.GetResourceRegister(buildingResourceProduction); if (resourceRegister == null) { return(null); } RandomAccessSet <Vector> producersForResource = GetOrCreateRegisterStorage(resourceRegister, buildingResourceProduction.ResourceId); int candidatesSize = producersForResource.Size; if (candidatesSize > 0) { return(this.TransportLinkForResult(producersForResource[this.random.Next(candidatesSize)])); } else { return(null); } }