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