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

Function PoleCollision

TombEngine/Objects/Generic/Object/polerope.cpp:65–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 };
64
65 void PoleCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll)
66 {
67 auto& poleItem = g_Level.Items[itemNumber];
68 auto& player = GetLaraInfo(*laraItem);
69
70 bool isFacingPole = Geometry::IsPointInFront(laraItem->Pose, poleItem.Pose.Position.ToVector3());
71
72 g_Hud.InteractionHighlighter.Test(*laraItem, poleItem);
73
74 // Mount while grounded.
75 if (IsHeld(In::Action) && isFacingPole &&
76 TestState(laraItem->Animation.ActiveState, VPoleGroundedMountStates) &&
77 player.Control.HandStatus == HandStatus::Free ||
78 (player.Control.IsMoving && player.Context.InteractedItem == itemNumber))
79 {
80 // Temporarily reorient pole.
81 short yOrient = poleItem.Pose.Orientation.y;
82 poleItem.Pose.Orientation.y = laraItem->Pose.Orientation.y;
83
84 if (TestLaraPosition(VPoleBounds, &poleItem, laraItem))
85 {
86 if (MoveLaraPosition(VPolePos, &poleItem, laraItem))
87 {
88 SetAnimation(laraItem, LA_STAND_TO_POLE);
89 player.Control.IsMoving = false;
90 player.Control.HandStatus = HandStatus::Busy;
91 }
92 else
93 {
94 player.Context.InteractedItem = itemNumber;
95 }
96
97 poleItem.Pose.Orientation.y = yOrient;
98 }
99 else
100 {
101 if (player.Control.IsMoving && player.Context.InteractedItem == itemNumber)
102 {
103 player.Control.IsMoving = false;
104 player.Control.HandStatus = HandStatus::Free;
105 }
106
107 poleItem.Pose.Orientation.y = yOrient;
108 }
109
110 return;
111 }
112
113 // Mount while airborne.
114 if (IsHeld(In::Action) && isFacingPole &&
115 TestState(laraItem->Animation.ActiveState, VPoleAirborneMountStates) &&
116 laraItem->Animation.IsAirborne &&
117 laraItem->Animation.Velocity.y > 0.0f &&
118 player.Control.HandStatus == HandStatus::Free)
119 {
120 // Test sphere collision.
121 if (!TestLaraPoleCollision(laraItem, coll, true, -CLICK(1)) || !TestLaraPoleCollision(laraItem, coll, false))
122 return;

Callers

nothing calls this directly

Calls 13

IsPointInFrontFunction · 0.85
IsHeldFunction · 0.85
TestStateFunction · 0.85
TestLaraPositionFunction · 0.85
MoveLaraPositionFunction · 0.85
SetAnimationFunction · 0.85
TestLaraPoleCollisionFunction · 0.85
TestBoundsCollideFunction · 0.85
AlignLaraPositionFunction · 0.85
ObjectCollisionFunction · 0.85
ToVector3Method · 0.45

Tested by

no test coverage detected