/* Help-function. Turns a start->goal-request into a will defined request. */ unsigned int CPathManager::RequestPath(const MoveData* moveData, float3 startPos, float3 goalPos, float goalRadius, CSolidObject* caller) { startPos.CheckInBounds(); goalPos.CheckInBounds(); if (startPos.x > gs->mapx * SQUARE_SIZE - 5) { startPos.x = gs->mapx * SQUARE_SIZE - 5; } if (goalPos.z > gs->mapy * SQUARE_SIZE - 5) { goalPos.z = gs->mapy * SQUARE_SIZE - 5; } // Create an estimator definition. CRangedGoalWithCircularConstraint* rangedGoalPED = SAFE_NEW CRangedGoalWithCircularConstraint(startPos,goalPos, goalRadius, 3, 2000); // Make request. return RequestPath(moveData, startPos, rangedGoalPED, goalPos, caller); }
/* Help-function. Turns a start->goal-request into a well-defined request. */ unsigned int CPathManager::RequestPath( const MoveDef* moveDef, const float3& startPos, const float3& goalPos, float goalRadius, CSolidObject* caller, bool synced ) { float3 sp(startPos); sp.ClampInBounds(); float3 gp(goalPos); gp.ClampInBounds(); // Create an estimator definition. CRangedGoalWithCircularConstraint* pfDef = new CRangedGoalWithCircularConstraint(sp, gp, goalRadius, 3.0f, 2000); // Make request. return RequestPath(moveDef, sp, gp, pfDef, caller, synced); }
void GridNavigationComponent::Update(float a_dt) { GameobjectComponent::Update(a_dt); if (m_wander) { if (!m_activePath) { GridObject* grid = m_pathfinder->GetGridObject(); if (grid) RequestPath(grid->GetRandomPositionOnGrid()); } } TraversePath(a_dt); DrawDebug(); }
/// Mainly handles. void PathableProperty::ProcessMessage(Message * message) { if (message->type == MessageType::SET_PATH_DESTINATION_MESSAGE) { SetPathDestinationMessage * wm = (SetPathDestinationMessage*) message; RequestPath(wm->pos); return; } if (message->type != MessageType::PATHFINDING_MESSAGE) return; PathMessage * pm = (PathMessage*)message; /// Response from pathfinding server? assert(pm->requestResponse == PathMessage::RESPONSE); StartWalking(pm->path); if (pm->path.Size() == 0) { /// Notify that we got a bad path. Message msg("PathableProperty::ZeroLengthPathReceived"); owner->ProcessMessage(&msg); } }
/* Help-function. Turns a start->goal-request into a well-defined request. */ unsigned int CPathManager::RequestPath( const MoveData* moveData, const float3& startPos, const float3& goalPos, float goalRadius, CSolidObject* caller, bool synced ) { float3 sp(startPos); sp.CheckInBounds(); float3 gp(goalPos); gp.CheckInBounds(); // ? // if (sp.x > (gs->mapx * SQUARE_SIZE - 5)) { sp.x = gs->mapx * SQUARE_SIZE - 5; } // if (gp.z > (gs->mapy * SQUARE_SIZE - 5)) { gp.z = gs->mapy * SQUARE_SIZE - 5; } // Create an estimator definition. CRangedGoalWithCircularConstraint* rangedGoalPED = new CRangedGoalWithCircularConstraint(sp, gp, goalRadius, 3.0f, 2000); // Make request. return RequestPath(moveData, sp, gp, rangedGoalPED, caller, synced); }
/// Requests a path to the target position. This will then be returned via the PathManaging system as a message. void PathableProperty::RequestPath(ConstVec3fr toPosition) { /// Find WP. Waypoint * wp = WaypointMan.GetClosestValidWaypoint(toPosition); RequestPath(wp); }
void CEC_TV::loop() { if (CECSerial->available()){ switch (CECSerial->read()) { case MESSAGE_REPORT_LOGICAL: _logicalAddress = CECBlockRead(); DbgPrint("got logical addr: %d.\r\n", _logicalAddress); TransmitMsg(CECDEVICE_BROADCAST, 4, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS, 0, 0, 0); break; case MESSAGE_RECIEVED: byte len = CECBlockRead(); if (len < 1) { //error DbgPrint("got bogus len %d.\r\n", len); break; } len--;//remove addr byte address = CECBlockRead();//contains both dst and src! byte* message = (byte*)malloc(len); for (int i = 0; i<len; i++){ message[i] = CECBlockRead(); } OnReceive(address >> 4, address & 0xF, message, len); } } checkStartupTimeout(); decode_results results; if (irrecv.decode(&results)) { //#ifdef DEBUG_IRCODES //Serial.print("received something!\r\n"); //#endif if (results.value == REPEAT){//defined in IRremote.h unsigned long timeNow = millis(); if (_lastRemoteInputTime /*&& timeNow-_lastRemoteInputTime >= 20*/ && timeNow - _lastRemoteInputTime <= 200) { results.value = _lastRemoteInputCode; _lastRemoteInputTime = millis(); //Serial.println("REPEAT"); //Serial.println(results.value, HEX); } //Serial.println(timeNow - _lastRemoteInputTime); } else { if (results.decode_type == RC6) results.value &= ~(1L << 16); //Serial.println(results.value, HEX); _lastRemoteInputTime = millis(); _lastRemoteInputCode = results.value; //Serial.println(results.value, HEX); //Serial.println(_lastRemoteInputCode, HEX); } switch (results.value) { case REMOTE_POWER: check_remote_protocol delay(250); powerToggle(); break; case REMOTE_GUIDE: check_remote_protocol delay(250); sendKoganCode(&irsend, KOGAN_ASPECT); break; case REMOTE_UP: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_UP); break; case REMOTE_DOWN: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_DOWN); break; case REMOTE_LEFT: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_LEFT); break; case REMOTE_RIGHT: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_RIGHT); break; case REMOTE_ENTER: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_SELECT); break; case REMOTE_BACK: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_EXIT); break; case REMOTE_PLAY: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_PLAY); break; case REMOTE_PAUSE: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_PAUSE); break; case REMOTE_SKIP_BACK: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_BACKWARD); break; case REMOTE_SKIP_FORWARD: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_FORWARD); break; case REMOTE_STOP: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_STOP); break; case REMOTE_RECORD: check_remote_protocol //delay(100); sendUC(CEC_USER_CONTROL_CODE_RECORD); break; case REMOTE_VOL_UP: check_remote_protocol //delay(100); SendRemoteCode(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_VOLUME_UP); break; case REMOTE_VOL_DOWN: check_remote_protocol //delay(100); SendRemoteCode(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_VOLUME_DOWN); break; case REMOTE_1: check_remote_protocol powerOn(); RequestPath(0x1100); RequestAudio(0x1100); break; case REMOTE_2: check_remote_protocol powerOn(); RequestPath(0x1200); RequestAudio(0x1200); break; case REMOTE_3: check_remote_protocol powerOn(); RequestPath(0x1300); RequestAudio(0x1300); break; case REMOTE_4: check_remote_protocol powerOn(); RequestPath(0x1400); RequestAudio(0x1400); //DbgPrint("Done requesting\n"); break; #ifdef DEBUG_IRCODES default: debugIRCode(&results); #endif } irrecv.resume(); // resume receiver //DbgPrint("resumed\n"); } }