コード例 #1
0
 public void DailyReset()
 {
     if (Game1.hasLoadedGame)
     {
         MachineHelper.DailyReset();
     }
     _connectedChestsCache = null;
 }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
        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());
                    }
                }
            }
        }