Table of Contents

Class Clothes

Namespace
TinyLife.Objects
Assembly
Tiny Life.dll

A set of information and a registry for clothing items (and hair) that a PersonLike can wear. Custom clothes can be registered using Register(Clothes).

[JsonConverter(typeof(StaticJsonConverter<Clothes>), new object[] { typeof(Clothes), "PrivateTypes" })]
public class Clothes : IEmotionSource
Inheritance
Clothes
Implements
Inherited Members
Extension Methods

Constructors

Clothes(string, ClothesLayer, IReadOnlyDictionary<Point, TextureRegion>, Point, float, ClothesIntention, StylePreference, params ColorScheme[])

Creates a new clothes item with the given data, producing a texture layout according to the rules described in https://docs.tinylifegame.com/articles/creating_textures.html.

public Clothes(string name, ClothesLayer layer, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion, float price, ClothesIntention intentions, StylePreference stylePreference, params ColorScheme[] colors)

Parameters

name string

The name of this clothes item

layer ClothesLayer

The ClothesLayer that this clothes item should render on

textures IReadOnlyDictionary<Point, TextureRegion>

The texture atlas to use for this clothing item.

textureRegion Point

The top left (standing frame 1) TextureRegion that this clothes item uses in the world

price float

The price of this piece of clothing

intentions ClothesIntention

A set of ClothesIntention flags that determine what this clothes item can be used for

stylePreference StylePreference

The style preference that this clothing item falls into. A clothing item's style preference slightly influences whether it will be chosen in SetRandomClothesItem(Random, PersonLike, ClothesLayer, ClothesIntention, StylePreference?, bool, int, Func<Clothes, bool>).

colors ColorScheme[]

The set of ColorSchemes that this clothes item can have its colors selected from, where each entry corresponds to a texture layer.

Clothes(string, ClothesLayer, IReadOnlyDictionary<Point, TextureRegion>, Point, float, ClothesIntention, StylePreference, ColorSettings)

Creates a new clothes item with the given data, producing a texture layout according to the rules described in https://docs.tinylifegame.com/articles/creating_textures.html.

public Clothes(string name, ClothesLayer layer, IReadOnlyDictionary<Point, TextureRegion> textures, Point textureRegion, float price, ClothesIntention intentions, StylePreference stylePreference, ColorSettings colors)

Parameters

name string

The name of this clothes item

layer ClothesLayer

The ClothesLayer that this clothes item should render on

textures IReadOnlyDictionary<Point, TextureRegion>

The texture atlas to use for this clothing item.

textureRegion Point

The top left (standing frame 1) TextureRegion that this clothes item uses in the world

price float

The price of this piece of clothing

intentions ClothesIntention

A set of ClothesIntention flags that determine what this clothes item can be used for

stylePreference StylePreference

The style preference that this clothing item falls into. A clothing item's style preference slightly influences whether it will be chosen in SetRandomClothesItem(Random, PersonLike, ClothesLayer, ClothesIntention, StylePreference?, bool, int, Func<Clothes, bool>).

colors ColorSettings

The set of ColorSchemes that this clothes item can have its colors selected from, where each entry corresponds to a texture layer.

Fields

AllIntentions

A set of all valid ClothesIntention values

public static readonly ClothesIntention[] AllIntentions

Field Value

ClothesIntention[]

Colors

The set of ColorSchemes that this clothes item can have its colors selected from, where each entry corresponds to a texture layer gathered from the Textures based on the TextureRegion, according to the rules described in https://docs.tinylifegame.com/articles/creating_textures.html.

public readonly ColorSettings Colors

Field Value

ColorSettings

DefaultDepths

Stores the default depth for each ClothesLayer when rendering. The default depth is the index of the layer in the Layers array.

public static readonly Dictionary<ClothesLayer, int> DefaultDepths

Field Value

Dictionary<ClothesLayer, int>

Intentions

A set of ClothesIntention flags that determine what this clothes item can be used for.

public readonly ClothesIntention Intentions

Field Value

ClothesIntention

Layer

The ClothesLayer that this clothes item should render on

public readonly ClothesLayer Layer

Field Value

ClothesLayer

Layers

A set of all valid ClothesLayer values

public static readonly ClothesLayer[] Layers

Field Value

ClothesLayer[]

Name

The name of this clothes item. Since this is used for the Types registry, the name must be unique across mods.

public readonly string Name

Field Value

string

Price

The price of this piece of clothing.

public readonly float Price

Field Value

float

ReferencePrice

The reference price for a piece of clothing. When clothes items are randomly chosen for a new PersonLike, the items chosen will be guaranteed to have a price equal to or below this value.

public const int ReferencePrice = 50

Field Value

int

StylePreference

The style preference that this clothing item falls into. A clothing item's style preference slightly influences whether it will be chosen in SetRandomClothesItem(Random, PersonLike, ClothesLayer, ClothesIntention, StylePreference?, bool, int, Func<Clothes, bool>). The style preference is not exposed to players.

public readonly StylePreference StylePreference

Field Value

StylePreference

StylePreferences

