コード例 #1
0
        public List <ItemInfo> ExtractWithinRange(MineralLayer layer, Point location, int range, uint amount)
        {
            var nodes = layer.GetNodesWithinRange(location, range).OrderBy(n => n.Area.SqrDistance(location));

            var result = new List <ItemInfo>();

            foreach (var node in nodes)
            {
                var needed = amount - result.Sum(r => r.Quantity);
                if (needed <= 0)
                {
                    break;
                }

                var nearestNode = node.GetNearestMineralPosition(location);
                if (nearestNode.Distance(location) > range)
                {
                    continue;
                }

                var e = new MineralExtractor(nearestNode, (uint)needed, _materialHelper);
                layer.AcceptVisitor(e);
                result.AddRange(e.Items);
            }

            return(result);
        }
コード例 #2
0
        public List <ItemInfo> Extract(MineralLayer layer, Point location, uint amount)
        {
            if (!layer.HasMineral(location))
            {
                return(new List <ItemInfo>());
            }

            var extractor = new MineralExtractor(location, amount, _materialHelper);

            layer.AcceptVisitor(extractor);
            return(new List <ItemInfo>(extractor.Items));
        }