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

Function InitializePickup

TombEngine/Game/pickup/pickup.cpp:1072–1135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1070}
1071
1072void InitializePickup(short itemNumber)
1073{
1074 auto* item = &g_Level.Items[itemNumber];
1075 auto bounds = GameBoundingBox(item);
1076
1077 item->Data = CollisionInfo();
1078 auto* coll = (CollisionInfo*)item->Data;
1079 coll->Setup.Radius = std::max(bounds.GetWidth(), bounds.GetDepth());
1080 coll->Setup.Height = bounds.GetHeight();
1081
1082 short triggerFlags = item->TriggerFlags & 0x3F;
1083 if (triggerFlags == 5)
1084 {
1085 item->ItemFlags[0] = item->Pose.Position.y - bounds.Y2;
1086 item->Status = ITEM_INVISIBLE;
1087 }
1088 else
1089 {
1090 if (triggerFlags == 0 ||
1091 triggerFlags == 3 ||
1092 triggerFlags == 4 ||
1093 triggerFlags == 7 ||
1094 triggerFlags == 8 ||
1095 triggerFlags == 11)
1096 {
1097 item->Pose.Position.y -= bounds.Y2;
1098
1099 if (triggerFlags == 0)
1100 {
1101 // Automatically align pickups to the floor surface.
1102 auto pointColl = GetPointCollision(*item);
1103 int bridgeItemNumber = pointColl.GetSector().GetInsideBridgeItemNumber(item->Pose.Position, true, true);
1104
1105 if (bridgeItemNumber != NO_VALUE)
1106 {
1107 // If pickup is within bridge item, most likely it means it is
1108 // below pushable or raising block, so ignore its collision.
1109 pointColl.GetSector().RemoveBridge(bridgeItemNumber);
1110 pointColl = GetPointCollision(*item);
1111 item->Pose.Position.y = pointColl.GetFloorHeight() - bounds.Y2;
1112 pointColl.GetSector().AddBridge(bridgeItemNumber);
1113 }
1114 else
1115 {
1116 item->Pose.Position.y = pointColl.GetFloorHeight() - bounds.Y2;
1117 }
1118
1119 AlignEntityToSurface(item, Vector2(Objects[item->ObjectNumber].radius));
1120 }
1121 }
1122
1123 if ((item->TriggerFlags & 0x80) != 0)
1124 {
1125 RPickups[NumRPickups] = itemNumber;
1126 NumRPickups++;
1127 }
1128
1129 if (item->TriggerFlags & 0x100)

Callers

nothing calls this directly

Calls 12

GetPointCollisionFunction · 0.85
AlignEntityToSurfaceFunction · 0.85
GetWidthMethod · 0.80
GetDepthMethod · 0.80
GetHeightMethod · 0.80
RemoveBridgeMethod · 0.80
AddBridgeMethod · 0.80
GameBoundingBoxClass · 0.70
CollisionInfoClass · 0.70
Vector2Function · 0.50
GetFloorHeightMethod · 0.45

Tested by

no test coverage detected