Table of Contents

Class GameImpl

Namespace
TinyLife
Assembly
Tiny Life.dll

The main class for Tiny Life, which houses a set of important game-wide properties.

public class GameImpl : MlemGame, IDisposable
Inheritance
Game
MlemGame
GameImpl
Implements
Inherited Members
MlemGame.GraphicsDeviceManager
MlemGame.Update(GameTime)
MlemGame.Draw(GameTime)
MlemGame.InitializeDefaultUiStyle(SpriteBatch)
MlemGame.Input
MlemGame.SpriteBatch
MlemGame.InputHandler
MlemGame.UiSystem
MlemGame.OnLoadContent
MlemGame.PreUpdate
MlemGame.OnUpdate
MlemGame.PreDraw
MlemGame.OnDraw
Game.Dispose()
Game.Exit()
Game.ResetElapsedTime()
Game.SuppressDraw()
Game.RunOneFrame()
Game.Run()
Game.Run(GameRunBehavior)
Game.Tick()
Game.BeginDraw()
Game.EndDraw()
Game.BeginRun()
Game.EndRun()
Game.UnloadContent()
Game.Initialize()
Game.LaunchParameters
Game.Components
Game.InactiveSleepTime
Game.MaxElapsedTime
Game.IsActive
Game.IsMouseVisible
Game.TargetElapsedTime
Game.IsFixedTimeStep
Game.Services
Game.Content
Game.GraphicsDevice
Game.Window
Game.Activated
Game.Deactivated
Game.Disposed
Game.Exiting
Extension Methods

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).

public readonly HashSet<Achievement> Achievements

Field Value

HashSet<Achievement>

CurrentCursor

The CursorType that is currently used. This is reset to Default at the start of every update.

public CursorType CurrentCursor

Field Value

CursorType

Version

The game's version, gathered from the assembly

public static readonly NuGetVersion Version

Field Value

NuGetVersion

Properties

Camera

The game's in-world camera, created in LoadContent()

public Camera Camera { get; }

Property Value

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

public Household CurrentHousehold { get; }

Property Value

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

public Lot CurrentLot { get; }

Property Value

Lot

CurrentMap

The map that the game's Camera is currently on.

public Map CurrentMap { get; }

Property Value

Map

CurrentMaps

The maps that are currently loaded, along with their names.

public Dictionary<string, Map> CurrentMaps { get; }

Property Value

Dictionary<string, Map>

CurrentTool

The Tool that is currently selected. Should always be set to either PlayModeTool or any of BuildTools.

public Tool CurrentTool { get; set; }

Property Value

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.

public Vector2 CursorPosition { get; }

Property Value

Vector2

FollowingPerson

The Person that the camera is currently locked onto

public Person FollowingPerson { get; }

Property Value

Person

GraphicsMetrics

The game's graphics metrics, gathered at the end of every DoDraw(GameTime) call

public GraphicsMetrics GraphicsMetrics { get; }

Property Value

GraphicsMetrics

Instance

The game's singleton instance

public static GameImpl Instance { get; }

Property Value

GameImpl

Listener

The game's Microsoft.Xna.Framework.Audio.AudioListener that is automatically moved to the Camera's position

public AudioListener Listener { get; }

Property Value

AudioListener

Mode

The GameImpl.GameMode that is currently active

public GameImpl.GameMode Mode { get; }

Property Value

GameImpl.GameMode

Money

The money that the CurrentHousehold has, or MaxValue if there is no active household

public float Money { get; set; }

Property Value

float

SaveName

The name of the save file that is currently being played, or null if in the main menu

public string SaveName { get; }

Property Value

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, bool).

public GameSpeed Speed { get; set; }

Property Value

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.

public bool CanBeExtremelyFast()

Returns

bool

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.

public bool CanSwitchGameModes()

Returns

bool

Whether the game can currently switch game modes.

CompleteAchievement(AchievementType)

Completes the achievement in this map's Achievements collection with the given AchievementType.

public bool CompleteAchievement(AchievementType type)

Parameters

type AchievementType

The type of achievement to complete.

Returns

bool

true if the achievement could be completed successfully, false if it was already completed.

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

DoDraw(GameTime)

This method is called in MLEM.Startup.MlemGame.Draw(Microsoft.Xna.Framework.GameTime). It is the version that should be overridden by implementors to draw game content.

