private void ReceiveManifestRPC(byte[] manifest) { // XXX: For testing. Simulate that client has no art assets. //artReg = ArtRegistry.GetEmptyArtRegistry(); ArtManifest artManifest = Serial.DeserializeByteArray <ArtManifest>(manifest); slotSettings = new Dictionary <Checksum, SlotSettings>(); List <Checksum> missing = new List <Checksum>(); foreach (SlotSettings slot in artManifest.Slots) { SlotSettings ss = slot; Checksum checksum = slot.MetaData.Checksum; if (artReg.HasArt(checksum)) { Debug.Log("Visitor already has art " + checksum.ToString()); // Use existing meta data from registry. ss = slot.WithMeta(artReg.Get(checksum)); slotSettings.Add(checksum, ss); DisplayArt(ss); } else { ArtMetaData absolute = ss.MetaData.MakeAbsolutePath(root); ss = slot.WithMeta(absolute); slotSettings.Add(ss.MetaData.Checksum, ss); if (alreadyDownloaded(ss.MetaData)) { artReg.AddArt(absolute); DisplayArt(ss); } else { Debug.Log("Visitor does NOT have art " + checksum.ToString()); missing.Add(checksum); // TODO: // instantiate some place holder for missing? } } } if (missing.Count > 0) { RequestArtAssets(missing); } }
public static ArtRegistry Load(string file) { ArtRegistry reg = new ArtRegistry(file); if (!Util.IsFile(file)) { return(reg); } string json = File.ReadAllText(file); Serial.ListFromJSON <ArtMetaData>(json, ArtMetaData.FromJSON).ForEach(art => reg.AddArt(art)); return(reg); }