Mercurial > fife-parpg
comparison engine/core/model/structures/instance.cpp @ 348:48c38e92e2bd
Added Instance::setActionRuntime() as requested in Ticket #373
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 03 Sep 2009 23:09:57 +0000 |
parents | 0fd74235b34d |
children | 16c2b3ee59ce |
comparison
equal
deleted
inserted
replaced
347:7fa5451d685d | 348:48c38e92e2bd |
---|---|
52 m_action(NULL), | 52 m_action(NULL), |
53 m_target(NULL), | 53 m_target(NULL), |
54 m_speed(0), | 54 m_speed(0), |
55 m_repeating(false), | 55 m_repeating(false), |
56 m_action_start_time(0), | 56 m_action_start_time(0), |
57 m_action_offset_time(0), | |
57 m_prev_call_time(0), | 58 m_prev_call_time(0), |
58 m_pather_session_id(-1), | 59 m_pather_session_id(-1), |
59 m_pather(pather), | 60 m_pather(pather), |
60 m_leader(NULL) {} | 61 m_leader(NULL) {} |
61 | 62 |
75 double m_speed; | 76 double m_speed; |
76 // should action be repeated? used only for non-moving actions, moving ones repeat until movement is finished | 77 // should action be repeated? used only for non-moving actions, moving ones repeat until movement is finished |
77 bool m_repeating; | 78 bool m_repeating; |
78 // action start time (ticks) | 79 // action start time (ticks) |
79 unsigned int m_action_start_time; | 80 unsigned int m_action_start_time; |
81 // action offset time (ticks) for resuming an action | |
82 unsigned int m_action_offset_time; | |
80 // ticks since last call | 83 // ticks since last call |
81 unsigned int m_prev_call_time; | 84 unsigned int m_prev_call_time; |
82 // session id for pather | 85 // session id for pather |
83 int m_pather_session_id; | 86 int m_pather_session_id; |
84 // pather | 87 // pather |
381 FL_DBG(_log, "movement finished"); | 384 FL_DBG(_log, "movement finished"); |
382 finalizeAction(); | 385 finalizeAction(); |
383 } | 386 } |
384 } else { | 387 } else { |
385 FL_DBG(_log, "action does not contain target for movement"); | 388 FL_DBG(_log, "action does not contain target for movement"); |
386 if (m_activity->m_timeprovider->getGameTime() - info->m_action_start_time >= info->m_action->getDuration()) { | 389 if (m_activity->m_timeprovider->getGameTime() - info->m_action_start_time + info->m_action_offset_time >= info->m_action->getDuration()) { |
387 if (info->m_repeating) { | 390 if (info->m_repeating) { |
388 info->m_action_start_time = m_activity->m_timeprovider->getGameTime(); | 391 info->m_action_start_time = m_activity->m_timeprovider->getGameTime(); |
392 // prock: offset no longer needed | |
393 info->m_action_offset_time = 0; | |
389 } else { | 394 } else { |
390 finalizeAction(); | 395 finalizeAction(); |
391 } | 396 } |
392 } | 397 } |
393 } | 398 } |
469 | 474 |
470 unsigned int Instance::getActionRuntime() { | 475 unsigned int Instance::getActionRuntime() { |
471 if (m_activity && m_activity->m_actioninfo) { | 476 if (m_activity && m_activity->m_actioninfo) { |
472 if(!m_activity->m_timeprovider) | 477 if(!m_activity->m_timeprovider) |
473 bindTimeProvider(); | 478 bindTimeProvider(); |
474 return m_activity->m_timeprovider->getGameTime() - m_activity->m_actioninfo->m_action_start_time; | 479 return m_activity->m_timeprovider->getGameTime() - m_activity->m_actioninfo->m_action_start_time + m_activity->m_actioninfo->m_action_offset_time; |
475 } | 480 } |
476 return getRuntime(); | 481 return getRuntime(); |
482 } | |
483 | |
484 void Instance::setActionRuntime(unsigned int time_offset) { | |
485 m_activity->m_actioninfo->m_action_offset_time = time_offset; | |
477 } | 486 } |
478 | 487 |
479 void Instance::bindTimeProvider() { | 488 void Instance::bindTimeProvider() { |
480 float multiplier = 1.0; | 489 float multiplier = 1.0; |
481 if (m_activity->m_timeprovider) { | 490 if (m_activity->m_timeprovider) { |