void CArtefact::shedule_Update (u32 dt) { inherited::shedule_Update (dt); ////////////////////////////////////////////////////////////////////////// // check "fast-mode" border if (H_Parent()) o_switch_2_slow (); else { Fvector center; Center(center); BOOL rendering = (Device.dwFrame==o_render_frame); float cam_distance = Device.vCameraPosition.distance_to(center)-Radius(); if (rendering || (cam_distance < FASTMODE_DISTANCE)) o_switch_2_fast (); else o_switch_2_slow (); } if (!o_fastmode) UpdateWorkload (dt); }
bool CCustomZone::Enable() { if (IsEnabled()) return false; o_switch_2_fast(); for(OBJECT_INFO_VEC_IT it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it) { CGameObject* pObject = (*it).object; if (!pObject) continue; PlayEntranceParticles(pObject); PlayObjectIdleParticles(pObject); } PlayIdleParticles (); return true; };
// called as usual void CCustomZone::shedule_Update(u32 dt) { m_zone_flags.set(eZoneIsActive, FALSE); if (IsEnabled()) { const Fsphere& s = CFORM()->getSphere(); Fvector P; XFORM().transform_tiny (P,s.P); // update feel_touch_update (P,s.R); //пройтись по всем объектам в зоне //и проверить их состояние for(OBJECT_INFO_VEC_IT it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it) { CGameObject* pObject = (*it).object; if (!pObject) continue; CEntityAlive* pEntityAlive = smart_cast<CEntityAlive*>(pObject); SZoneObjectInfo& info = (*it); info.dw_time_in_zone += dt; if((!info.small_object && m_iDisableHitTime != -1 && (int)info.dw_time_in_zone > m_iDisableHitTime) || (info.small_object && m_iDisableHitTimeSmall != -1 && (int)info.dw_time_in_zone > m_iDisableHitTimeSmall)) { if(!pEntityAlive || !pEntityAlive->g_Alive()) info.zone_ignore = true; } if(m_iDisableIdleTime != -1 && (int)info.dw_time_in_zone > m_iDisableIdleTime) { if(!pEntityAlive || !pEntityAlive->g_Alive()) StopObjectIdleParticles( pObject ); } //если есть хотя бы один не дисабленый объект, то //зона считается активной if(info.zone_ignore == false) m_zone_flags.set(eZoneIsActive,TRUE); } if(eZoneStateIdle == m_eZoneState) CheckForAwaking(); inherited::shedule_Update(dt); // check "fast-mode" border float cam_distance = Device.vCameraPosition.distance_to(P)-s.R; if (cam_distance>FASTMODE_DISTANCE && !m_zone_flags.test(eAlwaysFastmode) ) o_switch_2_slow (); else o_switch_2_fast (); if (!m_zone_flags.test(eFastMode)) UpdateWorkload (dt); }; UpdateOnOffState (); if( !IsGameTypeSingle() && Local() ) { if(Device.dwTimeGlobal > m_ttl) DestroyObject (); } }