MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / DoObjectCollision

Function DoObjectCollision

TombEngine/Game/collision/collide_item.cpp:1812–1988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1810}
1811
1812void DoObjectCollision(ItemInfo* item, CollisionInfo* coll)
1813{
1814 item->HitStatus = false;
1815 coll->HitStatic = false;
1816
1817 bool isPlayer = item->IsLara();
1818 bool isHarmless = !isPlayer && (item->Data.is<KayakInfo>() || item->Data.is<UPVInfo>());
1819
1820 if (isPlayer)
1821 {
1822 GetLaraInfo(*item).HitDirection = NO_VALUE;
1823
1824 if (item->HitPoints <= 0)
1825 return;
1826 }
1827
1828 if (Objects[item->ObjectNumber].intelligent)
1829 return;
1830
1831 const auto& room = g_Level.Rooms[item->RoomNumber];
1832 for (int neighborRoomNumber : room.NeighborRoomNumbers)
1833 {
1834 auto& neighborRoom = g_Level.Rooms[neighborRoomNumber];
1835 if (!neighborRoom.Active())
1836 continue;
1837
1838 int nextItemNumber = neighborRoom.itemNumber;
1839 while (nextItemNumber != NO_VALUE)
1840 {
1841 auto& linkItem = g_Level.Items[nextItemNumber];
1842 int itemNumber = nextItemNumber;
1843
1844 // HACK: For some reason, sometimes an infinite loop may happen here.
1845 if (nextItemNumber == linkItem.NextItem)
1846 break;
1847
1848 nextItemNumber = linkItem.NextItem;
1849
1850 if (&linkItem == item)
1851 continue;
1852
1853 if (!(linkItem.Collidable && linkItem.Status != ITEM_INVISIBLE))
1854 continue;
1855
1856 const auto& object = Objects[linkItem.ObjectNumber];
1857
1858 if (object.collision == nullptr)
1859 continue;
1860
1861 if (Vector3i::Distance(linkItem.Pose.Position, item->Pose.Position) >= COLLISION_CHECK_DISTANCE)
1862 continue;
1863
1864 if (isPlayer)
1865 {
1866 // Ignore all non-intelligent objects, if player is on a vehicle. This way we avoid
1867 // any collision routine calls for any interactable objects, as in original, but fix
1868 // the issue with enemies not hurting Lara on a vehicle via hand combat.
1869 if (GetLaraInfo(*item).Context.Vehicle != NO_VALUE && !object.intelligent)

Callers 6

DoVehicleCollisionFunction · 0.85
BigGunControlFunction · 0.85
DoTeethSpikeCollisionFunction · 0.85
LaraAboveWaterFunction · 0.85
LaraWaterSurfaceFunction · 0.85
LaraUnderwaterFunction · 0.85

Calls 12

TestBoundsCollideFunction · 0.85
ItemPushItemFunction · 0.85
DoDamageFunction · 0.85
DoLotsOfBloodFunction · 0.85
SoundEffectFunction · 0.85
CreatureDieFunction · 0.85
TestBoundsCollideStaticFunction · 0.85
GetShatterSoundFunction · 0.85
ShatterObjectFunction · 0.85
ItemPushStaticFunction · 0.85
IsLaraMethod · 0.80
ActiveMethod · 0.80

Tested by

no test coverage detected