Exemplo n.º 1
0
    public static SlotSettings FromJSON(string json, ArtRegistry reg)
    {
        Dictionary <string, string> tmp = Serial.DictFromJSON(json);
        int         slotNumber          = Int32.Parse(tmp["SlotNumber"]);
        ArtMetaData metaData            = reg.Get(Checksum.FromString(tmp["Checksum"]));

        return(new SlotSettings(slotNumber, metaData));
    }
Exemplo n.º 2
0
    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);
        }
    }
Exemplo n.º 3
0
    private byte[] getAssetBytes(Checksum checksum)
    {
        ArtRegistry artReg = AppSettings.GetAppSettings().ArtRegistry;

        return(Util.ZipAsset(artReg.Get(checksum)));
    }