Changes

→‎New utility fields & methods: + WorldDate.GetDaysPlayed
Line 381: Line 381:  
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
IEnumerable<string> coopNames = Utility.FuzzySearchAll("coop", Game1.buildingData.Keys); // [ "Coop", "Big Coop", "Deluxe Coop" ]
 
IEnumerable<string> coopNames = Utility.FuzzySearchAll("coop", Game1.buildingData.Keys); // [ "Coop", "Big Coop", "Deluxe Coop" ]
 +
</syntaxhighlight>
 +
|-
 +
| <samp>WorldDate.GetDaysPlayed(…)</samp>
 +
| Get the total days for a given date from the start of the game, to allow for efficient date comparisons.
 +
 +
For example:
 +
<syntaxhighlight lang="c#">
 +
int minDaysPlayed = WorldDate.GetDaysPlayed(year, season, dayOfMonth);
 +
int actualDaysPlayed = Game1.Date.TotalDays;
 +
if (actualDaysPlayed >= minDaysPlayed)
 +
  ...;
 
</syntaxhighlight>
 
</syntaxhighlight>
 
|}
 
|}
manager
8,549

edits