GameImpl - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife

GameImpl Class

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

public class GameImpl : MLEM.Startup.MlemGame

Inheritance System.Object 🡒 Microsoft.Xna.Framework.Game 🡒 MLEM.Startup.MlemGame 🡒 GameImpl

Fields

GameImpl.CurrentTime Field

The current in-game total time since the start of the game.

public TimeSpan CurrentTime;

Field Value

System.TimeSpan

GameImpl.FollowingPerson Field

The Person that the camera is currently locked onto

public Person FollowingPerson;

Field Value

Person

GameImpl.Version Field

The game's version, gathered from the assembly

public static readonly string Version;

Field Value

System.String

Properties

GameImpl.Camera Property

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

public MLEM.Cameras.Camera Camera { get; set; }

Property Value

MLEM.Cameras.Camera

GameImpl.CurrentHousehold Property

The household that is currently being played, or csharp null if in the main menu, editing a lot or on the map select screen

public TinyLife.World.Household CurrentHousehold { get; set; }

Property Value

Household

GameImpl.CurrentLot Property

The lot that is currently being played on or edited, or csharp null if in the main menu or on the map select screen

public TinyLife.World.Lot CurrentLot { get; set; }

Property Value

Lot

GameImpl.CurrentTool Property

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

public TinyLife.Tools.Tool CurrentTool { get; set; }

Property Value

Tool

GameImpl.GraphicsMetrics Property

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

public Microsoft.Xna.Framework.Graphics.GraphicsMetrics GraphicsMetrics { get; set; }

Property Value

Microsoft.Xna.Framework.Graphics.GraphicsMetrics

GameImpl.Instance Property

The game's singleton instance

public static TinyLife.GameImpl Instance { get; set; }

Property Value

GameImpl

GameImpl.Listener Property

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

public Microsoft.Xna.Framework.Audio.AudioListener Listener { get; set; }

Property Value

Microsoft.Xna.Framework.Audio.AudioListener

GameImpl.Map Property

The map that the game is currently on, or csharp null if in the main menu

public TinyLife.World.Map Map { get; set; }

Property Value

Map

GameImpl.Mode Property

The GameMode that is currently active

public TinyLife.GameImpl.GameMode Mode { get; set; }

Property Value

GameMode

GameImpl.Money Property

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

public float Money { get; set; }

Property Value

System.Single

GameImpl.SaveName Property

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

public string SaveName { get; set; }

Property Value

System.String

GameImpl.Speed Property

The current GameSpeed.
Note that, if the current speed is VeryFast and the game CanBeExtremelyFast(), ExtremelyFast is returned.

public TinyLife.GameSpeed Speed { get; set; }

Property Value

GameSpeed

GameImpl.Weekday Property

The current in-game weekday, based on CurrentTime

public System.DayOfWeek Weekday { get; }

Property Value

System.DayOfWeek

Methods

GameImpl.CanBeExtremelyFast() Method

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

System.Boolean
Whether the game can become extremely fast

GameImpl.CanSaveOrSwitchModes() Method

Returns whether the game can currently save or if SwitchGameMode(GameMode) is allowed to be used right now.
The return value is influenced by CanSaveOrSwitchModes() and AreRequirementsMet().

public bool CanSaveOrSwitchModes();

Returns

System.Boolean
Whether we can save or switch modes right now

GameImpl.DoDraw(GameTime) Method

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(Microsoft.Xna.Framework.GameTime gameTime);

Parameters

gameTime Microsoft.Xna.Framework.GameTime
The game's time

GameImpl.DoUpdate(GameTime) Method

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(Microsoft.Xna.Framework.GameTime gameTime);

Parameters

gameTime Microsoft.Xna.Framework.GameTime
The game's time

GameImpl.FadeKeyboardLighting(Color) Method

Fades the keyboard lighting at a constant speed to make it result in the passed color.
This method only has an effect if KeyboardLighting is enabled, and if the user has a lighting-capable keyboard.

public void FadeKeyboardLighting(Microsoft.Xna.Framework.Color newColor);

Parameters

newColor Microsoft.Xna.Framework.Color
The color to fade to; transparency is ignored

GameImpl.IsMouseOnUi() Method

Returns true if the mouse is currently on top of any ui element in the MLEM.Ui.UiSystem

public bool IsMouseOnUi();

Returns

System.Boolean
true if the mouse is currently on top of any element

GameImpl.LoadContent() Method

Override this to load graphical resources required by the game.

protected override void LoadContent();

GameImpl.OnExiting(object, EventArgs) Method

Called when the game is exiting. Raises the Microsoft.Xna.Framework.Game.Exiting event.

protected override void OnExiting(object sender, System.EventArgs args);

Parameters

sender System.Object
This Microsoft.Xna.Framework.Game.

args System.EventArgs
The arguments to the Microsoft.Xna.Framework.Game.Exiting event.

GameImpl.SwitchGameMode(GameMode) Method

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(TinyLife.GameImpl.GameMode mode);

Parameters

mode GameMode
The game mode to switch to