| 4511 | } |
| 4512 | |
| 4513 | void MovementObject::ChangeControlScript(const std::string& script_path) { |
| 4514 | PROFILER_ZONE(g_profiler_ctx, "ChangeControlScript"); |
| 4515 | if (current_control_script_path != script_path) { |
| 4516 | Path found_path = FindFilePath(AssemblePath(script_dir_path, script_path.c_str()), kDataPaths | kModPaths); |
| 4517 | if (found_path.isValid()) { |
| 4518 | current_control_script_path = script_path; |
| 4519 | if (as_context.get()) { |
| 4520 | as_context->SaveGlobalVars(); |
| 4521 | as_context->LoadScript(found_path); |
| 4522 | as_context->LoadGlobalVars(); |
| 4523 | update_script_period = (script_path == scenegraph_->level->GetPCScript(this)) ? 1 : 4; |
| 4524 | update_script_counter = rand() % update_script_period - update_script_period; |
| 4525 | rigged_object_->SetAnimUpdatePeriod(max(2, update_script_period)); |
| 4526 | as_context->CallScriptFunction(as_funcs.script_swap); |
| 4527 | } |
| 4528 | } else { |
| 4529 | DisplayFormatMessage("Cannot find file", "Cannot change to script file \"%s\" because it couldn't be found", script_path.c_str()); |
| 4530 | } |
| 4531 | if (script_path == "playermpcontrol.as" || script_path == "remotecontrol.as") { |
| 4532 | InitializeMultiplayer(); |
| 4533 | } |
| 4534 | } |
| 4535 | } |
| 4536 | |
| 4537 | void MovementObject::SetRotationFromEditorTransform() { |
| 4538 | vec3 dir = (transform_ * vec4(0.0f, 0.0f, 1.0f, 0.0f)).xyz(); |
no test coverage detected