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

Method Initialize

Source/Objects/cameraobject.cpp:73–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73bool CameraObject::Initialize() {
74 ASData as_data;
75 as_data.scenegraph = scenegraph_;
76 as_data.gui = scenegraph_->map_editor->gui;
77 as_context = new ASContext("camera_object", as_data);
78 AttachUIQueries(as_context);
79 AttachActiveCamera(as_context);
80 AttachScreenWidth(as_context);
81 AttachPhysics(as_context);
82 AttachEngine(as_context);
83 AttachScenegraph(as_context, scenegraph_);
84 AttachTextCanvasTextureToASContext(as_context);
85 AttachLevel(as_context);
86 AttachInterlevelData(as_context);
87 AttachMessages(as_context);
88 AttachTokenIterator(as_context);
89 AttachStringConvert(as_context);
90 AttachOnline(as_context);
91
92 as_collisions = new ASCollisions(scenegraph_);
93 as_collisions->AttachToContext(as_context);
94
95 as_context->RegisterObjectType("CameraObject", 0, asOBJ_REF | asOBJ_NOHANDLE);
96 as_context->RegisterObjectProperty("CameraObject", "vec3 velocity", asOFFSET(CameraObject, velocity));
97 as_context->RegisterObjectProperty("CameraObject", "bool controlled", asOFFSET(CameraObject, controlled));
98 as_context->RegisterObjectProperty("CameraObject", "bool frozen", asOFFSET(CameraObject, frozen));
99 as_context->RegisterObjectProperty("CameraObject", "bool ignore_mouse_input", asOFFSET(CameraObject, ignore_mouse_input));
100 as_context->RegisterObjectProperty("CameraObject", "bool has_position_initialized", asOFFSET(CameraObject, has_position_initialized));
101 as_context->RegisterObjectMethod("CameraObject", "const vec3& GetTranslation()", asMETHOD(CameraObject, GetTranslation), asCALL_THISCALL);
102 as_context->RegisterObjectMethod("CameraObject", "const quaternion& GetRotation()", asMETHOD(CameraObject, GetRotation), asCALL_THISCALL);
103 as_context->RegisterObjectMethod("CameraObject", "void SetTranslation(const vec3 &in vec)", asMETHOD(CameraObject, SetTranslation), asCALL_THISCALL);
104 as_context->RegisterObjectMethod("CameraObject", "void SetRotation(const quaternion &in quat)", asMETHOD(CameraObject, SetRotation), asCALL_THISCALL);
105 as_context->DocsCloseBrace();
106 as_context->RegisterGlobalProperty("CameraObject co", this);
107
108 as_funcs.init = as_context->RegisterExpectedFunction("void Init()", true);
109 as_funcs.frame_selection = as_context->RegisterExpectedFunction("void FrameSelection(bool)", true);
110
111 PROFILER_ENTER(g_profiler_ctx, "Exporting docs");
112 char path[kPathSize];
113 FormatString(path, kPathSize, "%sascameraobject_docs.h", GetWritePath(CoreGameModID).c_str());
114 as_context->ExportDocs(path);
115 PROFILER_LEAVE(g_profiler_ctx);
116
117 Path script_path = FindFilePath(script_dir_path + "cam.as", kDataPaths | kModPaths);
118
119 if (script_path.isValid()) {
120 if (as_context->LoadScript(script_path)) {
121 as_context->CallScriptFunction(as_funcs.init);
122
123 SDL_assert(update_list_entry == -1);
124 update_list_entry = scenegraph_->LinkUpdateObject(this);
125 return true;
126 } else {
127 FatalError("Error", "We don't handle the case of an invalid camera, fix the camera script");
128 return false;
129 }
130 } else {

Callers

nothing calls this directly

Calls 15

AttachUIQueriesFunction · 0.85
AttachActiveCameraFunction · 0.85
AttachScreenWidthFunction · 0.85
AttachPhysicsFunction · 0.85
AttachEngineFunction · 0.85
AttachScenegraphFunction · 0.85
AttachLevelFunction · 0.85
AttachInterlevelDataFunction · 0.85
AttachMessagesFunction · 0.85
AttachTokenIteratorFunction · 0.85
AttachStringConvertFunction · 0.85

Tested by

no test coverage detected