OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
actorpath.h
1/*
2===========================================================================
3Copyright (C) 2025 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// actorpath.h: Actor path
24
25#pragma once
26
27#include "navigate.h"
28#include "archive.h"
29
30#define MIN_FALLHEIGHT 18
31#define MAX_FALLHEIGHT 1024
32
33class ActorPath
34{
35 // path list
36 PathInfo *m_path;
37 int m_pathlen;
38
39 // path position
40 PathInfo *m_pathpos;
41
42 // starting path position
43 PathInfo *m_startpathpos;
44 vec2_t m_delta;
45 bool m_Side;
46 int m_Time;
47 float m_TotalDist;
48 short int m_FallHeight;
49 bool m_HasCompleteLookahead;
50 float m_fLookAhead;
51 bool m_bChangeLookAhead;
52
53private:
54 float PathLookAhead(float total_area, Vector& end, float *origin);
55
56public:
57 ActorPath();
58 ~ActorPath();
59
60 void Clear(void);
61 bool DoesTheoreticPathExist(
62 float *start, float *end, class SimpleActor *ent, float maxPath, float *vLeashHome, float fLeashDistSquared
63 );
64 void FindPath(float *start, float *end, Entity *ent, float maxPath, float *vLeashHome, float fLeashDistSquared);
65 void FindPathAway(
66 float *start,
67 float *avoid,
68 float *vPreferredDir,
69 Entity *ent,
70 float fMinSafeDist,
71 float *vLeashHome,
72 float fLeashDistSquared
73 );
74 void FindPathNear(
75 float *start,
76 float *nearby,
77 Entity *ent,
78 float maxPath,
79 float fRadiusSquared,
80 float *vLeashHome,
81 float fLeashDistSquared
82 );
83 void ReFindPath(float *start, Entity *ent);
84 void UpdatePos(float *origin, float fNodeRadius = 0.0f);
85 bool Complete(const float *origin) const;
86 PathInfo *StartNode(void) const;
87 PathInfo *CurrentNode(void) const;
88 int CurrentNodeIndex(void) const;
89 PathInfo *NextNode(void) const;
90 PathInfo *LastNode(void) const;
91 const float *CurrentPathDir(void) const;
92 const float *CurrentPathGoal(void) const;
93 int Time(void) const;
94 const float *CurrentDelta(void) const;
95 bool IsAccurate(void) const;
96 float TotalDist(void) const;
97 void SetFallHeight(float fHeight);
98 float GetFallHeight(void) const;
99 void TrimPathFromEnd(int nNodesPop);
100 void Shorten(float fDistRemove);
101 bool HasCompleteLookahead(void) const;
102 void ForceShortLookahead(void);
103
104 virtual void Archive(Archiver& arc);
105
106 bool IsSide(void) const;
107};
108
109inline void ActorPath::Archive(Archiver& arc)
110{
111 int index;
112 int i;
113
114 arc.ArchiveInteger(&m_pathlen);
115
116 if (m_pathlen) {
117 if (arc.Loading()) {
118 m_path = new PathInfo[m_pathlen];
119 }
120
121 for (i = 0; i < m_pathlen; i++) {
122 m_path[i].Archive(arc);
123 }
124
125 if (!arc.Saving()) {
126 arc.ArchiveInteger(&index);
127 if (index == -1) {
128 m_pathpos = NULL;
129 } else {
130 m_pathpos = &m_path[index];
131 }
132
133 arc.ArchiveInteger(&index);
134 if (index == -1) {
135 m_startpathpos = NULL;
136 } else {
137 m_startpathpos = &m_path[index];
138 }
139 } else {
140 if (m_pathpos) {
141 index = m_pathpos - m_path;
142 } else {
143 index = -1;
144 }
145
146 arc.ArchiveInteger(&index);
147
148 if (m_startpathpos) {
149 index = m_startpathpos - m_path;
150 } else {
151 index = -1;
152 }
153
154 arc.ArchiveInteger(&index);
155 }
156 } else if (arc.Loading()) {
157 m_pathpos = 0;
158 }
159
160 arc.ArchiveVec2(m_delta);
161 arc.ArchiveBool(&m_Side);
162 arc.ArchiveInteger(&m_Time);
163 arc.ArchiveFloat(&m_TotalDist);
164 arc.ArchiveShort(&m_FallHeight);
165 arc.ArchiveShort(&m_FallHeight);
166 arc.ArchiveBool(&m_HasCompleteLookahead);
167 arc.ArchiveFloat(&m_fLookAhead);
168 arc.ArchiveBool(&m_bChangeLookAhead);
169}
Definition archive.h:86
Definition entity.h:203
Definition navigate.h:99
Definition simpleactor.h:80
Definition vector.h:61