Пример #1
0
        //private static bool savingInProgress = false;

        private void OnSave(object sender, SavingEventArgs e)
        {
            VoidshroomTree.RemovalAll();
            //CaveCarrot.RemoveAll();
            ModState.visitedMineshafts.Clear();
            ModState.SaveMod();
        }
Пример #2
0
 public VoidshroomtreeSaveData(VoidshroomTree tree)
 {
     this.growthStage = tree.growthStage.Value;
     this.flipped     = tree.flipped.Value;
     this.health      = tree.health.Value;
     this.stump       = tree.stump.Value;
     this.tapped      = tree.tapped.Value;
     this.hasSeed     = tree.hasSeed.Value;
 }
Пример #3
0
 private void OnSave(object sender, SavingEventArgs e)
 {
     if (!savingInProgress)
     {
         savingInProgress = true;
         VoidshroomTree.RemovalAll();
         ModState.visitedMineshafts.Clear();
         ModState.SaveMod();
         savingInProgress = false;
     }
 }
Пример #4
0
        public static void ProcessLocation(GameLocation location, ProcessingMethod method)
        {
            if (location == null)
            {
                return;
            }

            monitor.Log("VoidshroomTree.ProcessLocation(" + location.Name + ", " + method + ")", StardewModdingAPI.LogLevel.Trace);

            if (processedLocations.Contains(location))
            {
                monitor.Log("VoidshroomTree.ProcessLocation(" + location.Name + ", " + method + "): Already processed this location (infinite recursion?), aborting!", StardewModdingAPI.LogLevel.Warn);
                return;
            }

            processedLocations.Add(location);

            bool itemsToRemove = false;

            if (VoidshroomSpore.IsValidLocation(location))
            {
                String locationName = location.Name.ToString();
                if (method.Equals(ProcessingMethod.Remove))
                {
                    foreach (Vector2 featureSpot in location.terrainFeatures.Keys)
                    {
                        if (location.terrainFeatures[featureSpot] is VoidshroomTree)
                        {
                            StringWriter writer = new StringWriter();

                            if (!ModState.voidshroomTreeLocations.ContainsKey(locationName))
                            {
                                ModState.voidshroomTreeLocations.Add(locationName, new Dictionary <Vector2, VoidshroomtreeSaveData>());
                            }

                            VoidshroomTree tree = (VoidshroomTree)location.terrainFeatures[featureSpot];

                            ModState.voidshroomTreeLocations[locationName].Add(featureSpot, tree.GetSaveData());
                            itemsToRemove = true;
                        }
                    }

                    //data is stored, but if we're removing we need to actually clear stuff out of the list now.
                    if (itemsToRemove)
                    {
                        foreach (Vector2 locationData in ModState.voidshroomTreeLocations[location.Name.ToString()].Keys)
                        {
                            location.terrainFeatures.Remove(locationData);
                        }
                    }
                }
                else if (method.Equals(ProcessingMethod.Restore))
                {
                    if (ModState.voidshroomTreeLocations.ContainsKey(location.Name.ToString()))
                    {
                        foreach (KeyValuePair <Vector2, VoidshroomtreeSaveData> locationData in ModState.voidshroomTreeLocations[location.Name.ToString()])
                        {
                            location.terrainFeatures.Add(locationData.Key, new VoidshroomTree(locationData.Value));
                        }
                    }
                }
            }
        }
Пример #5
0
 private void AfterSaveLoad(object sender, SaveLoadedEventArgs e)
 {
     ModState.LoadMod();
     VoidshroomTree.ReplaceAll();
 }
Пример #6
0
 private void AfterSave(object sender, SavedEventArgs e)
 {
     VoidshroomTree.ReplaceAll();
 }