Exemplo n.º 1
0
        public Route(
            string originBody,
            string originBiome,
            string destinationBody,
            string destinationBiome,
            int payload,
            IDepotRegistry depotRegistry)
        {
            OriginBody       = originBody;
            OriginBiome      = originBiome;
            DestinationBody  = destinationBody;
            DestinationBiome = destinationBiome;
            if (payload < 1)
            {
                throw new RouteInsufficientPayloadException();
            }
            Payload = payload;

            OriginDepot      = depotRegistry.GetDepot(originBody, originBiome);
            DestinationDepot = depotRegistry.GetDepot(destinationBody, destinationBiome);
        }
Exemplo n.º 2
0
        public void OnLoad(ConfigNode node)
        {
            OriginBody       = node.GetValue("OriginBody");
            OriginBiome      = node.GetValue("OriginBiome");
            DestinationBody  = node.GetValue("DestinationBody");
            DestinationBiome = node.GetValue("DestinationBiome");
            Payload          = int.Parse(node.GetValue("Payload"));

            OriginDepot      = _depotRegistry.GetDepot(OriginBody, OriginBiome);
            DestinationDepot = _depotRegistry.GetDepot(DestinationBody, DestinationBiome);

            var resourceNodes = node.GetNodes();

            foreach (var resourceNode in resourceNodes)
            {
                var resourceName = resourceNode.GetValue("ResourceName");
                if (!_resources.ContainsKey(resourceName))
                {
                    var quantity = int.Parse(resourceNode.GetValue("Quantity"));

                    _resources.Add(resourceName, quantity);
                }
            }
        }