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

Method Initialize

Source/Game/scriptablecampaign.cpp:60–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60void ScriptableCampaign::Initialize(Path script_path, std::string _campaign_id) {
61 campaign_id = _campaign_id;
62
63 ASData as_data;
64
65 as_context = new ASContext("scriptable_campaign", as_data);
66
67 as_context->RegisterGlobalFunction("void SendLevelMessage(const string& in msg)", asFUNCTION(ASSendLevelMessage), asCALL_CDECL);
68
69 AttachLevelSet(as_context);
70 AttachLevelXML(as_context);
71 AttachUIQueries(as_context);
72 AttachTokenIterator(as_context);
73 AttachSimpleFile(as_context);
74 AttachInterlevelData(as_context);
75 AttachEngine(as_context);
76 AttachOnline(as_context);
77
78 AttachSaveFile(as_context, &Engine::Instance()->save_file_);
79
80 as_funcs.init = as_context->RegisterExpectedFunction("void Init()", false);
81 as_funcs.receive_message = as_context->RegisterExpectedFunction("void ReceiveMessage(string)", false);
82 as_funcs.set_window_dimensions = as_context->RegisterExpectedFunction("void SetWindowDimensions(int width, int height)", false);
83
84 as_funcs.update = as_context->RegisterExpectedFunction("void Update()", true);
85 as_funcs.dispose = as_context->RegisterExpectedFunction("void Dispose()", true);
86 as_funcs.enter_campaign = as_context->RegisterExpectedFunction("void EnterCampaign()", true);
87 as_funcs.enter_level = as_context->RegisterExpectedFunction("void EnterLevel()", true);
88 as_funcs.leave_campaign = as_context->RegisterExpectedFunction("void LeaveCampaign()", true);
89 as_funcs.leave_level = as_context->RegisterExpectedFunction("void LeaveLevel()", true);
90
91 char path[kPathSize];
92 FormatString(path, kPathSize, "%sasscriptable_campaign_docs.h", GetWritePath(CoreGameModID).c_str());
93 as_context->ExportDocs(path);
94
95 // Load script and run init function
96 as_context->LoadScript(script_path);
97
98 as_context->CallScriptFunction(as_funcs.init);
99}
100
101void ScriptableCampaign::Dispose() {
102 as_context->CallScriptFunction(as_funcs.dispose);

Callers

nothing calls this directly

Calls 15

AttachLevelSetFunction · 0.85
AttachLevelXMLFunction · 0.85
AttachUIQueriesFunction · 0.85
AttachTokenIteratorFunction · 0.85
AttachSimpleFileFunction · 0.85
AttachInterlevelDataFunction · 0.85
AttachEngineFunction · 0.85
AttachOnlineFunction · 0.85
AttachSaveFileFunction · 0.85
FormatStringFunction · 0.85
GetWritePathFunction · 0.85

Tested by

no test coverage detected