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

Method think

src/Battlescape/UnitTurnBState.cpp:96–129  ·  view source on GitHub ↗

* Runs state functionality every cycle. */

Source from the content-addressed store, hash-verified

94 * Runs state functionality every cycle.
95 */
96void UnitTurnBState::think()
97{
98 const int tu = _unit->getFaction() == _parent->getSave()->getSide() ? 1 : 0; // one turn is 1 tu unless during reaction fire.
99
100 if (_unit->getFaction() == _parent->getSave()->getSide() && _parent->getPanicHandled() && !_action.targeting && !_parent->checkReservedTU(_unit, tu))
101 {
102 _unit->abortTurn();
103 _parent->popState();
104 return;
105 }
106
107 if (_unit->spendTimeUnits(tu))
108 {
109 size_t unitSpotted = _unit->getUnitsSpottedThisTurn().size();
110 _unit->turn(_turret);
111 _parent->getTileEngine()->calculateFOV(_unit);
112 _unit->setCache(0);
113 _parent->getMap()->cacheUnit(_unit);
114 if (_unit->getFaction() == _parent->getSave()->getSide() && _parent->getPanicHandled() && _action.type == BA_NONE && _unit->getUnitsSpottedThisTurn().size() > unitSpotted)
115 {
116 _unit->abortTurn();
117 }
118 if (_unit->getStatus() == STATUS_STANDING)
119 {
120 _parent->popState();
121 }
122 }
123 else if (_parent->getPanicHandled())
124 {
125 _action.result = "STR_NOT_ENOUGH_TIME_UNITS";
126 _unit->abortTurn();
127 _parent->popState();
128 }
129}
130
131/**
132 * Unit turning cannot be cancelled.

Callers

nothing calls this directly

Calls 15

getFactionMethod · 0.80
getSideMethod · 0.80
getSaveMethod · 0.80
getPanicHandledMethod · 0.80
checkReservedTUMethod · 0.80
abortTurnMethod · 0.80
spendTimeUnitsMethod · 0.80
turnMethod · 0.80
calculateFOVMethod · 0.80
setCacheMethod · 0.80
cacheUnitMethod · 0.80
popStateMethod · 0.45

Tested by

no test coverage detected