* Open a door on this tile. * @param part * @param unit * @param reserve * @return a value: 0(normal door), 1(ufo door) or -1 if no door opened or 3 if ufo door(=animated) is still opening 4 if not enough TUs */
| 317 | * @return a value: 0(normal door), 1(ufo door) or -1 if no door opened or 3 if ufo door(=animated) is still opening 4 if not enough TUs |
| 318 | */ |
| 319 | int Tile::openDoor(int part, BattleUnit *unit, BattleActionType reserve) |
| 320 | { |
| 321 | if (!_objects[part]) return -1; |
| 322 | |
| 323 | if (_objects[part]->isDoor()) |
| 324 | { |
| 325 | if (unit && unit->getTimeUnits() < _objects[part]->getTUCost(unit->getArmor()->getMovementType()) + unit->getActionTUs(reserve, unit->getMainHandWeapon(false))) |
| 326 | return 4; |
| 327 | if (_unit && _unit != unit && _unit->getPosition() != getPosition()) |
| 328 | return -1; |
| 329 | setMapData(_objects[part]->getDataset()->getObjects()->at(_objects[part]->getAltMCD()), _objects[part]->getAltMCD(), _mapDataSetID[part], |
| 330 | _objects[part]->getDataset()->getObjects()->at(_objects[part]->getAltMCD())->getObjectType()); |
| 331 | setMapData(0, -1, -1, part); |
| 332 | return 0; |
| 333 | } |
| 334 | if (_objects[part]->isUFODoor() && _currentFrame[part] == 0) // ufo door part 0 - door is closed |
| 335 | { |
| 336 | if (unit && unit->getTimeUnits() < _objects[part]->getTUCost(unit->getArmor()->getMovementType()) + unit->getActionTUs(reserve, unit->getMainHandWeapon(false))) |
| 337 | return 4; |
| 338 | _currentFrame[part] = 1; // start opening door |
| 339 | return 1; |
| 340 | } |
| 341 | if (_objects[part]->isUFODoor() && _currentFrame[part] != 7) // ufo door != part 7 - door is still opening |
| 342 | { |
| 343 | return 3; |
| 344 | } |
| 345 | return -1; |
| 346 | } |
| 347 | |
| 348 | int Tile::closeUfoDoor() |
| 349 | { |
no test coverage detected