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

Function SmashObject

TombEngine/Objects/TR5/Shatter/tr5_smashobject.cpp:32–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void SmashObject(short itemNumber)
33{
34 auto* item = &g_Level.Items[itemNumber];
35 auto* room = &g_Level.Rooms[item->RoomNumber];
36
37 int sectorX = (item->Pose.Position.x - room->Position.x) / BLOCK(1);
38 int sectorZ = (item->Pose.Position.z - room->Position.z) / BLOCK(1);
39
40 if (sectorX >= 0 && sectorX < room->XSize && sectorZ >= 0 && sectorZ < room->ZSize)
41 {
42 int sectorIndex = sectorZ + room->ZSize * sectorX;
43
44 if (room->Sectors[sectorIndex].PathfindingBoxID != NO_VALUE)
45 {
46 auto* box = &g_Level.PathfindingBoxes[room->Sectors[sectorIndex].PathfindingBoxID];
47 if (box->flags & BLOCKABLE)
48 box->flags &= ~BLOCKED;
49 }
50 }
51
52 SoundEffect(SFX_TR5_SMASH_GLASS, &item->Pose);
53
54 item->Collidable = false;
55 item->MeshBits = 0xFFFE;
56
57 ExplodingDeath(itemNumber, BODY_DO_EXPLOSION | BODY_NO_BOUNCE);
58
59 item->Flags |= IFLAG_INVISIBLE;
60
61 if (item->Status == ITEM_ACTIVE)
62 RemoveActiveItem(itemNumber);
63
64 item->Status = ITEM_DEACTIVATED;
65}
66
67void SmashObjectControl(short itemNumber)
68{

Callers 6

ControlExplosionFunction · 0.85
ControlGunShipFunction · 0.85
SmashObjectControlFunction · 0.85
GetTargetOnLOSFunction · 0.85
SmashItemFunction · 0.85
HandleProjectileFunction · 0.85

Calls 3

SoundEffectFunction · 0.85
ExplodingDeathFunction · 0.85
RemoveActiveItemFunction · 0.85

Tested by

no test coverage detected