public void ProcessMachines() { if (_connectedChestsCache == null) { _connectedChestsCache = new Dictionary <string, Dictionary <Vector2, Chest> >(); Parallel.ForEach(GetLocations(), BuildCacheForLocation); } if (MuteWhileCollectingFromMachines > 0) { SoundHelper.MuteTemporary(MuteWhileCollectingFromMachines); } foreach (var gameLocation in GetLocations()) { MachineHelper.Who.currentLocation = gameLocation; lock (_connectedChestsCache) { if (!_connectedChestsCache.ContainsKey(LocationHelper.GetName(gameLocation))) { // cache got invalidated BuildCacheForLocation(gameLocation); } } foreach (var valuePair in _connectedChestsCache[LocationHelper.GetName(gameLocation)]) { Vector2 location = valuePair.Key; Chest connectedChest = valuePair.Value; if (connectedChest == null) { // no chest connected continue; } if (!gameLocation.objects.ContainsKey(location)) { // skip connection without objects like floortiles etc continue; } if (!_machineNamesToProcess.Contains(gameLocation.objects[location].Name)) { continue; } MachineHelper.ProcessMachine(gameLocation.objects[location], connectedChest, _materialHelper); } } }
public void ProcessMachines() { if (_connectedChestsCache == null) { _connectedChestsCache = new Dictionary <string, Dictionary <Vector2, Chest> >(); Parallel.ForEach(GetLocations(), BuildCacheForLocation); } if (MuteWhileCollectingFromMachines > 0) { SoundHelper.MuteTemporary(MuteWhileCollectingFromMachines); } foreach (var gameLocation in GetLocations()) { MachineHelper.Who.currentLocation = gameLocation; MachineHelper.Monitor = _monitor; lock (_connectedChestsCache) { if (!_connectedChestsCache.ContainsKey(LocationHelper.GetName(gameLocation))) { // cache got invalidated BuildCacheForLocation(gameLocation); } } foreach (var valuePair in _connectedChestsCache[LocationHelper.GetName(gameLocation)]) { var location = valuePair.Key; var connectedChest = valuePair.Value; if (connectedChest != null && gameLocation.objects.ContainsKey(location) && _machineConfigs.Any(x => x.Name == gameLocation.objects[location].Name)) { MachineHelper.ProcessMachine(gameLocation.objects[location], connectedChest, _materialHelper, (from x in _machineConfigs where x.Name == gameLocation.objects[location].Name select x).FirstOrDefault()); } } } }
public void ProcessAnimalBuildings() { if (_dailiesDone) { return; } if (MuteWhenCollecting) { SoundHelper.MuteTemporary(1500); } Log.Info("Petting animals and processing their buildings to collect items"); var farms = Game1.locations.OfType <Farm>(); foreach (var farm in farms) { if (PetAnimals) { var allAnimals = farm.animals.Values.Concat( farm.buildings.Where(b => b.indoors is AnimalHouse) .SelectMany(i => ((AnimalHouse)i.indoors).animals.Values)); foreach (var animal in allAnimals) { PetAnimal(animal); } Log.Info("All animals have been petted."); } foreach (var building in farm.buildings) { var chest = ItemFinder.FindChestInLocation(building.indoors); if (chest == null) { continue; } if (building is Coop) { // collect eggs CollectItemsFromBuilding(building, chest, _coopCollectibles); } if (building is Barn) { int outsideAnimalCount = 0; foreach ( var outsideAnimal in farm.animals.Values.Where(a => a.home is Barn && a.home == building)) { CollectBarnAnimalProduce(outsideAnimal, chest); ++outsideAnimalCount; } if (outsideAnimalCount > 0) { Log.Debug( $"Found {outsideAnimalCount} animals wandering outside. collected their milk or wool and put it in the chest in their {building.buildingType}"); } int insideAnimalCount = 0; foreach (var animal in ((AnimalHouse)building.indoors).animals.Values) { CollectBarnAnimalProduce(animal, chest); ++insideAnimalCount; } if (insideAnimalCount > 0) { Log.Debug( $"Found {insideAnimalCount} animals in the {building.buildingType}. Collected their milk or wool and put it in the chest in their home."); } } if (building.indoors is SlimeHutch) { // collect goop foreach (var pair in building.indoors.objects.Where(o => o.Value.Name == "Slime Ball").ToList()) { var item = pair.Value; Random random = new Random( (int) (Game1.stats.daysPlayed + (uint)((int)Game1.uniqueIDForThisGame) + (uint)((int)item.tileLocation.X * 77) + (uint)((int)item.tileLocation.Y * 777) + 2u)); var number = random.Next(10, 21); var slimeStack = new Object(SlimeParentSheetIndex, number) { scale = Vector2.Zero, quality = 0, isSpawnedObject = false, isRecipe = false, questItem = false, name = "Slime", specialVariable = 0, price = 5 }; if (chest.addItem(slimeStack) == null) { building.indoors.objects.Remove(pair.Key); Log.Info($"Collected {number} Slimes from your Slime Hutch"); } } } } } _dailiesDone = true; }