pathcache.h

来自「这是整套横扫千军3D版游戏的源码」· C头文件 代码 · 共 44 行

H
44
字号
#ifndef PATHCACHE_H
#define PATHCACHE_H

#include "IPath.h"
#include <map>
#include <list>

class CPathCache
{
public:
	CPathCache(int blocksX,int blocksZ);
	~CPathCache(void);

	struct CacheItem {
		IPath::SearchResult result;
		IPath::Path path;
		int2 startBlock;
		int2 goalBlock;
		float goalRadius;
		int pathType;
	};

	void AddPath(IPath::Path* path, IPath::SearchResult result, int2 startBlock,int2 goalBlock,float goalRadius,int pathType);
	CacheItem* GetCachedPath(int2 startBlock,int2 goalBlock,float goalRadius,int pathType);
	void Update(void);

	std::map<unsigned int,CacheItem*> cachedPaths;

	struct CacheQue {
		int timeout;
		unsigned int hash;
	};
	std::list<CacheQue> cacheQue;
	void RemoveFrontQueItem(void);

	int blocksX;
	int blocksZ;

	int numCacheHits;
	int numCacheMisses;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?