void AMyActor::OnOverlapEnd(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) { if (OtherActor && (OtherActor != this) && OtherComp) { ToggleLight(); } }
void AMyActor::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { if (OtherActor && (OtherActor != this) && OtherComp) { ToggleLight(); } }
void CVehiclePartPulsingLight::OnEvent( const SVehiclePartEvent& event ) { if (event.type == eVPE_Damaged) { if(event.fparam < 1.0f) { if(m_toggleOnMinDamageRatio && !IsEnabled() && event.fparam >= m_toggleOnMinDamageRatio) { ToggleLight(true); m_currentColorMultSpeed = m_colorMultSpeed; } else if(m_toggleStageTwoMinDamageRatio && event.fparam >= m_toggleStageTwoMinDamageRatio) { m_currentColorMultSpeed = m_colorMultSpeedStageTwo; } } else //fParam >= 1.f (Vehicle destroyed) { ToggleLight(false); } } CVehiclePartLight::OnEvent(event); }
//------------------------------------------------------------------------ void CVehiclePartLight::Serialize(TSerialize ser, EEntityAspects aspects) { CVehiclePartBase::Serialize(ser, aspects); if (ser.GetSerializationTarget()!=eST_Network) { bool isEnabled = IsEnabled(); ser.Value("lightEnabled", isEnabled, 'bool'); if (ser.IsReading()) { ToggleLight(isEnabled); } } }
//------------------------------------------------------------------------ void CVehiclePartLight::OnEvent(const SVehiclePartEvent& event) { if (event.type == eVPE_Damaged) { if (event.fparam >= 1.0f) { float dmg = 1.f / max(1.f,(float)m_components.size()); m_damageRatio += dmg; if (m_damageRatio >= 1.f && IsEnabled()) ToggleLight(false); } } else { CVehiclePartBase::OnEvent(event); } }
// ----------------------------------------------------------------------- // // // ROUTINE: LightFX::HandleTrigger() // // PURPOSE: Called when triggered. // // ----------------------------------------------------------------------- // void LightFX::HandleTrigger( HOBJECT hSender, HMESSAGEREAD hRead ) { HSTRING hMsg = g_pServerDE->ReadFromMessageHString(hRead); char *pszMessage = g_pServerDE->GetStringData( hMsg ); if ( _mbsncmp((const unsigned char*)pszMessage, (const unsigned char*)"SWITCH", 6) == 0) { ToggleLight(); } else if ( _mbsncmp((const unsigned char*)pszMessage, (const unsigned char*)"ON", 2) == 0) { TurnOn(); } else if ( _mbsncmp((const unsigned char*)pszMessage, (const unsigned char*)"OFF", 3) == 0) { TurnOff(); } g_pServerDE->FreeString( hMsg ); }
//------------------------------------------------------------------------ void CVehiclePartLight::PostInit() { m_pHelper = m_pVehicle->GetHelper(m_pSharedParameters->m_helperPosName.c_str()); // get Components this Part belongs to. // currently that's only needed for Lights. for (int i=0,nComps=m_pVehicle->GetComponentCount(); i<nComps; ++i) { IVehicleComponent* pComponent = m_pVehicle->GetComponent(i); for (int j=0,nParts=pComponent->GetPartCount(); j<nParts; ++j) { if (pComponent->GetPart(j) == this) { m_components.push_back(pComponent); break; } } } if (VehicleCVars().v_lights_enable_always) ToggleLight(true); }
//------------------------------------------------------------------------ void CVehiclePartLight::Reset() { CVehiclePartBase::Reset(); ToggleLight(false); }
//------------------------------------------------------------------------ CVehiclePartLight::~CVehiclePartLight() { ToggleLight(false); }
void Animation::enableLights(bool enable) { std::for_each(mObjectRoot->mLights.begin(), mObjectRoot->mLights.end(), ToggleLight(enable)); }