📄 keepertricks.cc
字号:
// Bag of primarily Keeper tricks
#include <math.h>
#include "KeeperTricks.h"
#include "MovementTricks.h"
#include "BasicTricks.h"
#include "HeadTricks.h"
#include "../Common/Common.h"
#include "../Globals.h"
KeeperTricks::ChaseWithKick::ChaseWithKick() {
currentTrick = new BasicTricks::NullBody();
headTrick = new BasicTricks::NullHead();
justKicked = false;
interruptible = true;
}
KeeperTricks::ChaseWithKick::~ChaseWithKick() {
delete currentTrick;
delete headTrick;
}
int KeeperTricks::ChaseWithKick::Start() {
return Continue();
}
int KeeperTricks::ChaseWithKick::Abort() {
currentTrick->Abort();
headTrick->Abort();
return 0;
}
int KeeperTricks::ChaseWithKick::Continue() {
headTrick->Continue();
int cC = currentTrick->Continue();
char* cMsg = currentTrick->GetErrorMsg(cC);
if (cC < 1) {
delete currentTrick;
if (strcmp(cMsg,"BALL_UNDER_CHIN") == 0) {
// we want to clear the current step so the damn thing stops moving ASAP !
utils.Step(LocomotionCommand::TP_WALK,0.0,0.0,0.0,0.0,1.0);
currentTrick = ks.KeeperSelecta(wo_self_->x_, wo_self_->y_, wo_self_->heading_);
interruptible = false;
justKicked = true;
} else if (strcmp(cMsg,"SEE_BALL_AFTER_KICK") == 0 || vo_ball_ != NULL) {
interruptible = true;
currentTrick = new MovementTricks::ChaseBall();
} else {
interruptible = true;
currentTrick = new BasicTricks::NullBody();
return 0;
}
currentTrick->Start();
} else if (strcmp(cMsg,"GRAB_FAIL") == 0) {
// if grab failed, we want to totally abort.
// this generally means that a WaitForGrab ended and we could still see the ball (!!)
cout << "ChaseWithKick: Failed grab." << endl << flush;
currentTrick->Abort();
interruptible = true;
delete currentTrick;
currentTrick = new MovementTricks::ChaseBall();
currentTrick->Start();
}
// if we've just lost the ball (CLOSE_SEARCH), we're not interruptible for this frame!
if (interruptible && (strcmp(cMsg,"CLOSE_SEARCH")!=0) ) return 1;
return 2;
}
bool KeeperTricks::ChaseWithKick::IsUsingHead() {
return true;
}
char* KeeperTricks::ChaseWithKick::GetErrorMsg(int c) {
if (c == 0) return "CWK_DONE";
else if (c == 1) return "INTERRUPTIBLE";
else if (c == 2) return "NOT_INTERRUPTIBLE";
return "CWK:NO_MESSAGE";
}
char* KeeperTricks::ChaseWithKick::GetName() {
return "ChaseWithKick";
}
// END ChaseWithkick
//////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -