Added: #1469 timer implementation to send camera animation steps in service

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 13 years ago
parent 2629c3cf5f
commit 2d3b82ff57

@ -145,15 +145,38 @@ void CCameraAnimationManager::sendAnimation(const NLMISC::CEntityId& eid, const
void CCameraAnimationManager::TCameraAnimInfo::sendAnimationSteps(const NLMISC::CEntityId& eid)
{
// We first send the first step
sendAnimationStep(eid, 0);
// Now we send the other steps after the duration
// We first send the first step, and then the others
sendAnimationStepsFrom(eid, 0);
}
void CCameraAnimationManager::TCameraAnimInfo::sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep)
bool CCameraAnimationManager::TCameraAnimInfo::sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep)
{
// We can send the current step
// We first check if the step exists
if (currentStep < 0 || currentStep >= Steps.size())
return false;
ICameraAnimationStep* step = Steps[currentStep];
// We send the animation step to the client
step->sendAnimationStep(eid);
return true;
}
void CCameraAnimationManager::TCameraAnimInfo::sendAnimationStepsFrom(const NLMISC::CEntityId& eid, int firstStep, TCameraAnimTimerEvent* event)
{
// We send the current step
if (sendAnimationStep(eid, firstStep))
{
if (event == 0)
event = new TCameraAnimTimerEvent(this, firstStep + 1, eid);
else
event->nextStep();
// Now we send the other steps after the duration
//_Timer->reset();
NLMISC::TGameCycle duration = (NLMISC::TGameCycle)(Steps[firstStep]->getDuration() / CTickEventHandler::getGameTimeStep());
_Timer->setRemaining(duration, event);
}
}

@ -21,6 +21,7 @@
#include <string>
#include "camera_animation_manager/camera_animation_step_factory.h"
#include "nel/misc/entity_id.h"
#include "game_share/timer.h"
/************************************************************************/
/* Class that manages the camera animations. (singleton).
@ -60,10 +61,14 @@ private:
/// Class that contains information about an animation
class TCameraAnimInfo
{
private:
class TCameraAnimTimerEvent;
public:
TCameraAnimInfo()
{
Name = "";
_Timer = new CTimer();
}
/// Function called to release the animations
void release()
@ -77,16 +82,25 @@ private:
Steps.clear();
Name = "";
delete _Timer;
}
/// Function called to send the camera animation instruction specified by the current step to the client
void sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep);
/// The function returns false if the animation step does not exist
bool sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep);
/// Function called to send all the camera animation instructions to the client
void sendAnimationSteps(const NLMISC::CEntityId& eid);
/// Function that sends the animation steps from the specified one to the last one
void sendAnimationStepsFrom(const NLMISC::CEntityId& eid, int firstStep, TCameraAnimTimerEvent* event = 0);
std::string Name;
std::vector<ICameraAnimationStep*> Steps;
private:
CTimer* _Timer;
class TCameraAnimTimerEvent: public CTimerEvent
{
public:
@ -98,8 +112,13 @@ private:
// Callback called when the timer finished
void timerCallback(CTimer* owner)
{
// We tell the camera anim info to send the current step
_Infos->sendAnimationStep(_Eid, _Next);
// We tell the camera anim info to send the current step and the next ones
_Infos->sendAnimationStepsFrom(_Eid, _Next, this);
}
void nextStep()
{
_Next++;
}
private:

@ -78,3 +78,8 @@ void ICameraAnimationStep::addModifier(ICameraAnimationModifier* modifier)
{
Modifiers.push_back(modifier);
}
void ICameraAnimationStep::sendAnimationStep(const NLMISC::CEntityId& eid)
{
throw std::exception("The method or operation is not implemented.");
}

@ -40,6 +40,8 @@ public:
/// Function that returns the duration of the step (in seconds)
virtual float getDuration() const = 0;
/// Function that sends the animation step the to client
void sendAnimationStep(const NLMISC::CEntityId& eid);
protected:
// The list of modifiers
std::vector<ICameraAnimationModifier*> Modifiers;

Loading…
Cancel
Save