| 134 | } |
| 135 | |
| 136 | void CutscenePlayer::Process( const SystemEvents& events ) |
| 137 | { |
| 138 | if( script_ == nullptr ) |
| 139 | return; |
| 140 | |
| 141 | const Time current_time= Time::CurrentTime(); |
| 142 | map_state_->Tick( current_time ); |
| 143 | |
| 144 | if( IsFinished() ) |
| 145 | return; |
| 146 | |
| 147 | using CommandType= CutsceneScript::ActionCommand::Type; |
| 148 | |
| 149 | // Count key presses. |
| 150 | unsigned int key_press_events= 0u; |
| 151 | for( const SystemEvent& event : events ) |
| 152 | { |
| 153 | if( event.type == SystemEvent::Type::Key && |
| 154 | event.event.key.pressed ) |
| 155 | { |
| 156 | if( event.event.key.key_code == SystemEvent::KeyEvent::KeyCode::Escape ) |
| 157 | { |
| 158 | // Stop cutscene on escape press. |
| 159 | next_action_index_= script_->commands.size(); |
| 160 | return; |
| 161 | } |
| 162 | else |
| 163 | key_press_events++; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | bool continue_action= false; |
| 168 | if( current_countinuous_command_start_time_.ToSeconds() != 0.0f ) |
| 169 | { |
| 170 | const Time time_since_last_continuous_action= current_time - current_countinuous_command_start_time_; |
| 171 | |
| 172 | PC_ASSERT( next_action_index_ > 0u ); |
| 173 | const CutsceneScript::ActionCommand& command= script_->commands[ next_action_index_ - 1u ]; |
| 174 | |
| 175 | switch( command.type ) |
| 176 | { |
| 177 | case CommandType::None: |
| 178 | case CommandType::Say: |
| 179 | case CommandType::Voice: |
| 180 | case CommandType::WaitKey: |
| 181 | PC_ASSERT(false); |
| 182 | break; |
| 183 | |
| 184 | case CommandType::Delay: |
| 185 | { |
| 186 | const float delay_time= std::atof( command.params[0].c_str() ); |
| 187 | if( delay_time < time_since_last_continuous_action.ToSeconds() ) |
| 188 | continue_action= true; |
| 189 | } |
| 190 | break; |
| 191 | |
| 192 | case CommandType::Setani: |
| 193 | { |
no test coverage detected