| 159 | } |
| 160 | |
| 161 | Asset::LoadResult GameplayGlobals::load() |
| 162 | { |
| 163 | // Get data |
| 164 | const auto chunk = GetChunk(0); |
| 165 | if (!chunk || !chunk->IsLoaded()) |
| 166 | return LoadResult::MissingDataChunk; |
| 167 | MemoryReadStream stream(chunk->Get(), chunk->Size()); |
| 168 | |
| 169 | // Load all variables |
| 170 | int32 count; |
| 171 | stream.Read(count); |
| 172 | Variables.EnsureCapacity(count); |
| 173 | String name; |
| 174 | for (int32 i = 0; i < count; i++) |
| 175 | { |
| 176 | stream.Read(name, 71); |
| 177 | auto& e = Variables[name]; |
| 178 | stream.Read(e.DefaultValue); |
| 179 | e.Value = e.DefaultValue; |
| 180 | } |
| 181 | if (stream.HasError()) |
| 182 | { |
| 183 | // Failed to load data |
| 184 | Variables.Clear(); |
| 185 | return LoadResult::InvalidData; |
| 186 | } |
| 187 | |
| 188 | return LoadResult::Ok; |
| 189 | } |
| 190 | |
| 191 | void GameplayGlobals::unload(bool isReloading) |
| 192 | { |