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

Function RopeCollision

TombEngine/Objects/Generic/Object/rope.cpp:167–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165 }
166
167 void RopeCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll)
168 {
169 auto* laraInfo = GetLaraInfo(laraItem);
170 auto* ropeItem = &g_Level.Items[itemNumber];
171 auto* rope = &Ropes[ropeItem->TriggerFlags];
172
173 if (IsHeld(In::Action) &&
174 laraInfo->Control.HandStatus == HandStatus::Free &&
175 (laraItem->Animation.ActiveState == LS_REACH || laraItem->Animation.ActiveState == LS_JUMP_UP) &&
176 laraItem->Animation.IsAirborne &&
177 laraItem->Animation.Velocity.y > 0.0f &&
178 rope->active)
179 {
180 auto frame = GameBoundingBox(laraItem);
181
182 int segment = RopeNodeCollision(
183 rope,
184 laraItem->Pose.Position.x,
185 laraItem->Pose.Position.y + frame.Y1 + 512,
186 laraItem->Pose.Position.z + frame.Z2 * phd_cos(laraItem->Pose.Orientation.y),
187 laraItem->Animation.ActiveState == LS_REACH ? 128 : 320);
188
189 if (segment >= 0)
190 {
191 if (laraItem->Animation.ActiveState == LS_REACH)
192 {
193 laraItem->Animation.AnimNumber = LA_REACH_TO_ROPE_SWING;
194 laraItem->Animation.ActiveState = LS_ROPE_SWING;
195 laraInfo->Control.Rope.Frame = 32 << 8;
196 laraInfo->Control.Rope.DFrame = 60 << 8;
197 }
198 else
199 {
200 laraItem->Animation.AnimNumber = LA_JUMP_UP_TO_ROPE_START;
201 laraItem->Animation.ActiveState = LS_ROPE_IDLE;
202 }
203
204 laraItem->Animation.FrameNumber = 0;
205 laraItem->Animation.Velocity.y = 0;
206 laraItem->Animation.IsAirborne = false;
207
208 laraInfo->Control.HandStatus = HandStatus::Busy;
209 laraInfo->Control.Rope.Ptr = ropeItem->TriggerFlags;
210 laraInfo->Control.Rope.Segment = segment;
211 laraInfo->Control.Rope.Y = laraItem->Pose.Orientation.y;
212
213 DelAlignLaraToRope(laraItem);
214
215 CurrentPendulum.velocity.x = 0;
216 CurrentPendulum.velocity.y = 0;
217 CurrentPendulum.velocity.z = 0;
218
219 ApplyVelocityToRope(segment, laraItem->Pose.Orientation.y, 16 * laraItem->Animation.Velocity.z);
220 }
221 }
222 }
223
224 void RopeDynamics(ROPE_STRUCT* rope)

Callers

nothing calls this directly

Calls 6

IsHeldFunction · 0.85
RopeNodeCollisionFunction · 0.85
phd_cosFunction · 0.85
DelAlignLaraToRopeFunction · 0.85
ApplyVelocityToRopeFunction · 0.85
GameBoundingBoxClass · 0.50

Tested by

no test coverage detected