groupai.cpp

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

CPP
71
字号
// GroupAI.cpp: implementation of the CGroupAI class.
//
//////////////////////////////////////////////////////////////////////

#include "StdAfx.h"
#include "GroupAI.h"
#include "ExternalAI/IGroupAiCallback.h"
#include "ExternalAI/IAICallback.h"
#include "Sim/Units/UnitDef.h"
#include "Sim/Units/CommandAI/CommandQueue.h"

#define CMD_DUMMY			170

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CGroupAI::CGroupAI()
{
}

CGroupAI::~CGroupAI()
{
}

void CGroupAI::InitAi(IGroupAICallback* callback)
{
	this->callback=callback;
	aicb=callback->GetAICallback();
}

bool CGroupAI::AddUnit(int unit)
{
	return true;
}

void CGroupAI::RemoveUnit(int unit)
{
}

void CGroupAI::GiveCommand(Command* c)
{
}

const vector<CommandDescription>& CGroupAI::GetPossibleCommands()
{
	return commands;
}

int CGroupAI::GetDefaultCmd(int unit)
{
	return CMD_DUMMY;
}

void CGroupAI::CommandFinished(int unit,int type)
{
	if(type != CMD_STOP && type != CMD_MOVE)
	{
		const CCommandQueue* commandQue = aicb->GetCurrentUnitCommands(unit);
		if (commandQue->empty() ||
		    ((commandQue->size() == 1) &&
		     (commandQue->front().id == CMD_SET_WANTED_MAX_SPEED))) {
			aicb->SendTextMsg("Builder idle",0);
			aicb->SetLastMsgPos(aicb->GetUnitPos(unit));
		}
	}
}
void CGroupAI::Update()
{
}

⌨️ 快捷键说明

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