MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / Init

Method Init

ogsr_engine/xrGame/PHCaptureInit.cpp:235–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void CPHCapture::Init(CInifile* ini)
236{
237 Fvector dir;
238 Fvector capture_bone_position = GetCapturePosition();
239 b_character_feedback = true;
240
241 m_taget_element->GetGlobalPositionDynamic(&dir);
242 dir.sub(capture_bone_position, dir);
243
244 m_pull_distance = ini->r_float(m_capture_section, "pull_distance");
245 if (!m_hard_mode && dir.magnitude() > m_pull_distance)
246 {
247 m_taget_object = NULL;
248 b_failed = true;
249 return;
250 }
251
252 m_capture_distance = ini->r_float(m_capture_section, "distance");
253 m_capture_force = ini->r_float(m_capture_section, "capture_force");
254 m_capture_time = ini->r_u32(m_capture_section, "time_limit") * 1000;
255
256 float pull_force_factor = READ_IF_EXISTS(ini, r_float, m_capture_section, "pull_force_factor", 4.f);
257 auto ps = m_taget_object->PPhysicsShell();
258 m_pull_force = pull_force_factor * ph_world->Gravity() * ps->getMass();
259
260 m_time_start = Device.dwTimeGlobal;
261
262 float pulling_vel_scale = ini->r_float(m_capture_section, "velocity_scale");
263 m_taget_element->set_DynamicLimits(default_l_limit * pulling_vel_scale, default_w_limit * pulling_vel_scale);
264 // m_taget_element->PhysicsShell()->set_ObjectContactCallback(object_contactCallbackFun);
265 m_character->SetObjectContactCallback(object_contactCallbackFun);
266 m_island.Init();
267 CActor* A = smart_cast<CActor*>(m_character->PhysicsRefObject());
268 if (A)
269 {
270 A->SetWeaponHideState(INV_STATE_BLOCK_ALL, true, true);
271 m_hard_mode = true;
272 }
273 else if (!m_hard_mode)
274 m_hard_mode = false;
275
276 ps->applyForce(0, m_pull_force, 0);
277}
278
279void CPHCapture::Release()
280{

Callers

nothing calls this directly

Calls 11

SetWeaponHideStateMethod · 0.80
subMethod · 0.45
r_floatMethod · 0.45
magnitudeMethod · 0.45
r_u32Method · 0.45
getMassMethod · 0.45
set_DynamicLimitsMethod · 0.45
PhysicsRefObjectMethod · 0.45
applyForceMethod · 0.45

Tested by

no test coverage detected