internal ObjectsTask(ModConfig config, ObjectsTaskId id)
        {
            _config = config;
            _id     = id;

            SettingsMenu.ReportConfigChanged += SettingsMenu_ReportConfigChanged;
            ModEntry.EventsHelper.World.ObjectListChanged += World_ObjectListChanged;
        }
Beispiel #2
0
        internal ObjectsTask(ModConfig config, ObjectsTaskId id)
        {
            _config = config;
            _id     = id;

            SettingsMenu.ReportConfigChanged += SettingsMenu_ReportConfigChanged;
            LocationEvents.ObjectsChanged    += LocationEvents_ObjectsChanged;
        }
        protected override void FirstScan()
        {
            if (_who == ObjectsTaskId.None)
            {
                _who = _id;
            }
            else if (_who != _id)
            {
                return;
            }

            foreach (var location in Game1.locations)
            {
                if (!Machines.ContainsKey(location))
                {
                    Machines[location] = new List <Vector2>();
                }
                if (location.waterTiles != null && !CrabPots.ContainsKey(location))
                {
                    CrabPots[location] = new List <Vector2>();
                }

                foreach (var @object in location.Objects.Pairs)
                {
                    if (_config.Machines.ContainsKey(@object.Value.name) || @object.Value is Cask)
                    {
                        Machines[location].Add(@object.Key);
                    }
                    else if (@object.Value is CrabPot)
                    {
                        CrabPots[location].Add(@object.Key);
                    }
                }

                if (!(location is BuildableGameLocation farm))
                {
                    continue;
                }

                foreach (var building in farm.buildings)
                {
                    var indoors = building.indoors.Value;
                    if (indoors == null)
                    {
                        continue;
                    }

                    if (!Machines.ContainsKey(indoors))
                    {
                        Machines[indoors] = new List <Vector2>();
                    }

                    foreach (var @object in indoors.Objects.Pairs)
                    {
                        if (_config.Machines.ContainsKey(@object.Value.name))
                        {
                            Machines[indoors].Add(@object.Key);
                        }
                    }
                }
            }
        }