Skip to content

Commit

Permalink
Fix issue with legacy effects not showing in game
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyVR1 committed May 11, 2022
1 parent f042159 commit 37ca1fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
37 changes: 18 additions & 19 deletions PC/BundleLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ public static void LoadDefaultCover()
DefaultTex = Utils.LoadSpriteFromResources("Weather.DefaultCover.png");
}

public static void LoadFromFileAsync(string path, Action<AsyncOperation, string> callback)
private static void LoadFromFileAsync(string path, Action<AsyncOperation, string> callback)
{
if (File.Exists(path))
{
var bundleAsync = AssetBundle.LoadFromFileAsync(path);
bundleAsync.allowSceneActivation = true;
Action<AsyncOperation> action = async => { callback(async, path); };
bundleAsync.completed += action;
}
if (!File.Exists(path)) return;

var bundleAsync = AssetBundle.LoadFromFileAsync(path);
bundleAsync.allowSceneActivation = true;
Action<AsyncOperation> action = async => { callback(async, path); };
bundleAsync.completed += action;
}

public static void Load()
Expand All @@ -52,7 +51,7 @@ public static void Load()
}
}

public static void LoadFromBundle(AsyncOperation bundleRequest, string filePath)
private static void LoadFromBundle(AsyncOperation bundleRequest, string filePath)
{
var bundle = (bundleRequest as AssetBundleCreateRequest).assetBundle;
var json = bundle.LoadAsset<TextAsset>("assets/effectJson.asset");
Expand Down Expand Up @@ -87,21 +86,21 @@ public static void LoadFromBundle(AsyncOperation bundleRequest, string filePath)

try
{
efdTemp = JsonUtility.FromJson<TempDesc012>(json.text);
}
catch
{
try
if (json.text.Contains("WorksInGame"))
{
var efdOld1 = JsonUtility.FromJson<TempDesc011>(json.text);
efdTemp = new TempDesc012(efdOld1.Author, efdOld1.EffectName, efdOld1.WorksInMenu, true);
efdTemp = JsonUtility.FromJson<TempDesc012>(json.text);
}
catch
else
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
Plugin.Log.Error($"{fileName} Failed To Load! Json: {json.text}");
var efdOld1 = JsonUtility.FromJson<TempDesc011>(json.text);
efdTemp = new TempDesc012(efdOld1.Author, efdOld1.EffectName, efdOld1.WorksInMenu, true);
}
}
catch
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
Plugin.Log.Error($"{fileName} Failed To Load! Json: {json.text}");
}

var efd = eff.AddComponent<EffectDescriptor>();
efd.author = efdTemp.Author;
Expand Down
2 changes: 1 addition & 1 deletion PC/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void MenuSceneActive()
BundleLoader.WeatherPrefab.GetComponent<WeatherSceneInfo>().SetActiveRefs();
}

private void GameSceneActive()
private static void GameSceneActive()
{
WeatherSceneInfo.CurrentScene = SceneManager.GetSceneByName(Game);
BundleLoader.WeatherPrefab.GetComponent<WeatherSceneInfo>().SetActiveRefs();
Expand Down
5 changes: 3 additions & 2 deletions PC/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"id": "Weather",
"name": "Weather",
"author": "FutureMapper",
"version": "0.3.0",
"version": "0.3.1",
"description": "",
"gameVersion": "1.22.0",
"dependsOn": {
"BSIPA": "^4.2.2"
"BSIPA": "^4.2.2",
"SiraUtil": "^3.0.6"
},
"features": []
}

0 comments on commit 37ca1fa

Please sign in to comment.