@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
213 lines (206 loc) • 6.65 kB
TypeScript
import { a as StorageElementType } from './StorageElementType-dAIVJeiw.js';
import { S as StoredClassModel } from './StoredClassModel-D-s0mEVj.js';
import { CharacterInterface as CharacterInterface$1 } from '@drincs/pixi-vn';
/**
* CharacterBaseModelProps is an interface that is used to create a character model.
*/
interface CharacterBaseModelProps {
/**
* The name of the character.
*/
name?: string;
/**
* The surname of the character.
*/
surname?: string;
/**
* The age of the character.
*/
age?: number;
/**
* The icon of the character.
*/
icon?: string;
/**
* The color of the character.
*/
color?: string;
}
declare class CharacterStoredClass extends StoredClassModel {
private sourceId;
constructor(id: string, emotion?: string);
getStorageProperty<T extends StorageElementType>(propertyName: string): T | undefined;
}
/**
* CharacterBaseModel is a class that is used to create a character model.
* You must use the {@link 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.web.app/start/character.html#custom-character
* @example
* ```typescript
* export const liam = new CharacterBaseModel('liam', {
* name: 'Liam',
* surname: 'Smith',
* age: 25,
* icon: "https://pixijs.com/assets/eggHead.png",
* color: "#9e2e12"
* });
* export const alice = new CharacterBaseModel('alice', {
* name: 'Alice',
* surname: 'Smith',
* age: 25,
* icon: "https://pixijs.com/assets/eggHead.png",
* color: "#9e2e12"
* });
* RegisteredCharacters.add([liam, alice]);
* ```
*/
declare class CharacterBaseModel extends CharacterStoredClass {
/**
* @param id The id of the character.
* @param props The properties of the character.
*/
constructor(id: string | {
id: string;
emotion: string;
}, props: CharacterBaseModelProps);
private defaultName?;
/***
* The name of the character.
* If you set undefined, it will return the default name.
*/
get name(): string;
set name(value: string | undefined);
private defaultSurname?;
/**
* The surname of the character.
* If you set undefined, it will return the default surname.
*/
get surname(): string | undefined;
set surname(value: string | undefined);
private defaultAge?;
/**
* The age of the character.
* If you set undefined, it will return the default age.
*/
get age(): number | undefined;
set age(value: number | undefined);
private _icon?;
/**
* The icon of the character.
*/
get icon(): string | undefined;
private _color?;
/**
* The color of the character.
*/
get color(): string | undefined;
}
declare namespace RegisteredCharacters {
/**
* is a function that returns the character by the id
* @param id is the id of the character
* @returns the character
* @example
* ```typescript
* const liam = RegisteredCharacters.get('liam');
* ```
*/
function get<T = CharacterInterface$1>(id: string): T | undefined;
/**
* Is a function that saves the character. If the character already exists, it will be overwritten.
* @param character is the character to save
* @returns
* @example
* ```typescript
* export const liam = new CharacterBaseModel('liam', { name: 'Liam'});
* export const alice = new CharacterBaseModel('alice', { name: 'Alice'});
* RegisteredCharacters.add([liam, alice]);
* ```
*/
function add(character: CharacterInterface$1 | CharacterInterface$1[]): void;
/**
* is a function that returns all characters
* @returns all characters
* @example
* ```typescript
* const allCharacters = RegisteredCharacters.values();
* ```
*/
function values<T extends CharacterInterface$1>(): T[];
/**
* Check if a character is registered.
* @param id is the id of the character
* @returns true if the character exists, false otherwise
*/
function has(id: string): boolean;
/**
* Get a list of all character ids registered.
* @returns An array of label ids.
*/
function keys(): string[];
}
/**
* CharacterInterface is the interface that character must implement or extend.
* So if you want to create your own Character, you must override this interface, implement or extend it and extend the {@link CharacterStoredClass} class.
* You can override this interface to add your own props.
* @example
* ```typescript
* // pixi-vn.d.ts
* declare module '@drincs/pixi-vn' {
* interface CharacterInterface {
* name: string
* surname?: string
* age?: number
* icon?: string
* color?: string
* }
* }
* // You Character class
* export class Character extends CharacterStoredClass implements CharacterInterface {
* constructor(id: string, props: CharacterProps) {
* super(id)
* this.defaultName = props.name
* this.defaultSurname = props.surname
* this.defaultAge = props.age
* this._icon = props.icon
* this._color = props.color
* }
* private defaultName: string = ""
* get name(): string {
* return this.getStorageProperty<string>("name") || this.defaultName
* }
* set name(value: string | undefined) {
* this.setStorageProperty<string>("name", value)
* }
* private defaultSurname?: string
* get surname(): string | undefined {
* return this.getStorageProperty<string>("surname") || this.defaultSurname
* }
* set surname(value: string | undefined) {
* this.setStorageProperty<string>("surname", value)
* }
* private defaultAge?: number | undefined
* get age(): number | undefined {
* return this.getStorageProperty<number>("age") || this.defaultAge
* }
* set age(value: number | undefined) {
* this.setStorageProperty<number>("age", value)
* }
* private _icon?: string
* get icon(): string | undefined {
* return this._icon
* }
* private _color?: string | undefined
* get color(): string | undefined {
* return this._color
* }
* }
* ```
*/
interface CharacterInterface {
/**
* The id of the character. It must be unique.
*/
id: string;
}
export { CharacterBaseModel, type CharacterInterface, CharacterStoredClass, RegisteredCharacters };