dcl-npc-toolkit-ai-version
Version:
A collection of tools for creating Non-Player-Characters (NPCs). These are capable of having conversations with the player, and play different animations. AI usage is added atop of it
125 lines (124 loc) • 3.15 kB
TypeScript
import { Entity, PBAvatarShape, PBGltfContainer } from '@dcl/sdk/ecs';
import { Vector3 } from '@dcl/sdk/math';
export type Dialog = {
text: string;
windowHeight?: 'auto' | number;
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?: (other: Entity) => void;
onTriggerExit?: (other: Entity) => void;
onCameraEnter?: (other: Entity) => void;
onCameraExit?: (other: Entity) => void;
enableDebug?: boolean;
};
export type ButtonData = {
goToDialog: number | string;
label: string;
triggeredActions?: () => void;
fontSize?: number;
offsetX?: number;
offsetY?: number;
size?: number | 'auto';
};
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 | PBGltfContainer | PBAvatarShape;
walkingAnim?: string;
portrait?: string | ImageData;
reactDistance?: number;
idleAnim?: string;
faceUser?: boolean;
turningSpeed?: number;
onlyExternalTrigger?: boolean;
onlyClickTrigger?: boolean;
onlyETrigger?: boolean;
onActivate: (other: Entity) => void;
onWalkAway?: (other: Entity) => void;
continueOnWalkAway?: boolean;
darkUI?: boolean;
coolDownDuration?: number;
hoverText?: string;
dialogSound?: string;
textBubble?: boolean;
bubbleHeight?: number;
noUI?: boolean;
pathData?: FollowPathData;
bubbleXOffset?: number;
bubbleYOffset?: number;
};
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"
}