MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / updateBattlescapeParameters

Method updateBattlescapeParameters

game/state/tilemap/tile.cpp:347–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347void Tile::updateBattlescapeParameters()
348{
349 if (map.ceaseUpdates)
350 {
351 return;
352 }
353 bool providedGroundUpwards = solidGround && height >= 0.9625f;
354 height = 0.0f;
355 movementCostIn = -1; // -1 means empty, and will be set to 4 afterwards
356 movementCostOver = 255;
357 movementCostLeft = 0;
358 movementCostRight = 0;
359 solidGround = false;
360 canStand = false;
361 hasLift = false;
362 hasExit = false;
363 walkSfx = nullptr;
364 objectDropSfx = nullptr;
365 supportProviderForItems = nullptr;
366 closedDoorLeft = false;
367 closedDoorRight = false;
368 for (auto &o : ownedObjects)
369 {
370 if (o->getType() == TileObject::Type::Ground || o->getType() == TileObject::Type::Feature)
371 {
372 auto mp = std::static_pointer_cast<TileObjectBattleMapPart>(o)->getOwner();
373 if (!mp->isAlive())
374 {
375 continue;
376 }
377 height = std::max(height, (float)mp->type->height);
378 if (mp->type->floor ||
379 (o->getType() == TileObject::Type::Feature && !mp->type->gravlift))
380 {
381 if (!supportProviderForItems ||
382 supportProviderForItems->type->height < mp->type->height)
383 {
384 supportProviderForItems = mp;
385 }
386 }
387 solidGround = solidGround || (mp->type->floor && !mp->type->gravlift) ||
388 (o->getType() == TileObject::Type::Feature && !mp->type->gravlift);
389 hasLift = hasLift || mp->type->gravlift;
390 hasExit = hasExit || mp->type->exit;
391 movementCostIn = std::max(movementCostIn, mp->type->movement_cost);
392 if (mp->type->sfxIndex != -1)
393 {
394 walkSfx = mp->type->walkSounds;
395 objectDropSfx = mp->type->objectDropSound;
396 }
397 }
398 if (o->getType() == TileObject::Type::LeftWall)
399 {
400 auto mp = std::static_pointer_cast<TileObjectBattleMapPart>(o)->getOwner();
401 if (!mp->isAlive())
402 {
403 continue;
404 }

Callers 4

setPositionMethod · 0.80
removeFromMapMethod · 0.80
setDoorStateMethod · 0.80

Calls 4

getTileMethod · 0.80
getTypeMethod · 0.45
getOwnerMethod · 0.45
isAliveMethod · 0.45

Tested by

no test coverage detected