virtual bool Process(MobMovementManager *mgr, Mob *m) { if (!m->IsAIControlled()) { return true; } auto rotate_to_speed = m_rotate_to_mode == MovementRunning ? 200.0 : 16.0; //todo: get this from mob auto from = FixHeading(m->GetHeading()); auto to = FixHeading(m_rotate_to); auto diff = to - from; while (diff < -256.0) { diff += 512.0; } while (diff > 256) { diff -= 512.0; } auto dist = std::abs(diff); if (!m_started) { m_started = true; m->SetMoving(true); if (dist > 15.0f && rotate_to_speed > 0.0 && rotate_to_speed <= 25.0) { //send basic rotation mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, m_rotate_to_dir * rotate_to_speed, 0, ClientRangeClose); } } auto td = rotate_to_speed * 19.0 * frame_time; if (td >= dist) { m->SetHeading(to); m->SetMoving(false); mgr->SendCommandToClients(m, 0.0, 0.0, 0.0, 0.0, 0, ClientRangeCloseMedium); return true; } from += td * m_rotate_to_dir; m->SetHeading(FixHeading(from)); return false; }
void MobMovementManager::PushRotateTo(MobMovementEntry &ent, Mob *who, float to, MobMovementMode mode) { auto from = FixHeading(who->GetHeading()); to = FixHeading(to); float diff = to - from; if (std::abs(diff) < 0.001f) { return; } while (diff < -256.0) { diff += 512.0; } while (diff > 256) { diff -= 512.0; } ent.Commands.push_back(std::unique_ptr<IMovementCommand>(new RotateToCommand(to, diff > 0 ? 1.0 : -1.0, mode))); }
BOOL CGridCtrlComp::OnResizeColumn(int col, UINT size) { if (size > 0) FixHeading(col, size); return TRUE; }