void FrameTimer::Update(float dt){ class CallUpdate{ float dt; public: CallUpdate(float dt){this->dt = dt;} void operator()(WantFrameUpdate* c){ c->Update(dt); } }; std::for_each(clients.begin(), clients.end(), CallUpdate(dt)); }
void CBridgeHack::Update() { if (pLiftPart && pWeight) { unsigned int timeDifference; float lift; OldState = State; if (!CStats::CommercialPassed) { TimeOfBridgeBecomingOperational = 0; State = 0; // inactive lift = 25.0; } else { if (!TimeOfBridgeBecomingOperational) { TimeOfBridgeBecomingOperational = CTimer::m_snTimeInMilliseconds; } timeDifference = (CTimer::m_snTimeInMilliseconds - TimeOfBridgeBecomingOperational) & 0xFFFF; if (timeDifference < 10000) { State = 2; // moving down lift = 25.0f - static_cast<float>(timeDifference) * 25.0f * 0.0001f; } else if (timeDifference < 40000) { State = 3; // fully closed lift = 0.0; } else if (timeDifference < 50000) { State = 4; // ready to move up lift = 0.0; } else if (timeDifference < 60000) { State = 5; // moving up lift = static_cast<float>(timeDifference - 50000) * 25.0f * 0.0001f; } else { State = 1; // fully opened lift = 25.0; } } if (lift != OldLift) { pWeight->GetZ() = DefaultZLiftWeight - lift; pWeight->GetMatrix().UpdateRW(); pWeight->UpdateRwFrame(); if (pLiftRoad) { pLiftRoad->GetZ() = DefaultZLiftRoad + lift; pLiftRoad->GetMatrix().UpdateRW(); pLiftRoad->UpdateRwFrame(); } pLiftPart->GetZ() = DefaultZLiftPart + lift; pLiftPart->GetMatrix().UpdateRW(); pLiftPart->UpdateRwFrame(); // additional objects if (pLodWeight) { pLodWeight->GetZ() = DefaultZLiftWeight - lift; pLodWeight->GetMatrix().UpdateRW(); pLodWeight->UpdateRwFrame(); } if (pLodLiftPart) { pLodLiftPart->GetZ() = DefaultZLiftPart + lift; pLodLiftPart->GetMatrix().UpdateRW(); pLodLiftPart->UpdateRwFrame(); } OldLift = lift; } //if (State == 4 && OldState == 3) { //} else if (State == 3 && OldState == 2) { //} } CallUpdate(); }