Exemplo n.º 1
0
        /// <summary>The method invoked when a location is added or removed.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
        {
            if (!this.EnableAutomation)
            {
                return;
            }

            this.Monitor.VerboseLog("Location list changed, reloading machines in affected locations.");

            try
            {
                // remove locations
                foreach (GameLocation location in e.Removed)
                {
                    this.ActiveMachineGroups.Remove(location);
                    this.DisabledMachineGroups.Remove(location);
                }

                // add locations
                this.ReloadQueue.AddMany(e.Added);
            }
            catch (Exception ex)
            {
                this.HandleError(ex, "updating locations");
            }
        }
Exemplo n.º 2
0
 /// <summary>The method invoked after locations are added or removed from the game.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     if (Context.IsMultiplayer)
     {
         foreach (GameLocation location in e.Added)
         {
             this.MigrateLegacyData(location);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>The method called after a location is added or removed.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
        {
            if (!Context.IsMainPlayer)
            {
                return;
            }

            // set greenhouse mode if applicable
            if (this.ShouldApply())
            {
                this.SetCropMode(e.Added, true, this.EnabledLocations);
            }
        }
Exemplo n.º 4
0
 /*********
 ** Public methods
 *********/
 /// <summary>The event called after the location list changes.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     // rescue lost horses
     if (Context.IsMainPlayer)
     {
         foreach (GameLocation location in e.Removed)
         {
             foreach (Horse horse in this.GetHorsesIn(location).ToArray())
             {
                 this.WarpHome(horse);
             }
         }
     }
 }
Exemplo n.º 5
0
        private void updateCritterLocationsList(object sender, LocationListChangedEventArgs args)
        {
            if (args.Added.Count() > 0)
            {
                foreach (GameLocation location in args.Added.ToList())
                {
                    updateCritterLocations(location);
                }
            }
            if (args.Removed.Count() > 0)
            {
                AllCritterLocations.RemoveAll(l => args.Removed.Contains(l.Location));
            }

            //Helper.Events.World.LocationListChanged -= updateCritterLocationsList;
        }
Exemplo n.º 6
0
        private void OnLocationChanged(object sender, LocationListChangedEventArgs e)
        {
            // ignore if player hasn't loaded a save yet
            if (!Context.IsWorldReady)
            {
                return;
            }

            //Checks each game location as it's added to the list
            foreach (GameLocation location in e.Added)
            {
                //Then checks each monter in the list and adds them to a read-only list; prevents crashes when removing characters
                foreach (Monster monster in location.characters.OfType <Monster>().ToArray())
                {
                    //executes the RemoveIfApplicable to the specified location and monster
                    this.RemoveIfApplicable(location, monster);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>The event called after the location list changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            // rescue lost tractors
            if (Context.IsMainPlayer)
            {
                foreach (GameLocation location in e.Removed)
                {
                    foreach (Horse tractor in this.GetTractorsIn(location).ToArray())
                    {
                        this.DismissTractor(tractor);
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>The event called after the location list changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            // rescue lost tractors
            if (Context.IsMainPlayer)
            {
                foreach (GameLocation location in e.Removed)
                {
                    foreach (Horse tractor in this.GetTractorsIn(location).ToArray())
                    {
                        TractorManager.SetLocation(tractor, Game1.getFarm(), tractor.DefaultPosition);
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>The method invoked when a location is added or removed.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void World_LocationListChanged(object sender, LocationListChangedEventArgs e)
        {
            if (!this.EnableAutomation)
            {
                return;
            }

            this.VerboseLog("Location list changed, reloading all machines.");

            try
            {
                this.MachineGroups.Clear();
                foreach (GameLocation location in CommonHelper.GetLocations())
                {
                    this.ReloadQueue.Add(location);
                }
            }
            catch (Exception ex)
            {
                this.HandleError(ex, "updating locations");
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Location list changed event handler.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
        {
            foreach (GameLocation gameLocation in e.Added)
            {
                Monitor.VerboseLog($"Loading {gameLocation.Name}");

                if (!locationProcessors.TryGetValue(gameLocation, out IList <Processor> processors))
                {
                    locationProcessors[gameLocation] = processors = new List <Processor>();
                }

                foreach (SObject @object in gameLocation.Objects.Values)
                {
                    if (ShouldReplaceWithProcessor(@object, out Processor processor))
                    {
                        processors.Add(processor);
                    }
                }

                PlaceObjects(gameLocation, processors);
            }
        }
Exemplo n.º 11
0
        private void OnLoadLocation(object sender, LocationListChangedEventArgs e)
        {
            foreach (GameLocation gameLocation in e.Added)
            {
                if (!locationProcessors.ContainsKey(gameLocation))
                {
                    locationProcessors.Add(gameLocation, new List <Processor>());
                }

                List <Processor> processors = new List <Processor>();
                foreach (SObject @object in gameLocation.Objects.Values)
                {
                    if (@object.bigCraftable.Value && Processor.WhichProcessor(@object.ParentSheetIndex) != null && !(@object is Processor))
                    {
                        Processor processor = Processor.FromObject(@object);
                        processors.Add(processor);
                    }
                }

                PlaceObjects(gameLocation, processors);
            }
        }
Exemplo n.º 12
0
        /// <inheritdoc cref="IWorldEvents.LocationListChanged"/>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnLocationListChanged(object?sender, LocationListChangedEventArgs e)
        {
            if (!this.EnableAutomation)
            {
                return;
            }

            this.Monitor.VerboseLog("Location list changed, reloading machines in affected locations.");

            try
            {
                if (e.Removed.Any())
                {
                    this.MachineManager.QueueRemove(e.Removed);
                }

                this.MachineManager.QueueReload(e.Added);
            }
            catch (Exception ex)
            {
                this.HandleError(ex, "updating locations");
            }
        }
Exemplo n.º 13
0
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     Routing.Reset();
 }
Exemplo n.º 14
0
 /// <summary>The method called after a location is added or removed.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     // handle locations added after day start
     this.ApplyChanges(e.Added);
 }
Exemplo n.º 15
0
 private void WorldOnLocationListChanged(object?sender, LocationListChangedEventArgs e)
 {
     // TODO: search for all networks
 }
Exemplo n.º 16
0
 /// <inheritdoc cref="IWorldEvents.LocationListChanged"/>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     this.LocationUtil.ScanLocationContexts();
 }
Exemplo n.º 17
0
 private void World_LocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     GetLocationContexts();
 }
Exemplo n.º 18
0
 /// <summary>Raised after a game location is added or removed.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     this.Locations = CJB.GetAllLocations().ToArray();
 }
Exemplo n.º 19
0
 /// <summary>Raised after a game location is added or removed.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
     this.ResetLocationCache();
 }
 /// <summary>Raised after a game location is added or removed.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 protected virtual void OnLocationListChanged(object sender, LocationListChangedEventArgs e)
 {
 }