public void SaveToWorld(BinaryWriter writer) { foreach (KeyValuePair <ushort, ICreativePower> item in _powersById) { IPersistentPerWorldContent persistentPerWorldContent = item.Value as IPersistentPerWorldContent; if (persistentPerWorldContent != null) { writer.Write(value: true); writer.Write(item.Key); persistentPerWorldContent.Save(writer); } } writer.Write(value: false); }
public void ValidateWorld(BinaryReader reader, int versionGameWasLastSavedOn) { while (reader.ReadBoolean()) { ushort key = reader.ReadUInt16(); if (_powersById.TryGetValue(key, out ICreativePower value)) { IPersistentPerWorldContent persistentPerWorldContent = value as IPersistentPerWorldContent; if (persistentPerWorldContent != null) { persistentPerWorldContent.ValidateWorld(reader, versionGameWasLastSavedOn); continue; } break; } break; } }