@@ -5354,15 +5354,8 @@ std::vector<double> interpolate(double start, double end, double duration, const
5354
5354
}
5355
5355
5356
5356
bool Game_Interpreter::CommandEasyRpgAnimateVariable (lcf::rpg::EventCommand const & com) {
5357
- // CommandInterpolateVariable ("typeStart/typeEnd",[useVarTarget, target, useVarStart, start, useVarEnd, end, useVarDuration, duration])
5357
+ // $InterpolateVariable ("typeStart/typeEnd",[useVarTarget, target, useVarStart, start, useVarEnd, end, useVarDuration, duration])
5358
5358
5359
- auto * frame = GetFramePtr ();
5360
- const auto & list = frame->commands ;
5361
- auto & index = frame->current_command ;
5362
-
5363
- int i = frame->current_command + 1 ;
5364
-
5365
- // Extract parameters: target, start, end, and duration for the animation
5366
5359
int32_t target = ValueOrVariable (com.parameters [0 ], com.parameters [1 ]);
5367
5360
int32_t start = ValueOrVariable (com.parameters [2 ], com.parameters [3 ]);
5368
5361
int32_t end = ValueOrVariable (com.parameters [4 ], com.parameters [5 ]);
@@ -5372,13 +5365,12 @@ bool Game_Interpreter::CommandEasyRpgAnimateVariable(lcf::rpg::EventCommand cons
5372
5365
lcf::rpg::EventCommand waitCom;
5373
5366
waitCom.code = int (Cmd::Wait);
5374
5367
5375
- lcf::rpg::EventCommand updateVarCom ;
5376
- updateVarCom .code = int (Cmd::ControlVars);
5377
- std::vector<int32_t > updateVarParams = { 0 , static_cast <int32_t >(target), 0 , 0 , 0 , static_cast <int32_t >(end) };
5378
- updateVarCom .parameters = lcf::DBArray<int32_t >(updateVarParams .begin (), updateVarParams .end ());
5368
+ lcf::rpg::EventCommand animatedCom ;
5369
+ animatedCom .code = int (Cmd::ControlVars);
5370
+ std::vector<int32_t > animatedVarParams = { 0 , static_cast <int32_t >(target), 0 , 0 , 0 , static_cast <int32_t >(end) };
5371
+ animatedCom .parameters = lcf::DBArray<int32_t >(animatedVarParams .begin (), animatedVarParams .end ());
5379
5372
5380
- lcf::rpg::EventCommand branchCom;
5381
- branchCom.code = int (Cmd::ShowChoiceOption);
5373
+ std::vector<lcf::rpg::EventCommand> cmdList;
5382
5374
5383
5375
// Extract easing information
5384
5376
std::string easeStart = ToString (com.string );
@@ -5391,41 +5383,21 @@ bool Game_Interpreter::CommandEasyRpgAnimateVariable(lcf::rpg::EventCommand cons
5391
5383
easeStart = easeStart.substr (0 , pos);
5392
5384
}
5393
5385
5394
- // Check if new commands don't exist in the timeline yet
5395
- if (!(i < frame->commands .size () && frame->commands .at (i).code == int (Cmd::ShowChoiceOption))) {
5396
- // Insert animation commands
5397
- Output::Debug (" inserting animation commands" );
5398
- std::vector<double > interpolatedValues = interpolate (start, end, duration, easeStart, easeEnd);
5399
-
5400
- // Insert ShowChoiceOption command
5401
- // This helps me isolating all the "keyframes" commands inside a nested commands, it also helps to avoid creating a repeated list.
5402
- // It's problematic when "start", "end" and "duration" are variables.
5403
- frame->commands .insert (frame->commands .begin () + i, branchCom);
5404
- i++;
5405
-
5406
- // Insert updateVarCom and waitCom commands for each interpolated value
5407
- for (int value : interpolatedValues) {
5408
- updateVarParams.back () = value;
5409
- updateVarCom.parameters = lcf::DBArray<int32_t >(updateVarParams.begin (), updateVarParams.end ());
5410
- updateVarCom.indent = com.indent + 1 ;
5386
+ // Insert animation commands
5387
+ std::vector<double > interpolatedValues = interpolate (start, end, duration, easeStart, easeEnd);
5411
5388
5412
- frame-> commands . insert (frame-> commands . begin () + i, updateVarCom);
5413
- i++;
5414
- frame-> commands . insert (frame-> commands . begin () + i, waitCom) ;
5415
- i++ ;
5416
- }
5389
+ // Insert animatedCom and waitCom commands for each interpolated value
5390
+ for ( int value : interpolatedValues) {
5391
+ animatedVarParams. back () = value ;
5392
+ animatedCom. parameters = lcf::DBArray< int32_t >(animatedVarParams. begin (), animatedVarParams. end ()) ;
5393
+ animatedCom. indent = com. indent + 1 ;
5417
5394
5418
- // Insert ShowChoiceEnd command
5419
- branchCom.code = int (Cmd::ShowChoiceEnd);
5420
- frame->commands .insert (frame->commands .begin () + i, branchCom);
5421
- i++;
5422
- }
5423
- else {
5424
- Output::Debug (" Animated Commands Already Exists" );
5395
+ cmdList.push_back (animatedCom);
5396
+ cmdList.push_back (waitCom);
5425
5397
}
5426
5398
5427
5399
// Update current_command index and return true to indicate success
5428
- frame-> current_command = index + 2 ;
5429
- return false ;
5400
+ Push (cmdList, 0 , false ) ;
5401
+ return true ;
5430
5402
}
5431
5403
0 commit comments