Class GameImpl
The main class for Tiny Life, which houses a set of important game-wide properties.
Inheritance
Implements
Inherited Members
Namespace: TinyLife
Assembly: Tiny Life.dll
Syntax
public class GameImpl : MlemGame, IDisposable
Fields
Achievements
A set of Achievement instances being tracked on this map. Achievements are automatically added to this collection if they are registered as AchievementType instances. To complete an achievement, use CompleteAchievement(AchievementType).
Declaration
public readonly HashSet<Achievement> Achievements
Field Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<Achievement> |
CurrentCursor
The CursorType that is currently used. This is reset to Default at the start of every update.
Declaration
public CursorType CurrentCursor
Field Value
Type | Description |
---|---|
CursorType |
Version
The game's version, gathered from the assembly
Declaration
public static readonly string Version
Field Value
Type | Description |
---|---|
System.String |
Properties
Camera
The game's in-world camera, created in LoadContent()
Declaration
public Camera Camera { get; }
Property Value
Type | Description |
---|---|
MLEM.Cameras.Camera |
CurrentHousehold
The household that is currently being played, or
null
if in the main menu, editing a lot or on the map select screen
Declaration
public Household CurrentHousehold { get; }
Property Value
Type | Description |
---|---|
Household |
CurrentLot
The lot that is currently being played on or edited, or
null
if in the main menu or on the map select screen
Declaration
public Lot CurrentLot { get; }
Property Value
Type | Description |
---|---|
Lot |
CurrentTool
The Tool that is currently selected. Should always be set to either PlayModeTool or any of BuildTools.
Declaration
public Tool CurrentTool { get; set; }
Property Value
Type | Description |
---|---|
Tool |
CursorPosition
The position that the game's cursor is currently at. If gamepad controls are being used, an internal cursor position is returned. Otherwise, MLEM.Input.InputHandler.MousePosition is returned.
Declaration
public Vector2 CursorPosition { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Vector2 |
FollowingPerson
The Person that the camera is currently locked onto
Declaration
public Person FollowingPerson { get; set; }
Property Value
Type | Description |
---|---|
Person |
GraphicsMetrics
The game's graphics metrics, gathered at the end of every DoDraw(GameTime) call
Declaration
public GraphicsMetrics GraphicsMetrics { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Graphics.GraphicsMetrics |
Instance
The game's singleton instance
Declaration
public static GameImpl Instance { get; }
Property Value
Type | Description |
---|---|
GameImpl |
Listener
The game's Microsoft.Xna.Framework.Audio.AudioListener that is automatically moved to the Camera's position
Declaration
public AudioListener Listener { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Audio.AudioListener |
Map
The map that the game is currently on, or
null
if in the main menu
Declaration
public Map Map { get; }
Property Value
Type | Description |
---|---|
Map |
Mode
The GameImpl.GameMode that is currently active
Declaration
public GameImpl.GameMode Mode { get; }
Property Value
Type | Description |
---|---|
GameImpl.GameMode |
Money
The money that the CurrentHousehold has, or System.Single.MaxValue if there is no active household
Declaration
public float Money { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
SaveName
The name of the save file that is currently being played, or
null
if in the main menu
Declaration
public string SaveName { get; }
Property Value
Type | Description |
---|---|
System.String |
Speed
The current GameSpeed. Note that, if the current speed is VeryFast and the game CanBeExtremelyFast(), ExtremelyFast is returned. You can cause any ui MLEM.Ui.RootElement instances to pause the game by using SetPauseGame(RootElement, Boolean).
Declaration
public GameSpeed Speed { get; set; }
Property Value
Type | Description |
---|---|
GameSpeed |
Methods
CanBeExtremelyFast()
Returns whether the game allows changing the speed to ExtremelyFast at the current time. If this returns true, and Speed is set to VeryFast, the ExtremelyFast speed is automatically engaged.
Declaration
public bool CanBeExtremelyFast()
Returns
Type | Description |
---|---|
System.Boolean | Whether the game can become extremely fast |
CanSwitchGameModes()
Returns whether the game mode of the game can currently be switched. This method checks the CharacterCreator if it is active, as well as the CurrentTool and the CurrentLot's requirements.
Declaration
public bool CanSwitchGameModes()
Returns
Type | Description |
---|---|
System.Boolean | Whether the game can currently switch game modes. |
CompleteAchievement(AchievementType)
Completes the achievement in this map's Achievements collection with the given AchievementType.
Declaration
public bool CompleteAchievement(AchievementType type)
Parameters
Type | Name | Description |
---|---|---|
AchievementType | type | The type of achievement to complete. |
Returns
Type | Description |
---|---|
System.Boolean | true if the achievement could be completed successfully, false if it was already completed. |
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
DoDraw(GameTime)
Declaration
protected override void DoDraw(GameTime gameTime)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | gameTime |
Overrides
DoUpdate(GameTime)
Declaration
protected override void DoUpdate(GameTime gameTime)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | gameTime |
Overrides
FadeKeyboardLighting(Color)
Fades the keyboard lighting at a constant speed to make it result in the passed color. This method only has an effect if the game is running on desktop, and the user has a lighting-capable keyboard.
Declaration
public void FadeKeyboardLighting(Color newColor)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Color | newColor | The color to fade to; transparency is ignored |
IsCursorOnUi()
Returns true if the mouse is currently on top of any ui element in the MLEM.Ui.UiSystem or the system's auto-navigation cursor is currently being used.
Declaration
public bool IsCursorOnUi()
Returns
Type | Description |
---|---|
System.Boolean | true if the cursor is currently on the ui. |
LoadContent()
Declaration
protected override void LoadContent()
Overrides
RotateCamera(Boolean)
Rotates the camera by 90 degrees in a clockwise or counter-clockwise direction.
Declaration
public void RotateCamera(bool ccw)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | ccw | Whether the rotation should be counter-clockwise. |
SwitchGameMode(GameImpl.GameMode)
Switches the game mode to the given mode, and sets up all of the required data. Note that some game modes require certain data to be set prior to calling this method.
Declaration
public void SwitchGameMode(GameImpl.GameMode mode)
Parameters
Type | Name | Description |
---|---|---|
GameImpl.GameMode | mode | The game mode to switch to |
TakeScreenshot(Point, Nullable<RectangleF>, Nullable<Matrix>, RenderTarget2D)
Takes a screenshot and stores it in the default location, using a file name that contains the current date and time
Declaration
public void TakeScreenshot(Point size, RectangleF? visibleArea = null, Matrix? visibleMatrix = null, RenderTarget2D lightmap = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | size | The size, in pixels, of the resulting screenshots |
System.Nullable<MLEM.Misc.RectangleF> | visibleArea | The area that should be marked as visible, in world space. This determines culling values. |
System.Nullable<Microsoft.Xna.Framework.Matrix> | visibleMatrix | A matrix that has a translation and scale that determines the visible area of the screenshot |
Microsoft.Xna.Framework.Graphics.RenderTarget2D | lightmap | The light map to draw light onto, or null to use the default light map |
Events
OnFinishedLoading
An event that is raised when the game's loading screen fades out.
Declaration
public event Action OnFinishedLoading
Event Type
Type | Description |
---|---|
System.Action |
OnLoadContentLater
An event that is raised in the game's loading screen while loading additional mod content.
Declaration
public event Action OnLoadContentLater
Event Type
Type | Description |
---|---|
System.Action |