Clothes - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife.Objects

Clothes Class

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

public class Clothes :
TinyLife.World.IPricedObject

Inheritance System.Object 🡒 Clothes

Implements IPricedObject

Constructors

Clothes.Clothes(string, ClothesLayer, TextureRegion, float, ClothesIntention, TextureRegion, bool, ColorScheme[]) Constructor

Creates a new clothes item with the given data

public Clothes(string name, TinyLife.Objects.ClothesLayer layer, MLEM.Textures.TextureRegion region, float price, TinyLife.Objects.ClothesIntention intentions, MLEM.Textures.TextureRegion icon=null, bool nonBuyable=false, params TinyLife.Utilities.ColorScheme[] colors);

Parameters

name System.String
The name of this clothes item

layer ClothesLayer
The ClothesLayer that this clothes item should render on

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

price System.Single
The price of this piece of clothing

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

icon MLEM.Textures.TextureRegion
The character creator icon for this object, which represents the category / theme / mod that it comes from

nonBuyable System.Boolean
Whether this item should be unable to be bought in the character creator

colors ColorScheme[]
The ColorScheme that this clothes item can have its colors selected from

Fields

Clothes.Colors Field

The set of ColorSchemes that this clothes item can have its colors selected from.
The color scheme at index i will be mapped to the TextureRegions entry at index i.

public readonly ColorScheme[] Colors;

Field Value

ColorScheme[]

Clothes.Icon Field

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 readonly TextureRegion Icon;

Field Value

MLEM.Textures.TextureRegion

Clothes.Intentions Field

A set of ClothesIntention flags that determine what this clothes item can be used for.
This value is used by GetMatchingOutfit(ClothesIntention, float).

public readonly ClothesIntention Intentions;

Field Value

ClothesIntention

Clothes.Layer Field

The ClothesLayer that this clothes item should render on

public readonly ClothesLayer Layer;

Field Value

ClothesLayer

Clothes.Layers Field

A set of all valid ClothesLayer values

public static readonly ClothesLayer[] Layers;

Field Value

ClothesLayer[]

Clothes.Name Field

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

System.String

Clothes.NonBuyable Field

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 readonly bool NonBuyable;

Field Value

System.Boolean

Clothes.Price Field

The price of this piece of clothing.
Use GetPrice() to retrieve this value for consistency.

public readonly float Price;

Field Value

System.Single

Clothes.ReferencePrice Field

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

public const int ReferencePrice = 50;

Field Value

System.Int32

Clothes.TextureRegions Field

The MLEM.Textures.TextureRegion that this clothes item uses in the world.
The texture region specified in the constructor only needs to cover the top left animation frame of the Person, any remaining frames will automatically be gathered.
Multiple layers will be gathered if Colors has multiple entries. Each new layer will be gathered to the right of the passed region's area.

public readonly TextureRegion[] TextureRegions;

Field Value

MLEM.Textures.TextureRegion[]

Clothes.Types Field

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

public static readonly IDictionary<string,Clothes> Types;

Field Value

System.Collections.Generic.IDictionary<System.String,Clothes>

Methods

Clothes.GetIntentionDescription() Method

Returns a set of strings (split into multiple lines) that describes this clothes item's Intentions in a localized fashion

public System.Collections.Generic.IEnumerable<string> GetIntentionDescription();

Returns

System.Collections.Generic.IEnumerable<System.String>
This clothes item's intention description

Clothes.GetIntentionMatchingOutfit(IEnumerable<IEnumerable<Clothes>>, ClothesIntention, float) Method

Returns the index for an outfit that best matches the given ClothesIntention out of all of the passed outfits.
This method is used by GetMatchingOutfit(ClothesIntention, float) and evaluates the best match by using GetIntentionPercentage(IEnumerable<Clothes>, ClothesIntention).

public static int GetIntentionMatchingOutfit(System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<TinyLife.Objects.Clothes>> outfits, TinyLife.Objects.ClothesIntention intention, float requiredMatchPercentage=0f);

Parameters

outfits System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<Clothes>>
A set of outfits, each of which is a set of clothing items

intention ClothesIntention
The intention to match the best outfit to

requiredMatchPercentage System.Single
An optional minimum percentage that the returned outfit needs to have. If this is greater than 0, this method can return -1, meaning no outfit is sufficiently matching.

Returns

System.Int32
The index in the outfits collection that best matches the intention, or -1 if requiredMatchPercentage is set and there is no sufficient match

Clothes.GetIntentionPercentage(IEnumerable<Clothes>, ClothesIntention) Method

Returns a value between 0 and 1 that represents how well the given set of clothes (outfit) matches the given ClothesIntention.
For a person, this method is used by GetMatchingOutfit(ClothesIntention, float).

public static float GetIntentionPercentage(System.Collections.Generic.IEnumerable<TinyLife.Objects.Clothes> outfit, TinyLife.Objects.ClothesIntention intention);

Parameters

outfit System.Collections.Generic.IEnumerable<Clothes>
The outfit whose intention percentage to query

intention ClothesIntention
The intention to match the outfit to

Returns

System.Single
The intention match percentage, between 0 and 1

Clothes.GetPrice() Method

Returns the price that this object can be bought or sold for.
Note that, like in the case of the Painting, the returned price isn't necessarily the full price that the object can be sold for. Instead, the price returned here should be the price that this object has when bought or sold from the FurnitureTool or similar.

public float GetPrice();

Returns

System.Single
The object's price

Implements GetPrice()

Clothes.Register(Clothes) Method

Register the given clothes instance to the Types registry

public static void Register(TinyLife.Objects.Clothes clothes);

Parameters

clothes Clothes
The clothes to register