protected override void DoDraw(GameTime gameTime)

Parameters

gameTime GameTime

The game's time

DoUpdate(GameTime)

This method is called in MLEM.Startup.MlemGame.Update(Microsoft.Xna.Framework.GameTime). It is the version that should be overridden by implementors to update game content.

protected override void DoUpdate(GameTime gameTime)

Parameters

gameTime GameTime

The game's time

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.

public void FadeKeyboardLighting(Color newColor)

Parameters

newColor Color

The color to fade to; transparency is ignored

FollowPerson(Person, bool, Action)

Causes the camera to follow the given person, optionally switching to the map the person is on using SwitchMap(Map, Action, Action).

public bool FollowPerson(Person person, bool switchToMap = true, Action additionalAction = null)

Parameters

person Person

The person to follow.

switchToMap bool

Whether to switch to the map the person is on.

additionalAction Action

An optional additional action that should be invoked when the camera is moved, which is passed to Transition(Action, Action, TransitionType, TransitionType, float, float, float, Color?) when switching maps, or invoked immediately when not switching maps.

Returns

bool

Whether following the person was successful.

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.

public bool IsCursorOnUi()

Returns

bool

true if the cursor is currently on the ui.

IsLotVisible(Lot)

Returns whether the given lot is considered visible to the player. Note that passing the CurrentHousehold's Lot will always cause this method to return true.

public bool IsLotVisible(Lot lot)

Parameters

lot Lot

The lot to query

Returns

bool

Whether the lot is visible

LoadContent()

Override this to load graphical resources required by the game.

protected override void LoadContent()

MarkLotNonVisible(Lot)

Marks a lot non-visible if it's currently visible to the player.

public void MarkLotNonVisible(Lot lot)

Parameters

lot Lot

The lot to remove visibility for

MarkLotVisible(Lot)

Marks the given lot as visible for the player. The method VisitLot(Lot) should be used in favor of this method in most cases. By default, visibility lasts for 30 seconds of real time.

public void MarkLotVisible(Lot lot)

Parameters

lot Lot

The lot to mark as visible

RotateCamera(bool)

Rotates the camera by 90 degrees in a clockwise or counter-clockwise direction.

public void RotateCamera(bool ccw)

Parameters

ccw bool

Whether the rotation should be counter-clockwise.

SwitchGameMode(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.

public void SwitchGameMode(GameImpl.GameMode mode)

Parameters

mode GameImpl.GameMode

The game mode to switch to

SwitchMap(Map, Action, Action)

Switches the game's CurrentMap to the given map, additionally displaying a transition and resetting various UI states. OnCurrentGameMapChanged(Map, Map) is also invoked.

public void SwitchMap(Map map, Action inbetween = null, Action after = null)

Parameters

map Map

The map to change to.

inbetween Action

An optional inbetween action, which is passed to Transition(Action, Action, TransitionType, TransitionType, float, float, float, Color?).

after Action

An optional after action, which is passed to Transition(Action, Action, TransitionType, TransitionType, float, float, float, Color?).

TakeScreenshot(Point, RectangleF?, Matrix?, RenderTarget2D)

Takes a screenshot and stores it in the default location, using a file name that contains the current date and time

public void TakeScreenshot(Point size, RectangleF? visibleArea = null, Matrix? visibleMatrix = null, RenderTarget2D lightmap = null)

Parameters

size Point

The size, in pixels, of the resulting screenshots

visibleArea RectangleF?

The area that should be marked as visible, in world space. This determines culling values.

visibleMatrix Matrix?

A matrix that has a translation and scale that determines the visible area of the screenshot

lightmap RenderTarget2D

The light map to draw light onto, or null to use the default light map

ZoomCamera(int)

Zooms the camera by the given delta, either towards the center of the camera's viewport, or toward the CursorPosition if it is not on the UI.

public void ZoomCamera(int delta)

Parameters

delta int

The delta to zoom by.

Events

OnFinalizingGameContent

An event that is raised when this game's content is about to finish loading. Note that "finalize" in this context refers not to object destruction, but to the completion of the loading process.

public event Action OnFinalizingGameContent

Event Type

Action

OnFinishedLoading

An event that is raised when the game's loading screen fades out.

public event Action OnFinishedLoading

Event Type

Action