Skip to content

Commit

Permalink
Fix: Infinate Collecting Truffles bug when setting as True. (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
WuZhuoran authored Apr 9, 2024
1 parent 50cd5cb commit fe2ecc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion AnimalSitter/AnimalSitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class AnimalSitter : Mod
// A string defining the locations of specific chests.
private string ChestDefs = "";

private bool isFirstTimeTruffle = true;

private ModConfig Config;

private DialogueManager DialogueManager;
Expand All @@ -83,6 +85,12 @@ public override void Entry(IModHelper helper)
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
helper.Events.GameLoop.DayStarted += this.OnDayStarted;
}

private void OnDayStarted(object sender, DayStartedEventArgs e)
{
this.isFirstTimeTruffle = true;
}

/// <summary>Raised after the player loads a save slot.</summary>
Expand Down Expand Up @@ -311,12 +319,13 @@ private void IterateOverAnimals()

if (animal.type.Value == "Pig")
{
if (this.TakeTrufflesFromPigs)
if (this.TakeTrufflesFromPigs && this.isFirstTimeTruffle)
{
Object toAdd = new Object(animal.currentProduce.Value, 1, false, -1, animal.produceQuality.Value);
this.AddItemToInventory(toAdd, farmer);

stats.TrufflesHarvested++;
this.isFirstTimeTruffle = false;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion AnimalSitter/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Animal Sitter LTS",
"Author": "oliver",
"Version": "2.2.0",
"Version": "2.2.1",
"Description": "Long Term Support Mod Version for Animal Sitter Mod. Let someone else pet all those pesky animals!",
"UniqueID": "oliver.AnimalSitterLTS",
"EntryDll": "AnimalSitter.dll",
Expand Down

0 comments on commit fe2ecc1

Please sign in to comment.