| 196 | } |
| 197 | |
| 198 | void TechController::tickMaster(float dt) { |
| 199 | // if there's no gravity, fly instead of walking |
| 200 | if (m_movementController->zeroG()) { |
| 201 | if (m_moveRight || m_moveLeft || m_moveUp || m_moveDown) { |
| 202 | Vec2F flightControl = {0, 0}; |
| 203 | |
| 204 | if (m_moveRight) |
| 205 | flightControl[0]++; |
| 206 | if (m_moveLeft) |
| 207 | flightControl[0]--; |
| 208 | if (m_moveUp) |
| 209 | flightControl[1]++; |
| 210 | if (m_moveDown) |
| 211 | flightControl[1]--; |
| 212 | |
| 213 | m_movementController->controlFly(flightControl); |
| 214 | } |
| 215 | } else { |
| 216 | if (m_moveLeft != m_moveRight) |
| 217 | m_movementController->controlMove(m_moveLeft ? Direction::Left : Direction::Right, m_moveRun); |
| 218 | |
| 219 | if (m_moveJump && !m_moveDown) |
| 220 | m_movementController->controlJump(); |
| 221 | |
| 222 | if (m_movementController->onGround() && m_moveDown && !m_moveJump) |
| 223 | m_movementController->controlCrouch(); |
| 224 | else if (m_moveDown) |
| 225 | m_movementController->controlDown(); |
| 226 | } |
| 227 | |
| 228 | for (auto& module : m_techModules) { |
| 229 | JsonObject moves = { |
| 230 | {"run", m_moveRun}, |
| 231 | {"up", m_moveUp}, |
| 232 | {"down", m_moveDown}, |
| 233 | {"left", m_moveLeft}, |
| 234 | {"right", m_moveRight}, |
| 235 | {"jump", m_moveJump}, |
| 236 | {"primaryFire", m_movePrimaryFire}, |
| 237 | {"altFire", m_moveAltFire}, |
| 238 | {"special1", m_moveSpecial1}, |
| 239 | {"special2", m_moveSpecial2}, |
| 240 | {"special3", m_moveSpecial3} |
| 241 | }; |
| 242 | |
| 243 | module.scriptComponent.update(JsonObject{{"moves", moves}, {"dt", module.scriptComponent.updateDt(dt)}}); |
| 244 | } |
| 245 | |
| 246 | resetMoves(); |
| 247 | updateAnimators(dt); |
| 248 | } |
| 249 | |
| 250 | void TechController::tickSlave(float dt) { |
| 251 | resetMoves(); |
no test coverage detected