Scripting refactor : add new property animator helper, transfer light animations to this new animator class. Can be used in the future to animate more properties
This commit is contained in:
parent
ea581e0909
commit
2252495fdc
@ -57,6 +57,7 @@
|
|||||||
#include "modes/profile_world.hpp"
|
#include "modes/profile_world.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "physics/physics.hpp"
|
#include "physics/physics.hpp"
|
||||||
|
#include "scriptengine/property_animator.hpp"
|
||||||
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
|
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "tracks/track_manager.hpp"
|
#include "tracks/track_manager.hpp"
|
||||||
@ -2153,6 +2154,8 @@ void IrrDriver::update(float dt)
|
|||||||
|
|
||||||
m_wind->update();
|
m_wind->update();
|
||||||
|
|
||||||
|
PropertyAnimator::get()->update(dt);
|
||||||
|
|
||||||
World *world = World::getWorld();
|
World *world = World::getWorld();
|
||||||
|
|
||||||
if (GUIEngine::getCurrentScreen() != NULL &&
|
if (GUIEngine::getCurrentScreen() != NULL &&
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "network/protocol_manager.hpp"
|
#include "network/protocol_manager.hpp"
|
||||||
#include "network/network_world.hpp"
|
#include "network/network_world.hpp"
|
||||||
#include "network/protocols/start_game_protocol.hpp"
|
#include "network/protocols/start_game_protocol.hpp"
|
||||||
|
#include "scriptengine/property_animator.hpp"
|
||||||
#include "states_screens/grand_prix_cutscene.hpp"
|
#include "states_screens/grand_prix_cutscene.hpp"
|
||||||
#include "states_screens/grand_prix_lose.hpp"
|
#include "states_screens/grand_prix_lose.hpp"
|
||||||
#include "states_screens/grand_prix_win.hpp"
|
#include "states_screens/grand_prix_win.hpp"
|
||||||
@ -520,6 +521,7 @@ void RaceManager::startNextRace()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void RaceManager::next()
|
void RaceManager::next()
|
||||||
{
|
{
|
||||||
|
PropertyAnimator::get()->clear();
|
||||||
World::deleteWorld();
|
World::deleteWorld();
|
||||||
m_num_finished_karts = 0;
|
m_num_finished_karts = 0;
|
||||||
m_num_finished_players = 0;
|
m_num_finished_players = 0;
|
||||||
@ -720,7 +722,11 @@ void RaceManager::exitRace(bool delete_world)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delete_world) World::deleteWorld();
|
if (delete_world)
|
||||||
|
{
|
||||||
|
PropertyAnimator::get()->clear();
|
||||||
|
World::deleteWorld();
|
||||||
|
}
|
||||||
delete_world = false;
|
delete_world = false;
|
||||||
|
|
||||||
StateManager::get()->enterGameState();
|
StateManager::get()->enterGameState();
|
||||||
@ -757,7 +763,11 @@ void RaceManager::exitRace(bool delete_world)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delete_world) World::deleteWorld();
|
if (delete_world)
|
||||||
|
{
|
||||||
|
PropertyAnimator::get()->clear();
|
||||||
|
World::deleteWorld();
|
||||||
|
}
|
||||||
|
|
||||||
m_saved_gp = NULL;
|
m_saved_gp = NULL;
|
||||||
m_track_number = 0;
|
m_track_number = 0;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "input/input_device.hpp"
|
#include "input/input_device.hpp"
|
||||||
#include "input/input_manager.hpp"
|
#include "input/input_manager.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
#include "scriptengine/property_animator.hpp"
|
||||||
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
||||||
#include "states_screens/dialogs/race_paused_dialog.hpp"
|
#include "states_screens/dialogs/race_paused_dialog.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
@ -230,7 +231,11 @@ namespace Scripting
|
|||||||
|
|
||||||
void animateEnergy(float energy, float duration, /** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
|
void animateEnergy(float energy, float duration, /** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
|
||||||
{
|
{
|
||||||
((TrackObjectPresentationLight*)memory)->setEnergy(energy, duration);
|
TrackObjectPresentationLight* light = ((TrackObjectPresentationLight*)memory);
|
||||||
|
PropertyAnimator::get()->add(
|
||||||
|
new AnimatedProperty(AP_LIGHT_ENERGY, light->getEnergy(), energy, duration, light)
|
||||||
|
);
|
||||||
|
//((TrackObjectPresentationLight*)memory)->setEnergy(energy, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "modes/soccer_world.hpp"
|
#include "modes/soccer_world.hpp"
|
||||||
#include "modes/world_with_rank.hpp"
|
#include "modes/world_with_rank.hpp"
|
||||||
#include "race/highscores.hpp"
|
#include "race/highscores.hpp"
|
||||||
|
#include "scriptengine/property_animator.hpp"
|
||||||
#include "states_screens/feature_unlocked.hpp"
|
#include "states_screens/feature_unlocked.hpp"
|
||||||
#include "states_screens/main_menu_screen.hpp"
|
#include "states_screens/main_menu_screen.hpp"
|
||||||
#include "states_screens/networking_lobby.hpp"
|
#include "states_screens/networking_lobby.hpp"
|
||||||
@ -270,6 +271,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
|||||||
|
|
||||||
// kart will no longer be available during cutscene, drop reference
|
// kart will no longer be available during cutscene, drop reference
|
||||||
StateManager::get()->getActivePlayer(playerID)->setKart(NULL);
|
StateManager::get()->getActivePlayer(playerID)->setKart(NULL);
|
||||||
|
PropertyAnimator::get()->clear();
|
||||||
World::deleteWorld();
|
World::deleteWorld();
|
||||||
|
|
||||||
CutsceneWorld::setUseDuration(true);
|
CutsceneWorld::setUseDuration(true);
|
||||||
@ -287,6 +289,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StateManager::get()->popMenu();
|
StateManager::get()->popMenu();
|
||||||
|
PropertyAnimator::get()->clear();
|
||||||
World::deleteWorld();
|
World::deleteWorld();
|
||||||
|
|
||||||
CutsceneWorld::setUseDuration(false);
|
CutsceneWorld::setUseDuration(false);
|
||||||
|
@ -967,11 +967,6 @@ TrackObjectPresentationLight::TrackObjectPresentationLight(
|
|||||||
{
|
{
|
||||||
m_node = NULL; // lights require shaders to work
|
m_node = NULL; // lights require shaders to work
|
||||||
}
|
}
|
||||||
|
|
||||||
m_energy_animation_from = 0.0f;
|
|
||||||
m_energy_animation_to = 0.0f;
|
|
||||||
m_energy_animation_total_duration = 0.0f;
|
|
||||||
m_energy_animation_remaining_duration = 0.0f;
|
|
||||||
} // TrackObjectPresentationLight
|
} // TrackObjectPresentationLight
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -989,29 +984,6 @@ void TrackObjectPresentationLight::setEnergy(float energy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void TrackObjectPresentationLight::setEnergy(float energy, float duration)
|
|
||||||
{
|
|
||||||
m_energy_animation_from = m_energy;
|
|
||||||
m_energy_animation_to = energy;
|
|
||||||
m_energy_animation_total_duration = duration;
|
|
||||||
m_energy_animation_remaining_duration = duration;
|
|
||||||
}
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
void TrackObjectPresentationLight::update(float dt)
|
|
||||||
{
|
|
||||||
if (m_energy_animation_remaining_duration > 0.0f)
|
|
||||||
{
|
|
||||||
m_energy_animation_remaining_duration -= dt;
|
|
||||||
if (m_energy_animation_remaining_duration < 0.0f)
|
|
||||||
m_energy_animation_remaining_duration = 0.0f;
|
|
||||||
|
|
||||||
float ratio = m_energy_animation_remaining_duration / m_energy_animation_total_duration;
|
|
||||||
|
|
||||||
setEnergy(m_energy_animation_from +
|
|
||||||
(m_energy_animation_to - m_energy_animation_from)*(1.0f - ratio));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
|
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
|
||||||
const XMLNode& xml_node)
|
const XMLNode& xml_node)
|
||||||
: TrackObjectPresentation(xml_node)
|
: TrackObjectPresentation(xml_node)
|
||||||
|
@ -354,19 +354,12 @@ private:
|
|||||||
video::SColor m_color;
|
video::SColor m_color;
|
||||||
float m_distance;
|
float m_distance;
|
||||||
float m_energy;
|
float m_energy;
|
||||||
|
|
||||||
float m_energy_animation_from;
|
|
||||||
float m_energy_animation_to;
|
|
||||||
float m_energy_animation_total_duration;
|
|
||||||
float m_energy_animation_remaining_duration;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackObjectPresentationLight(const XMLNode& xml_node,
|
TrackObjectPresentationLight(const XMLNode& xml_node,
|
||||||
scene::ISceneNode* parent);
|
scene::ISceneNode* parent);
|
||||||
virtual ~TrackObjectPresentationLight();
|
virtual ~TrackObjectPresentationLight();
|
||||||
|
float getEnergy() const { return m_energy; }
|
||||||
void setEnergy(float energy);
|
void setEnergy(float energy);
|
||||||
void setEnergy(float energy, float duration);
|
|
||||||
virtual void update(float dt) OVERRIDE;
|
|
||||||
}; // TrackObjectPresentationLight
|
}; // TrackObjectPresentationLight
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user