sdk7-npc-utils
Version:
A collection of helpers to make it easier to build a Decentraland scene using the SDK 7.
120 lines (119 loc) • 2.85 kB
TypeScript
import { Vector3 } from "@dcl/sdk/math";
export type Dialog = {
text: string;
name?: string;
fontSize?: number;
offsetX?: number;
offsetY?: number;
typeSpeed?: number;
isEndOfDialog?: boolean;
triggeredByNext?: () => void;
portrait?: ImageData;
image?: ImageData;
isQuestion?: boolean;
isFixedScreen?: boolean;
buttons?: ButtonData[];
audio?: string;
skipable?: boolean;
timeOn?: number;
};
export type TriggerData = {
layer?: number;
triggeredByLayer?: number;
onTriggerEnter?: () => void;
onTriggerExit?: () => void;
onCameraEnter?: () => void;
onCameraExit?: () => void;
enableDebug?: boolean;
};
export type ButtonData = {
goToDialog: number | string;
label: string;
triggeredActions?: () => void;
fontSize?: number;
offsetX?: number;
offsetY?: number;
};
export declare enum ButtonStyles {
E = "e",
F = "f",
DARK = "dark",
RED = "red",
ROUNDBLACK = "roundblack",
ROUNDWHITE = "roundwhite",
ROUNDSILVER = "roundsilver",
ROUNDGOLD = "roundgold",
SQUAREBLACK = "squareblack",
SQUAREWHITE = "squarewhite",
SQUARESILVER = "squaresilver",
SQUAREGOLD = "squaregold",
WHITE = "white"
}
export type NPCData = {
type: NPCType;
body?: NPCBodyType;
model?: string;
walkingAnim?: string;
portrait?: string | ImageData;
reactDistance?: number;
idleAnim?: string;
faceUser?: boolean;
turningSpeed?: number;
onlyExternalTrigger?: boolean;
onlyClickTrigger?: boolean;
onlyETrigger?: boolean;
onActivate: () => void;
onWalkAway?: () => void;
continueOnWalkAway?: boolean;
darkUI?: boolean;
coolDownDuration?: number;
hoverText?: string;
dialogSound?: string;
textBubble?: boolean;
bubbleHeight?: number;
noUI?: boolean;
pathData?: FollowPathData;
};
export type FollowPathData = {
startingPoint?: number;
loop?: boolean;
curve?: boolean;
totalDuration: number;
speed?: number;
path?: Vector3[];
pathType?: NPCPathType;
onFinishCallback?: () => void;
onReachedPointCallback?: () => void;
};
export type ImageSection = {
sourceWidth: number;
sourceHeight: number;
sourceLeft?: number;
sourceTop?: number;
};
export type ImageData = {
path: string;
offsetX?: number;
offsetY?: number;
height?: number;
width?: number;
section?: ImageSection;
};
export declare enum NPCState {
STANDING = "standing",
TALKING = "talking",
FOLLOWPATH = "followPath"
}
export declare enum NPCBodyType {
MALE = "BaseMale",
FEMALE = "BaseFemale"
}
export declare enum NPCType {
BLANK = "blank",
CUSTOM = "custom",
AVATAR = "avatar"
}
export declare enum NPCPathType {
SMOOTH_PATH = "smooth",
RIGID_PATH = "rigid"
}