Add start dialogue action and interaction link creation
This commit is contained in:
@@ -48,6 +48,11 @@ export interface StopSoundAction {
|
||||
targetSoundEmitterId: string;
|
||||
}
|
||||
|
||||
export interface StartDialogueAction {
|
||||
type: "startDialogue";
|
||||
dialogueId: string;
|
||||
}
|
||||
|
||||
export interface ControlInteractionAction {
|
||||
type: "control";
|
||||
effect: ControlEffect;
|
||||
@@ -60,6 +65,7 @@ export type InteractionAction =
|
||||
| StopAnimationAction
|
||||
| PlaySoundAction
|
||||
| StopSoundAction
|
||||
| StartDialogueAction
|
||||
| ControlInteractionAction;
|
||||
|
||||
export interface InteractionLink {
|
||||
@@ -114,6 +120,13 @@ export interface CreateStopSoundInteractionLinkOptions {
|
||||
targetSoundEmitterId: string;
|
||||
}
|
||||
|
||||
export interface CreateStartDialogueInteractionLinkOptions {
|
||||
id?: string;
|
||||
sourceEntityId: string;
|
||||
trigger?: InteractionTriggerKind;
|
||||
dialogueId: string;
|
||||
}
|
||||
|
||||
export interface CreateControlInteractionLinkOptions {
|
||||
id?: string;
|
||||
sourceEntityId: string;
|
||||
@@ -162,6 +175,11 @@ function cloneAction(action: InteractionAction): InteractionAction {
|
||||
type: "stopSound",
|
||||
targetSoundEmitterId: action.targetSoundEmitterId
|
||||
};
|
||||
case "startDialogue":
|
||||
return {
|
||||
type: "startDialogue",
|
||||
dialogueId: action.dialogueId
|
||||
};
|
||||
case "control":
|
||||
return {
|
||||
type: "control",
|
||||
@@ -306,6 +324,23 @@ export function createStopSoundInteractionLink(
|
||||
};
|
||||
}
|
||||
|
||||
export function createStartDialogueInteractionLink(
|
||||
options: CreateStartDialogueInteractionLinkOptions
|
||||
): InteractionLink {
|
||||
assertNonEmptyString(options.sourceEntityId, "Interaction source entity id");
|
||||
assertNonEmptyString(options.dialogueId, "Dialogue id");
|
||||
|
||||
return {
|
||||
id: options.id ?? createOpaqueId("interaction-link"),
|
||||
sourceEntityId: options.sourceEntityId,
|
||||
trigger: options.trigger ?? "enter",
|
||||
action: {
|
||||
type: "startDialogue",
|
||||
dialogueId: options.dialogueId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function createControlInteractionLink(
|
||||
options: CreateControlInteractionLinkOptions
|
||||
): InteractionLink {
|
||||
@@ -348,6 +383,8 @@ export function getInteractionActionControlEffect(
|
||||
return createStopSoundControlEffect({
|
||||
target: createSoundEmitterControlTargetRef(action.targetSoundEmitterId)
|
||||
});
|
||||
case "startDialogue":
|
||||
return null;
|
||||
case "control":
|
||||
return cloneControlEffect(action.effect);
|
||||
case "teleportPlayer":
|
||||
@@ -370,6 +407,8 @@ export function getInteractionActionLabel(action: InteractionAction): string {
|
||||
return "Play Sound";
|
||||
case "stopSound":
|
||||
return "Stop Sound";
|
||||
case "startDialogue":
|
||||
return "Start Dialogue";
|
||||
case "control":
|
||||
return getControlEffectLabel(action.effect);
|
||||
}
|
||||
@@ -435,6 +474,11 @@ export function areInteractionLinksEqual(
|
||||
left.action.targetSoundEmitterId ===
|
||||
(right.action as StopSoundAction).targetSoundEmitterId
|
||||
);
|
||||
case "startDialogue":
|
||||
return (
|
||||
left.action.dialogueId ===
|
||||
(right.action as StartDialogueAction).dialogueId
|
||||
);
|
||||
case "control":
|
||||
return areControlEffectsEqual(
|
||||
left.action.effect,
|
||||
|
||||
Reference in New Issue
Block a user