private static RandomAccessSet <Vector> GetOrCreateRegisterStorage(IDictionary <int, RandomAccessSet <Vector> > resourceRegister, int resourceId)
        {
            if (!resourceRegister.TryGetValue(resourceId, out RandomAccessSet <Vector> result))
            {
                result = new RandomAccessSet <Vector>(64);
                resourceRegister[resourceId] = result;
            }

            return(result);
        }
        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);
            }
        }