A set of all valid StylePreference values.

public static readonly StylePreference[] StylePreferences

Field Value

StylePreference[]

TextureRegion

This clothing's initial, top left texture region, with additional regions laid out according to the rules described in https://docs.tinylifegame.com/articles/creating_textures.html.

public readonly Point TextureRegion

Field Value

Point

Textures

The texture atlas that this clothing item uses, which its base TextureRegion, animation frames and additional Colors are contained in.

public readonly IReadOnlyDictionary<Point, TextureRegion> Textures

Field Value

IReadOnlyDictionary<Point, TextureRegion>

Types

A registry that contains all Clothes in the game and all mods

public static readonly ReadOnlyDictionary<string, Clothes> Types

Field Value

ReadOnlyDictionary<string, Clothes>

Properties

Ages

The age groups that are allowed to wear these clothes. Defaults to Adult.

public AgeGroup Ages { get; init; }

Property Value

AgeGroup

DepthFunction

A function that determines the depth with which this clothes item is rendered based on the given Pose, their rotation, and the layer of this clothes item being rendered. This function defaults to returning Extensions.GetDepth.

public Func<(Pose Pose, Direction2 Rotation, int Layer), float> DepthFunction { get; init; }

Property Value

Func<(Pose Pose, Direction2 Rotation, int Layer), float>

Description

A function that can optionally determine a set of additional text strings that are added to this clothes item's description in the CharacterCreator. To do so, simply add to the passed List<T>.

public Action<Clothes, PersonLike, List<string>> Description { get; init; }

Property Value

Action<Clothes, PersonLike, List<string>>

Icon

The character creator icon for this object, which represents the category / theme / mod that it comes from. If this value is nonnull, the icon will be displayed in the corner of the character creator button for this object.

public TextureRegion Icon { get; init; }

Property Value

TextureRegion

IsIncompatible

An optional function that determines whether this clothing item is incompatible with the passed clothing item. If this function returns true, the other clothing item is removed from an Outfit when this item gets added.

public Func<Clothes, Clothes, bool> IsIncompatible { get; init; }

Property Value

Func<Clothes, Clothes, bool>

LayersToHide

A set of ClothesLayer flags that determines which clothes layers are hidden when this clothing item is being worn. This is used by objects like the headscarf, which hides hair.

public ClothesLayer LayersToHide { get; init; }

Property Value

ClothesLayer

NonBuyable

This value determines whether this clothes item can be bought in the character creator. If this value is false, the only way for this clothes item to be visible in the character creator is by adding it to the ClothesStorage.

public bool NonBuyable { get; init; }

Property Value

bool

PersonType

The type of person that is allowed to wear these clothes. Defaults to the Person type.

public Type PersonType { get; init; }

Property Value

Type

RandomColorWeight

An optional function that determines the weight that this clothing item's given color index has when randomly generating an Outfit for a PersonLike. The default weight for each clothing item's color is 1, and the higher the weight is, the more likely it is for the color to be chosen for an outfit.

public Func<Clothes, ColorScheme, int, float> RandomColorWeight { get; init; }

Property Value

Func<Clothes, ColorScheme, int, float>

RandomWeight

An optional function that determines the weight that this clothing item has when randomly generating an Outfit for a PersonLike. The higher the weight is, the more likely it is for this item to be chosen for an outfit. The default weight for a clothing item is 3 if any of the outfit's Intentions match the clothing item's Intentions, and 1 otherwise.

public Func<Clothes, Outfit, float> RandomWeight { get; init; }

Property Value

Func<Clothes, Outfit, float>

SourceString

A (localized) string that is displayed when hovering over an EmotionModifier that has this source

public string SourceString { get; }

Property Value

string

TextureBehaviorLayer

A ClothesLayer whose texture behavior should be used instead of the Layer's texture behavior. The texture behavior determines how many texture regions a clothes item uses, and whether they are animated in a certain Pose. For more information, see https://docs.tinylifegame.com/articles/creating_textures.html.

public ClothesLayer? TextureBehaviorLayer { get; init; }

Property Value

ClothesLayer?

Methods

AreCompatible(Clothes, Clothes)

A utility function that checks the passed two Clothes items' IsIncompatible functions and returns whether they are compatible, meaning whether they can be worn together in the same Outfit.

public static bool AreCompatible(Clothes clothes, Clothes other)

Parameters

clothes Clothes

The first clothes item.

other Clothes

The second clothes item.

Returns

bool

Whether the two clothes items are compatible.

GetDescription(PersonLike)

Returns this clothes item's description, which is displayed in the CharacterCreator. This method returns this clothes item's Intentions' description, as well as any additional description info returned by Description.

public IEnumerable<string> GetDescription(PersonLike person)

Parameters

person PersonLike

The person who is wearing this clothing item, or null.

Returns

IEnumerable<string>

This clothes item's description.

Register(Clothes)

Register the given clothes instance to the Types registry

public static Clothes Register(Clothes clothes)

Parameters

clothes Clothes

The clothes to register

Returns

Clothes

The passed clothes, for chaining.