| 454 | } |
| 455 | |
| 456 | void AEquipment::update(GameState &state, unsigned int ticks) |
| 457 | { |
| 458 | bool realTime = state.current_battle->mode == Battle::Mode::RealTime; |
| 459 | |
| 460 | // Firing update |
| 461 | if (weapon_fire_ticks_remaining > 0) |
| 462 | { |
| 463 | if (weapon_fire_ticks_remaining > ticks) |
| 464 | { |
| 465 | weapon_fire_ticks_remaining -= ticks; |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | weapon_fire_ticks_remaining = 0; |
| 470 | readyToFire = true; |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | if (isFiring()) |
| 475 | { |
| 476 | // If firing - confirm we're still in inventory |
| 477 | // If firing - confirm we're still aiming |
| 478 | if (!ownerAgent || ownerAgent->unit->target_hand_state == HandState::AtEase) |
| 479 | { |
| 480 | stopFiring(); |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | // If firing - confirm we're still attacking with it and it's in right place |
| 485 | switch (equippedSlotType) |
| 486 | { |
| 487 | // Check if we're still firing |
| 488 | case EquipmentSlotType::LeftHand: |
| 489 | if (ownerAgent->unit->weaponStatus != WeaponStatus::FiringBothHands && |
| 490 | ownerAgent->unit->weaponStatus != WeaponStatus::FiringLeftHand) |
| 491 | { |
| 492 | stopFiring(); |
| 493 | } |
| 494 | else if (ownerAgent->unit->fire_aiming_mode != aimingMode) |
| 495 | { |
| 496 | startFiring(ownerAgent->unit->fire_aiming_mode, !realTime); |
| 497 | } |
| 498 | break; |
| 499 | case EquipmentSlotType::RightHand: |
| 500 | if (ownerAgent->unit->weaponStatus != WeaponStatus::FiringBothHands && |
| 501 | ownerAgent->unit->weaponStatus != WeaponStatus::FiringRightHand) |
| 502 | { |
| 503 | stopFiring(); |
| 504 | } |
| 505 | else if (ownerAgent->unit->fire_aiming_mode != aimingMode) |
| 506 | { |
| 507 | startFiring(ownerAgent->unit->fire_aiming_mode, !realTime); |
| 508 | } |
| 509 | break; |
| 510 | // If weapon was moved to any other slot from hands, stop firing |
| 511 | default: |
| 512 | stopFiring(); |
| 513 | break; |
nothing calls this directly
no test coverage detected