2023-05-02 09:42:43 +03:00
|
|
|
//
|
2023-05-24 23:41:23 +03:00
|
|
|
// YaPB, based on PODBot by Markus Klinge ("CountFloyd").
|
|
|
|
|
// Copyright © YaPB Project Developers <yapb@jeefo.net>.
|
2023-05-02 09:42:43 +03:00
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// next code is based on cs-ebot implementation, devised by EfeDursun125
|
2023-05-02 09:42:43 +03:00
|
|
|
class GraphAnalyze : public Singleton <GraphAnalyze> {
|
|
|
|
|
public:
|
|
|
|
|
GraphAnalyze () = default;
|
|
|
|
|
~GraphAnalyze () = default;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
float m_updateInterval {}; // time to update analyzer
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
bool m_basicsCreated {}; // basics nodes were created?
|
2023-05-02 09:42:43 +03:00
|
|
|
bool m_isCrouch {}; // is node to be created as crouch ?
|
|
|
|
|
bool m_isAnalyzing {}; // we're in analyzing ?
|
2023-05-12 22:12:22 +03:00
|
|
|
bool m_isAnalyzed {}; // current node is analyzed
|
2023-05-02 09:42:43 +03:00
|
|
|
bool m_expandedNodes[kMaxNodes] {}; // all nodes expanded ?
|
|
|
|
|
bool m_optimizedNodes[kMaxNodes] {}; // all nodes expanded ?
|
|
|
|
|
|
|
|
|
|
public:
|
2023-05-12 22:12:22 +03:00
|
|
|
// start analysis process
|
2023-05-02 09:42:43 +03:00
|
|
|
void start ();
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// update analysis process
|
2023-05-02 09:42:43 +03:00
|
|
|
void update ();
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// suspend analysis
|
2023-05-02 09:42:43 +03:00
|
|
|
void suspend ();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// flood with nodes
|
|
|
|
|
void flood (const Vector &pos, const Vector &next, float range);
|
|
|
|
|
|
|
|
|
|
// set update interval (keeps game from freezing)
|
|
|
|
|
void setUpdateInterval ();
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// mark nodes as goals
|
2023-05-02 09:42:43 +03:00
|
|
|
void markGoals ();
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// terminate analysis and save data
|
2023-05-02 09:42:43 +03:00
|
|
|
void finish ();
|
|
|
|
|
|
|
|
|
|
// optimize nodes a little
|
|
|
|
|
void optimize ();
|
|
|
|
|
|
|
|
|
|
// cleanup bad nodes
|
|
|
|
|
void cleanup ();
|
|
|
|
|
|
2024-01-19 00:03:45 +03:00
|
|
|
// show overlay message about analyzing
|
|
|
|
|
void displayOverlayMessage ();
|
|
|
|
|
|
2023-05-02 09:42:43 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// node should be created as crouch
|
|
|
|
|
bool isCrouch () const {
|
|
|
|
|
return m_isCrouch;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// is currently analyzing ?
|
2023-05-02 09:42:43 +03:00
|
|
|
bool isAnalyzing () const {
|
|
|
|
|
return m_isAnalyzing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// current graph is analyzed graph ?
|
|
|
|
|
bool isAnalyzed () const {
|
|
|
|
|
return m_isAnalyzed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mark as optimized
|
|
|
|
|
void markOptimized (const int index) {
|
|
|
|
|
m_optimizedNodes[index] = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-12 22:12:22 +03:00
|
|
|
// expose global
|
2023-05-02 09:42:43 +03:00
|
|
|
CR_EXPOSE_GLOBAL_SINGLETON (GraphAnalyze, analyzer);
|