From e638cc9323c7b74279f0274591264efc53c29d4d Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:47:56 +0200 Subject: [PATCH] Server: create new core NavMesh types Create new types which will be used to refactor the current Detour implementation in the SDK. --- src/public/game/server/ai_agent.h | 38 +++++++++++++++++++++ src/public/game/server/ai_navmesh.h | 53 +++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/public/game/server/ai_agent.h create mode 100644 src/public/game/server/ai_navmesh.h diff --git a/src/public/game/server/ai_agent.h b/src/public/game/server/ai_agent.h new file mode 100644 index 00000000..a99314ce --- /dev/null +++ b/src/public/game/server/ai_agent.h @@ -0,0 +1,38 @@ +//=============================================================================// +// +// Purpose: defines the agent types for AI +// +//=============================================================================// +#ifndef AI_AGENT_H +#define AI_AGENT_H + +// The traverse types determine the animations, they also determine the jump +// links that can be taken (e.g. ANIMTYPE_FRAG_DRONE can take far more jumps +// than ANIMTYPE_STALKER. This is determined during the creation of the static +// pathing data in the NavMesh. +enum TraverseAnimType_e +{ + // NAVMESH_SMALL + ANIMTYPE_HUMAN = 0, + ANIMTYPE_SPECTRE, + ANIMTYPE_STALKER, + ANIMTYPE_FRAG_DRONE, + ANIMTYPE_PILOT, + + // NAVMESH_MED_SHORT + ANIMTYPE_PROWLER, + + // NAVMESH_MEDIUM + ANIMTYPE_SUPER_SPECTRE, + + // NAVMESH_LARGE + ANIMTYPE_TITAN, + + // NAVMESH_EXTRA_LARGE + ANIMTYPE_GOLIATH, + + // Not an anim type! + ANIMTYPE_COUNT +}; + +#endif // AI_AGENT_H diff --git a/src/public/game/server/ai_navmesh.h b/src/public/game/server/ai_navmesh.h new file mode 100644 index 00000000..005b3182 --- /dev/null +++ b/src/public/game/server/ai_navmesh.h @@ -0,0 +1,53 @@ +//=============================================================================// +// +// Purpose: defines the NavMesh types for AI +// +//=============================================================================// +#ifndef AI_NAVMESH_H +#define AI_NAVMESH_H + +#include "ai_agent.h" + +enum NavMeshType_e +{ + NAVMESH_SMALL = 0, + NAVMESH_MED_SHORT, + NAVMESH_MEDIUM, + NAVMESH_LARGE, + NAVMESH_EXTRA_LARGE, + + // Not a NavMesh! + NAVMESH_COUNT +}; + +inline const char* const g_navMeshNames[NAVMESH_COUNT] = { + "small", + "med_short", + "medium", + "large", + "extra_large" +}; + +inline const char* NavMesh_GetNameForType(const NavMeshType_e navMeshType) +{ + Assert(navMeshType >= 0 && navMeshType < NAVMESH_COUNT); + return g_navMeshNames[navMeshType]; +} + +inline const int g_traverseAnimTypeSetTableIndices[ANIMTYPE_COUNT] = { + // NAVMESH_SMALL has 5 reachability tables, so each traverse anim type indexes + // into its own. + 0, 0, 0, 0, 0, + + // All other navmeshes have 1 reachability table, so we need to subtract the + // number from the enumerant to index into the first one. + -5, -6, -7, -8 +}; + +inline int NavMesh_GetReachabilityTableIndexForTraverseAnimType(const TraverseAnimType_e animType) +{ + Assert(animType >= 0 && animType < V_ARRAYSIZE(g_traverseAnimTypeSetTableIndices)); + return animType + g_traverseAnimTypeSetTableIndices[animType]; +} + +#endif // AI_NAVMESH_H