コード例 #1
0
        public BuildingContentsInfo(GameLocation location, List <string> supportedContainerTypes)
        {
            if (location == null)
            {
                Containers           = null;
                NumberOfItems        = 0;
                NumberOfContainers   = 0;
                NumberReadyToHarvest = 0;
                NumberReadyToLoad    = 0;
                IsCellar             = false;
            }
            else
            {
                var objects = location.objects.Values;
                Containers = objects.Where(o => supportedContainerTypes.Any(c => o.Name == c)).Select(o => o);
                ReadyToHarvestContainers = Containers.Where(c => c.heldObject.Value != null && (c.readyForHarvest.Value == true || (c.heldObject.Value is Chest && (c.heldObject.Value as Chest).items.Count() > 0)));
                ReadyToLoadContainers    = Containers.Where(c => c.heldObject.Value == null && c.readyForHarvest.Value == false && c.name != "Mushroom Box" && c.name != "Auto-Grabber");

                NumberOfItems        = Containers.Count(c => c.heldObject.Value != null && c.readyForHarvest.Value == true) + Containers.Where(c => c.heldObject.Value is Chest).Sum(c => (c.heldObject.Value as Chest).items.Sum(i => i.Stack));
                NumberOfContainers   = Containers.Count();
                NumberReadyToHarvest = ReadyToHarvestContainers.Count();
                NumberReadyToLoad    = ReadyToHarvestContainers.Where(c => c.name != "Mushroom Box" && c.name != "Auto-Grabber").Count() + ReadyToLoadContainers.Count();

                IsCellar = location is Cellar;
            }
        }
コード例 #2
0
        public BuildingContentsInfo(Building building, List <string> supportedContainerTypes)
        {
            if (building == null || building.indoors.Value == null)
            {
                Containers           = null;
                NumberOfContainers   = 0;
                NumberReadyToHarvest = 0;
                NumberReadyToLoad    = 0;
            }
            else
            {
                var indoors = building.indoors.Value;
                var objects = indoors.objects.Values;
                Containers = objects.Where(o => supportedContainerTypes.Any(c => o.Name == c)).Select(o => o);
                ReadyToHarvestContainers = Containers.Where(c => c.heldObject.Value != null && c.readyForHarvest.Value == true);
                ReadyToLoadContainers    = Containers.Where(c => c.heldObject.Value == null && c.readyForHarvest.Value == false);

                NumberOfContainers   = Containers.Count();
                NumberReadyToHarvest = ReadyToHarvestContainers.Count();
                NumberReadyToLoad    = NumberReadyToHarvest + ReadyToLoadContainers.Count();
            }
        }