Changes

Jump to navigation Jump to search
→‎Main classes: + GameLocation, BuildableGameLocation, and Farm
Line 50: Line 50:  
|-
 
|-
 
| <tt>Game1.currentLocation</tt>
 
| <tt>Game1.currentLocation</tt>
| <tt>GameLocation</tt>
+
| <tt>[[#GameLocation|GameLocation]]</tt>
 
| The game location containing the current player. '''For a non-main player, may be <tt>null</tt> when transitioning between locations.'''
 
| The game location containing the current player. '''For a non-main player, may be <tt>null</tt> when transitioning between locations.'''
 
|-
 
|-
 
| <tt>Game1.locations</tt>
 
| <tt>Game1.locations</tt>
| <tt>IList&lt;GameLocation&gt;</tt>
+
| <tt>IList&lt;[[#GameLocation|GameLocation]]&gt;</tt>
 
| All locations in the game. '''For a non-main player, use [[Modding:Modder Guide/APIs/Multiplayer#GetActiveLocations|SMAPI's <tt>GetActiveLocations</tt> method]] instead.'''
 
| All locations in the game. '''For a non-main player, use [[Modding:Modder Guide/APIs/Multiplayer#GetActiveLocations|SMAPI's <tt>GetActiveLocations</tt> method]] instead.'''
 
|-
 
|-
Line 63: Line 63:  
| <tt>Game1.itemsToShip</tt>
 
| <tt>Game1.itemsToShip</tt>
 
| <tt>IList&lt;Item&gt;</tt>
 
| <tt>IList&lt;Item&gt;</tt>
| The items in the shipping bin.
+
| Do not use (this is part of the save logic). See <tt>Game1.getFarm().shippingBin</tt> instead.
 
|-
 
|-
 
| <tt>Game1.activeClickableMenu</tt>
 
| <tt>Game1.activeClickableMenu</tt>
Line 69: Line 69:  
| The modal menu being displayed. Creating an <tt>IClickableMenu</tt> subclass and assigning an instance to this field will display it.
 
| The modal menu being displayed. Creating an <tt>IClickableMenu</tt> subclass and assigning an instance to this field will display it.
 
|}
 
|}
 +
 +
===GameLocation et al===
 +
<ul>
 +
<li><tt>GameLocation</tt> represents an in-game location players can visit. Each location has a map (the tile layout), objects, trees, characters, etc. Here are some of the most useful fields for any location:
 +
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! type
 +
! purpose
 +
|-
 +
| <tt>Name</tt>
 +
| <tt>string</tt>
 +
| The unique name for this location. (This isn't unique for constructed building interiors like cabins; see <tt>uniqueName</tt> instead.)
 +
|-
 +
| <tt>IsFarm</tt>
 +
| <tt>bool</tt>
 +
| Whether this is a farm, where crops can be planted.
 +
|-
 +
| <tt>IsGreenhouse</tt>
 +
| <tt>bool</tt>
 +
| Whether this is a greenhouse, where crops can be planted and grown all year.
 +
|-
 +
| <tt>IsOutdoors</tt>
 +
| <tt>bool</tt>
 +
| Whether the location is outdoors (as opposed to a greenhouse, building, etc).
 +
|-
 +
| <tt>characters</tt>
 +
| [[#Net fields|<tt>NetCollection</tt>]] of <tt>NPC</tt>
 +
| The villagers, pets, horses, and monsters in the location.
 +
|-
 +
| <tt>critters</tt> (private)
 +
| <tt>List</tt> of <tt>Critter</tt>
 +
| The temporary birds, squirrels, or other critters in the location.
 +
|-
 +
| <tt>debris</tt>
 +
| [[#Net fields|<tt>NetCollection</tt>]] of <tt>Debris</tt>
 +
| The floating items in the location.
 +
|-
 +
| <tt>farmers</tt>
 +
| <tt>FarmerCollection</tt>
 +
| The players in the location.
 +
|-
 +
| <tt>Objects</tt>
 +
| <tt>OverlaidDictionary</tt>
 +
| The placed fences, crafting machines, and other objects in the current location. (<tt>OverlaidDictionary</tt> is basically a [[#Net fields|<tt>NetVector2Dictionary</tt>]] with logic added to show certain quest items over pre-existing objects.)
 +
|-
 +
| <tt>terrainFeatures</tt>
 +
| [[#Net fields|<tt>NetVector2Dictionary</tt>]] of <tt>TerrainFeature</tt>
 +
| The trees, fruit trees, tall grass, tilled dirt (including crops), and flooring in the location. For each pair, the key is their tile position and the value is the terrain feature instance.
 +
|-
 +
| <tt>waterTiles</tt>
 +
| <tt>bool[,]</tt>
 +
| A multi-dimensional array which indicates whether each tile on the map is a lake/river tile. For example, <code>if (location.waterTiles[10, 20])</code> checks the tile at [[#Tiles|position]] (10, 20).
 +
|}</li>
 +
 +
<li><tt>BuildableGameLocation</tt> is a subclass of <tt>GameLocation</tt> for locations where players can construct buildings. In the vanilla game, only the farm is a buildable location. Here are the most useful fields:
 +
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! type
 +
! purpose
 +
|-
 +
| <tt>buildings</tt>
 +
| [[#Net fields|<tt>NetCollection</tt>]] of <tt>Building</tt>
 +
| The buildings in the location.
 +
|}</li>
 +
 +
<li><tt>Farm</tt> is a subclass of both <tt>GameLocation</tt> and <tt>BuildableGameLocation</tt> for locations where the player can have animals and grow crops. In the vanilla, there's only one farm location (accessed using <code>Game1.getFarm()</code>). Here are its most useful properties:
 +
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! type
 +
! purpose
 +
|-
 +
| <tt>animals</tt>
 +
| [[#Net fields|<tt>NetLongDictionary</tt>]] of <tt>FarmAnimal</tt>
 +
| The farm animals currently in the location.
 +
|-
 +
| <tt>resourceClumps</tt>
 +
| [[#Net fields|<tt>NetCollection</tt>]] of <tt>ResourceClump</tt>
 +
| The giant crops, large stumps, boulders, and meteorites in the location.
 +
|-
 +
| <tt>piecesOfHay</tt>
 +
| [[#Net fields|<tt>NetInt</tt>]]
 +
| The amount of hay stored in silos.
 +
|-
 +
| <tt>shippingBin</tt>
 +
| [[#Net fields|<tt>NetCollection</tt>]] of <tt>Item</tt>
 +
| The items in the shipping bin.
 +
|}</li>
 +
 +
<li>There are a number of subclasses for specific location (like <tt>AdventureGuild</tt>) which have fields useful for specific cases.</li>
 +
</ul>
    
{{modding guide footer
 
{{modding guide footer
translators
8,447

edits

Navigation menu