MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / openDoor

Method openDoor

src/Savegame/Tile.cpp:319–346  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

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 */
319int 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
348int Tile::closeUfoDoor()
349{

Callers 2

unitOpensDoorMethod · 0.80
checkAdjacentDoorsMethod · 0.80

Calls 13

isDoorMethod · 0.80
getTimeUnitsMethod · 0.80
getMovementTypeMethod · 0.80
getActionTUsMethod · 0.80
getMainHandWeaponMethod · 0.80
getObjectsMethod · 0.80
getDatasetMethod · 0.80
getAltMCDMethod · 0.80
getObjectTypeMethod · 0.80
isUFODoorMethod · 0.80
getTUCostMethod · 0.45
getArmorMethod · 0.45

Tested by

no test coverage detected