Esempio n. 1
0
        public static ProtoResult BuildProto(string srcDir)
        {
            ProtoResult result = new ProtoResult();
            var         files  = Directory.GetFiles(srcDir, "*.sdp", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                ProtoParser.ParseFile(file, result);
            }
            ProtoCheck.Check(result);
            return(result);
        }
Esempio n. 2
0
        private static void TestForMigration()
        {
            //TODO: tie this into game intialization loop instead of disparate like it is here
            //TODO: use datastores as part of game init rather than parallel route
            var buildInfo         = new BuildInfoDatastore();
            var lastKnownItemHash = buildInfo.Get(BuildInfoDatastore.Keys.ITEM_DATA_VERSION);
            var currentHash       = GetItemDataHash();

            bool needsMigration = lastKnownItemHash != currentHash;

            Debug.Log($"TestForMigration last hash {lastKnownItemHash} current hash {currentHash} need migration {needsMigration}");
            //TODO: editor pref for migration re-running
            if (needsMigration)
            {
                Debug.LogWarning("Data needed Migration");
                var playerDataBytes = new BinaryDatastore().GetData(BinaryDatastore.Keys.PlayerData);
                if (playerDataBytes == null)
                {
                    return;
                }
                try
                {
                    var playerData = new ProtoParser().Parse <PlayerData>(playerDataBytes);
                    //current migration deals with color data
                    var colorMigration = new ColorMigration();
                    foreach (var item in playerData.Items)
                    {
                        foreach (var artAsset in item.ArtAssets)
                        {
                            if (artAsset.Color != null)
                            {
                                artAsset.ColorNew = colorMigration.UpgradeColor(artAsset.Color);
                            }
                        }
                    }
                    //now set item version string to indicate that we've upgraded
#if UNITY_EDITOR
                    buildInfo.Set(BuildInfoDatastore.Keys.ITEM_DATA_VERSION, GetItemDataHash());
                    Debug.Log($"Migration successful to new item data version {GetItemDataHash()}");
#endif
                }
                catch (Exception e)
                {
                    Debug.LogError($"Migraiton failed {e.Message} stack{e.StackTrace}");
                }
            }
        }