74 lines
1.9 KiB
C
74 lines
1.9 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "entity/entitybase.h"
|
|
|
|
typedef struct cutsceneitem_s cutsceneitem_t;
|
|
typedef union cutsceneitemdata_u cutsceneitemdata_t;
|
|
|
|
/** Default speed for CUTSCENE_ENTITY_WALK_TO/_PATH, in units/second. */
|
|
#define CUTSCENE_ENTITY_WALK_SPEED_DEFAULT 4.0f
|
|
|
|
/** Below this squared distance, an entity is considered to have arrived. */
|
|
#define CUTSCENE_ENTITY_WALK_ARRIVE_THRESHOLD_SQ 0.0001f
|
|
|
|
typedef struct {
|
|
uint8_t entityIndex;
|
|
const vec3 *positions;
|
|
uint8_t count;
|
|
float_t speed;
|
|
} cutsceneentitywalkto_t;
|
|
|
|
typedef struct {
|
|
uint8_t currentIndex;
|
|
} cutsceneentitywalktodata_t;
|
|
|
|
/**
|
|
* Starts an entity walk-to item (resets the waypoint index).
|
|
*
|
|
* @param item The cutscene item.
|
|
* @param data Runtime data storage.
|
|
*/
|
|
void cutsceneEntityWalkToStart(
|
|
const cutsceneitem_t *item,
|
|
cutsceneitemdata_t *data
|
|
);
|
|
|
|
/**
|
|
* Updates an entity walk-to item (steps the entity toward the next
|
|
* waypoint).
|
|
*
|
|
* @param item The cutscene item.
|
|
* @param data Runtime data storage.
|
|
* @returns true once all waypoints have been reached.
|
|
*/
|
|
bool_t cutsceneEntityWalkToUpdate(
|
|
const cutsceneitem_t *item,
|
|
cutsceneitemdata_t *data
|
|
);
|
|
|
|
/**
|
|
* Steps an entity's local position directly toward target at speed
|
|
* units/second (straight-line, no pathfinding/obstacle avoidance), and
|
|
* faces it in the direction of travel. No-op (returns true immediately)
|
|
* if the entity has no POSITION component.
|
|
*
|
|
* @param mgr The entity manager that owns the entity.
|
|
* @param entityId The entity to move.
|
|
* @param target The local-space destination.
|
|
* @param speed Movement speed, in units/second.
|
|
* @returns true once the entity is within
|
|
* CUTSCENE_ENTITY_WALK_ARRIVE_THRESHOLD_SQ of target.
|
|
*/
|
|
bool_t cutsceneEntityStepToward(
|
|
entitymanager_t *mgr,
|
|
const entityid_t entityId,
|
|
vec3 target,
|
|
const float_t speed
|
|
);
|