MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ChangeControlScript

Method ChangeControlScript

Source/Objects/movementobject.cpp:4513–4535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4511}
4512
4513void 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
4537void MovementObject::SetRotationFromEditorTransform() {
4538 vec3 dir = (transform_ * vec4(0.0f, 0.0f, 1.0f, 0.0f)).xyz();

Callers 4

InitializeMethod · 0.80
UpdateMethod · 0.80
DrawObjectInfoFlatFunction · 0.80
DrawImGuiFunction · 0.80

Calls 13

FindFilePathFunction · 0.85
AssemblePathFunction · 0.85
maxFunction · 0.85
DisplayFormatMessageFunction · 0.85
LoadScriptMethod · 0.80
GetPCScriptMethod · 0.80
SetAnimUpdatePeriodMethod · 0.80
c_strMethod · 0.45
isValidMethod · 0.45
getMethod · 0.45
SaveGlobalVarsMethod · 0.45
LoadGlobalVarsMethod · 0.45

Tested by

no test coverage detected