//-------------------------------------------- void CLaser::TurnOnLaser(bool manual /*= false*/) { CWeapon* pParentWeapon = GetWeapon(); if(pParentWeapon == NULL) return; m_laserHelperFP.clear(); const SAccessoryParams *params = GetWeapon()->GetAccessoryParams(GetEntity()->GetClass()); if (params) m_laserHelperFP = params->attach_helper; int slot = pParentWeapon->IsOwnerFP() ? eIGS_FirstPerson: eIGS_ThirdPerson; CActor* pOwner = pParentWeapon->GetOwnerActor(); GetGameObject()->EnableUpdateSlot(this, eIUS_General); if (pOwner && pOwner->IsPlayer()) pParentWeapon->SetFiringLocator(this); m_laserBeam.TurnOnLaser(); //Turn off crosshair if (pParentWeapon->IsOwnerClient()) { pParentWeapon->SetCrosshairMode(CWeapon::eWeaponCrossHair_ForceOff); pParentWeapon->FadeCrosshair(0.0f, g_pGame->GetUI()->GetCVars()->hud_Crosshair_laser_fadeOutTime); } }
//-------------------------------------------- void CLaser::TurnOffLaser(bool manual /*= false*/) { if(!m_laserBeam.IsLaserActivated()) return; GetGameObject()->DisableUpdateSlot(this, eIUS_General); CWeapon* pParentWeapon = GetWeapon(); if(pParentWeapon == NULL) return; bool ownerIsFP = pParentWeapon? pParentWeapon->IsOwnerFP(): false; m_laserBeam.TurnOffLaser(); //Turn on crosshair if (pParentWeapon->IsOwnerClient()) { pParentWeapon->SetCrosshairMode(CWeapon::eWeaponCrossHair_Default); pParentWeapon->FadeCrosshair(1.0f, g_pGame->GetUI()->GetCVars()->hud_Crosshair_laser_fadeInTime); } pParentWeapon->SetFiringLocator(0); }
CLaser::~CLaser() { CWeapon* pWeapon = GetWeapon(); if (pWeapon) pWeapon->SetFiringLocator(0); }