86 lines
2.0 KiB
C
86 lines
2.0 KiB
C
// Copyright (c) 2026 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "error/error.h"
|
|
|
|
#define CUTSCENE_EVENT_COUNT_MAX 16
|
|
|
|
typedef struct {
|
|
errorret_t (*onStart)(void);
|
|
errorret_t (*onEnd)(void);
|
|
errorret_t (*onUpdate)(void);
|
|
} cutsceneevent_t;
|
|
|
|
typedef struct {
|
|
cutsceneevent_t events[CUTSCENE_EVENT_COUNT_MAX];
|
|
uint8_t eventCount;
|
|
uint8_t eventCurrent;
|
|
errorret_t (*onStop)(void);
|
|
bool_t active;
|
|
} cutscene_t;
|
|
|
|
extern cutscene_t CUTSCENE;
|
|
|
|
/**
|
|
* Initializes the cutscene manager.
|
|
*
|
|
* @return Any error state that happened.
|
|
*/
|
|
errorret_t cutsceneInit(void);
|
|
|
|
/**
|
|
* Ticks the active cutscene event, calling its onUpdate callback.
|
|
* Does nothing when no cutscene is playing.
|
|
*
|
|
* @return Any error state that happened.
|
|
*/
|
|
errorret_t cutsceneUpdate(void);
|
|
|
|
/**
|
|
* Copies the given event array and begins playing from the first
|
|
* event. If a cutscene is already playing it is stopped first.
|
|
*
|
|
* @param events Array of events to copy.
|
|
* @param eventCount Number of events. Must be > 0 and
|
|
* <= CUTSCENE_EVENT_COUNT_MAX.
|
|
* @return Any error state that happened.
|
|
*/
|
|
errorret_t cutscenePlay(
|
|
const cutsceneevent_t *events,
|
|
const uint8_t eventCount
|
|
);
|
|
|
|
/**
|
|
* Ends the current event and starts the next one.
|
|
* Marks the cutscene as inactive after the last event ends.
|
|
* Does nothing when no cutscene is playing.
|
|
*
|
|
* @return Any error state that happened.
|
|
*/
|
|
errorret_t cutsceneAdvance(void);
|
|
|
|
/**
|
|
* Ends the current event and stops the cutscene immediately.
|
|
* Does nothing when no cutscene is playing.
|
|
*
|
|
* @return Any error state that happened.
|
|
*/
|
|
errorret_t cutsceneStop(void);
|
|
|
|
/**
|
|
* Disposes of the cutscene manager, stopping any active cutscene.
|
|
*
|
|
* @return Any error state that happened.
|
|
*/
|
|
errorret_t cutsceneDispose(void);
|
|
|
|
/**
|
|
* Returns whether a cutscene is currently playing.
|
|
*
|
|
* @return true if a cutscene is active.
|
|
*/
|
|
bool_t cutsceneIsActive(void);
|