Table of Contents

Class Achievement

Namespace
TinyLife.Goals
Assembly
Tiny Life.dll

A class that contains a AchievementType and represents an achievement that can be gained by the player, either through a GoalSet or through CompleteAchievement(AchievementType). The game's default achievements are also available on Steam and other platforms, and get completed automatically when their in-game counterparts are completed.

[DataContract]
public class Achievement
Inheritance
Achievement
Inherited Members
Extension Methods

Constructors

Achievement(AchievementType, GoalSet)

Creates a new achievement with the given settings. This constructor is called by Construct().

public Achievement(AchievementType type, GoalSet goals = null)

Parameters

type AchievementType

This achievement instance's underlying AchievementType.

goals GoalSet

The GoalSet that this achievement is trying to complete.

Fields

Type

This achievement instance's underlying AchievementType.

[DataMember]
public readonly AchievementType Type

Field Value

AchievementType

Properties

Completed

Stores whether this achievement has already been completed in the current save file. By default, when this is set to true, Goals is also set to null.

[DataMember(EmitDefaultValue = false)]
public bool Completed { get; protected set; }

Property Value

bool

Goals

The GoalSet that this achievement is trying to complete, or null if the underlying Type does not contain a set of Goals or this achievement is Completed.

[DataMember(EmitDefaultValue = false)]
public GoalSet Goals { get; protected set; }

Property Value

GoalSet

Methods

Complete()

Completes this achievement. If Completed is already true, this method should do nothing. Note that this method completes an achievement even if its Goals are not met yet.

public virtual void Complete()

CreateElement()

Creates the MLEM.Ui.Elements.Element that is used to display this achievement. Custom implementations can display custom progress or other custom information.

public virtual Element CreateElement()

Returns

Element

The element used to display this achievement.

Update(GameTime, TimeSpan, float)

Updates this achievement, querying its Goals and completing it if necessary. This method is called every update frame.

public virtual void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game's time.

passedInGame TimeSpan

The amount of time that has passed since the last update, in in-game time.

speedMultiplier float

The speed multiplier that time is currently passing with.

Validate()

Validates this achievement when loading from disk, validating its Goals and returning whether the validation was successful.

public virtual bool Validate()

Returns

bool

Whether this achievement is valid.