MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Save

Method Save

Source/Engine/Engine/GameplayGlobals.cpp:107–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105#if USE_EDITOR
106
107bool GameplayGlobals::Save(const StringView& path)
108{
109 if (OnCheckSave(path))
110 return true;
111 ScopeLock lock(Locker);
112
113 // Save to bytes
114 MemoryWriteStream stream(1024);
115 stream.Write(Variables.Count());
116 for (auto& e : Variables)
117 {
118 stream.Write(e.Key, 71);
119 stream.Write(e.Value.DefaultValue);
120 }
121
122 // Set chunk data
123 FlaxChunk* chunk;
124 if (IsVirtual())
125 {
126 _header.Chunks[0] = chunk = New<FlaxChunk>();
127 }
128 else
129 {
130 chunk = GetOrCreateChunk(0);
131 }
132 chunk->Data.Copy(ToSpan(stream));
133
134 // Save
135 AssetInitData data;
136 data.SerializedVersion = SerializedVersion;
137 const bool saveResult = path.HasChars() ? SaveAsset(path, data) : SaveAsset(data, true);
138 if (IsVirtual())
139 {
140 _header.Chunks[0] = nullptr;
141 Delete(chunk);
142 }
143 if (saveResult)
144 {
145 LOG(Error, "Cannot save \'{0}\'", ToString());
146 return true;
147 }
148
149 return false;
150}
151
152#endif
153

Callers

nothing calls this directly

Calls 8

IsVirtualFunction · 0.85
DeleteFunction · 0.85
ToSpanFunction · 0.50
ToStringFunction · 0.50
WriteMethod · 0.45
CountMethod · 0.45
CopyMethod · 0.45
HasCharsMethod · 0.45

Tested by

no test coverage detected