| 214 | } |
| 215 | |
| 216 | void BattleUnit::setPosition(GameState &state, const Vec3<float> &pos, bool goal) |
| 217 | { |
| 218 | auto oldPosition = position; |
| 219 | position = pos; |
| 220 | if (!tileObject) |
| 221 | { |
| 222 | LogError("setPosition called on unit with no tile object"); |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | tileObject->setPosition(pos); |
| 227 | if (shadowObject) |
| 228 | { |
| 229 | shadowObject->setPosition(tileObject->getCenter()); |
| 230 | } |
| 231 | |
| 232 | if (oldPosition != position) |
| 233 | { |
| 234 | // Notify battle that there's action going on at this position |
| 235 | state.current_battle->notifyAction(position, {&state, id}); |
| 236 | if ((Vec3<int>)oldPosition != (Vec3<int>)position) |
| 237 | { |
| 238 | // Notify motion scanners |
| 239 | state.current_battle->notifyScanners(position); |
| 240 | tilesMoved++; |
| 241 | // Spread hazards if this agent does so |
| 242 | // (this overrides enzyme hazards) |
| 243 | if (agent->type->spreadHazardDamageType) |
| 244 | { |
| 245 | state.current_battle->placeHazard( |
| 246 | state, owner, {&state, id}, agent->type->spreadHazardDamageType, oldPosition, |
| 247 | agent->type->spreadHazardDamageType->hazardType->getLifetime(state), |
| 248 | randBoundsInclusive(state.rng, agent->type->spreadHazardMinPower, |
| 249 | agent->type->spreadHazardMaxPower), |
| 250 | agent->type->spreadHazardTTLDivizor, false); |
| 251 | } |
| 252 | // Spawn enzyme hazards |
| 253 | else if (enzymeDebuffIntensity > 0) |
| 254 | { |
| 255 | spawnEnzymeSmoke(state); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | if (goal) |
| 261 | { |
| 262 | onReachGoal(state); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | Vec3<float> BattleUnit::getVelocity() const |
| 267 | { |
nothing calls this directly
no test coverage detected