LogoPixi’VN
indexClasses

Class: CharacterBaseModel

Defined in: src/characters/classes/CharacterBaseModel.ts:33

CharacterBaseModel is a class that is used to create a character model. You must use the RegisteredCharacters.add function to save the character in the game. It is raccomended to create your own class Character, read more here: https://pixi-vn.com/start/character.html#custom-character

Example

import { CharacterBaseModel, RegisteredCharacters } from "@drincs/pixi-vn";

export const liam = new CharacterBaseModel("liam", {
    name: "Liam",
    surname: "Smith",
    age: 25,
    icon: "https://example.com/liam.png",
    color: "#9e2e12",
});

export const emma = new CharacterBaseModel("emma", {
    name: "Emma",
    surname: "Johnson",
    age: 23,
    icon: "https://example.com/emma.png",
    color: "#9e2e12",
});

RegisteredCharacters.add([liam, emma]);

Extends

Constructors

Constructor

> new CharacterBaseModel(id, props): CharacterBaseModel

Defined in: src/characters/classes/CharacterBaseModel.ts:38

Parameters

id

string | CharacterEmotionId

A unique identifier (string). It is used to reference the character in the game (must be unique). If you want to create a character with an "emotion", you can pass an object.

props

CharacterBaseModelProps

The properties of the character.

Returns

CharacterBaseModel

Overrides

CharacterStoredClass.constructor

Properties

color?

> readonly optional color?: string

Defined in: src/characters/classes/CharacterBaseModel.ts:86

The color of the character.


defaultAge?

> readonly optional defaultAge?: number

Defined in: src/characters/classes/CharacterBaseModel.ts:68


defaultName?

> readonly optional defaultName?: string

Defined in: src/characters/classes/CharacterBaseModel.ts:46


defaultSurname?

> readonly optional defaultSurname?: string

Defined in: src/characters/classes/CharacterBaseModel.ts:57


icon?

> readonly optional icon?: string

Defined in: src/characters/classes/CharacterBaseModel.ts:82

The icon of the character.


id

> readonly id: string

Defined in: src/storage/classes/StoredClassModel.ts:63

Is id of the stored class. is unique for this class.

Inherited from

CharacterStoredClass.id

Accessors

age

Get Signature

> get age(): number | undefined

Defined in: src/characters/classes/CharacterBaseModel.ts:73

The age of the character. If you set undefined, it will return the default age.

Returns

number | undefined

Set Signature

> set age(value): void

Defined in: src/characters/classes/CharacterBaseModel.ts:76

Parameters
value

number | undefined

Returns

void


name

Get Signature

> get name(): string

Defined in: src/characters/classes/CharacterBaseModel.ts:51

The name of the character. If you set undefined, it will return the default name.

Returns

string

Set Signature

> set name(value): void

Defined in: src/characters/classes/CharacterBaseModel.ts:54

Parameters
value

string | undefined

Returns

void


surname

Get Signature

> get surname(): string | undefined

Defined in: src/characters/classes/CharacterBaseModel.ts:62

The surname of the character. If you set undefined, it will return the default surname.

Returns

string | undefined

Set Signature

> set surname(value): void

Defined in: src/characters/classes/CharacterBaseModel.ts:65

Parameters
value

string | undefined

Returns

void

Methods

getStorageProperty()

> getStorageProperty<T>(propertyName): T | undefined

Defined in: src/characters/classes/CharacterStoredClass.ts:16

Get a property from the storage.

Type Parameters

T

T

Parameters

propertyName

string

The name of the property to get.

Returns

T | undefined

The value of the property. If the property is not found, returns undefined.

Default

this.id

Inherited from

CharacterStoredClass.getStorageProperty


migrateOldStorage()

> protected migrateOldStorage(oldCategoryId?): void

Defined in: src/storage/classes/StoredClassModel.ts:43

Parameters

oldCategoryId?

string = ...

Returns

void

Inherited from

CharacterStoredClass.migrateOldStorage


setStorageProperty()

> protected setStorageProperty<T>(propertyName, value): void

Defined in: src/storage/classes/StoredClassModel.ts:71

Update a property in the storage.

Type Parameters

T

T

The type of the value to set. (Deprecated, it is not necessary to specify the type of the value, it will be inferred from the value)

Parameters

propertyName

string

The name of the property to set.

value

StorageElementType

The value to set. If is undefined, the property will be removed from the storage.

Returns

void

Inherited from

CharacterStoredClass.setStorageProperty

On this page