⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goal_hitswitch.cpp

📁 很好游戏代码
💻 CPP
字号:


Goal_HitSwitch::Goal_HitSwitch(AI* pAI, const PathNode *switchNode_) : Goal( pAI ), GoalQueue()
 switchNode(switchNode_), timer(0.0f), active(false)
{
	Assert(switchNode->flags & CPathNode::flagNodeSwitch);
	const CEntity *pEntity = switchNode->GetEntity();
	pSwitch = pEntity->Switch();
	Assert(pSwitch);
}

bool Goal_HitSwitch::ReplanSubgoals(){
	ResetSubgoals();
	NewSubgoal(new Goal_GotoNode(mpAI, switchNode)); //goto the switch
	NewSubgoal(new Goal_TurnToEntity(mpAI, pSwitch)); //turn towards the switch
	return true;
}

Goal_HitSwitch::~Goal_HitSwitch()
{
}

// Update the goal
void Goal_HitSwitch::Update( float secs_elapsed )
{	
	if (!active){
		ReplanSubgoals();
		active = true;
	}

	typeGoalStatus status = UpdateSubgoals( secs_elapsed );
	if (status==statusFailed) {
		mGoalStatus = statusFailed;	
		return; 
	}

	if (!NoSubgoals())
		return;

	mpAI->Nudge(pSwitch->ID()); //send an activation message to the switch

	mGoalStatus = statusSucceeded;
}

⌨️ 快捷键说明

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