Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Futuremappermydud committed Jun 15, 2021
1 parent 96e1d99 commit dfb4cf9
Show file tree
Hide file tree
Showing 245 changed files with 137,529 additions and 700 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
13 changes: 13 additions & 0 deletions PC/.idea/.idea.Weather.dir/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions PC/.idea/.idea.Weather.dir/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions PC/.idea/.idea.Weather.dir/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions PC/.idea/.idea.Weather.dir/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions PC/.idea/.idea.Weather.dir/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 34 additions & 44 deletions PC/BundleLoader.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
using Object = UnityEngine.Object;
//Update this for each Descriptor update!
Expand All @@ -17,9 +13,9 @@ namespace Weather
/// </summary>
public static class BundleLoader
{
public static GameObject WeatherPrefab = null;
public static List<Effect> effects = new List<Effect>();
public static Sprite DefaultTex = null;
public static GameObject WeatherPrefab;
public static List<Effect> Effects = new List<Effect>();
public static Sprite DefaultTex;

public static void LoadDefaultCover()
{
Expand All @@ -29,9 +25,9 @@ public static bool LoadFromFileAsync(string path, Action<AsyncOperation, string>
{
if (File.Exists(path))
{
AssetBundleCreateRequest bundleAsync = AssetBundle.LoadFromFileAsync(path);
var bundleAsync = AssetBundle.LoadFromFileAsync(path);
bundleAsync.allowSceneActivation = true;
Action<AsyncOperation> action = (AsyncOperation async) => { callback(async, path); };
Action<AsyncOperation> action = async => { callback(async, path); };
bundleAsync.completed += action;
}
else return false;
Expand All @@ -40,31 +36,30 @@ public static bool LoadFromFileAsync(string path, Action<AsyncOperation, string>
public static void Load()
{
LoadDefaultCover();
LoadWeatherFinder();
WeatherPrefab = new GameObject("Weather", typeof(WeatherSceneInfo));
Object.DontDestroyOnLoad(WeatherPrefab);
string EffectsPath = Path.Combine(IPA.Utilities.UnityGame.UserDataPath, "Weather", "Effects");
var effectsPath = Path.Combine(IPA.Utilities.UnityGame.UserDataPath, "Weather", "Effects");
//Plugin.Log.Info(EffectsPath);

if (!Directory.Exists(Path.GetDirectoryName(EffectsPath)))
Directory.CreateDirectory(Path.GetDirectoryName(EffectsPath));
if (!Directory.Exists(effectsPath))
Directory.CreateDirectory(effectsPath);

string[] Paths = Directory.GetFiles(EffectsPath, "*.effect");
for (int i = 0; i < Paths.Length; i++)
var paths = Directory.GetFiles(effectsPath, "*.effect");
for (var i = 0; i < paths.Length; i++)
{
string Path = Paths[i];
var path = paths[i];
//Plugin.Log.Info(Path);
LoadFromFileAsync(Path, new Action<AsyncOperation, string>(LoadFromBundle));
LoadFromFileAsync(path, LoadFromBundle);
}
}

public static void LoadFromBundle(AsyncOperation bundleRequest, string filePath)
{
AssetBundle bundle = (bundleRequest as AssetBundleCreateRequest).assetBundle;
TextAsset json = bundle.LoadAsset<TextAsset>("assets/effectJson.asset");
Sprite Cover = null;
string coverPath = "";
foreach(string path in bundle.GetAllAssetNames())
var bundle = (bundleRequest as AssetBundleCreateRequest).assetBundle;
var json = bundle.LoadAsset<TextAsset>("assets/effectJson.asset");
Sprite cover = null;
var coverPath = "";
foreach(var path in bundle.GetAllAssetNames())
{
if (path.StartsWith("assets/covers/"))
coverPath = path;
Expand All @@ -73,48 +68,43 @@ public static void LoadFromBundle(AsyncOperation bundleRequest, string filePath)
{
try
{
Texture2D coverTex = bundle.LoadAsset<Texture2D>(coverPath);
Cover = Sprite.Create(coverTex, new Rect(0, 0, coverTex.width, coverTex.height), new Vector2(0, 0), 100f);
var coverTex = bundle.LoadAsset<Texture2D>(coverPath);
cover = Sprite.Create(coverTex, new Rect(0, 0, coverTex.width, coverTex.height), new Vector2(0, 0), 100f);
}
catch
{
Cover = DefaultTex;
cover = DefaultTex;
}
}
else
Cover = DefaultTex;
cover = DefaultTex;

GameObject Eff = Object.Instantiate(bundle.LoadAsset<GameObject>("assets/Effect.prefab"), WeatherPrefab.transform);
Eff.SetActive(false);
TempDesc_0_1_2 EfdTemp = null;
var eff = Object.Instantiate(bundle.LoadAsset<GameObject>("assets/Effect.prefab"), WeatherPrefab.transform);
eff.SetActive(false);
TempDesc012 efdTemp = null;
try
{
EfdTemp = JsonUtility.FromJson<TempDesc_0_1_2>(json.text);
efdTemp = JsonUtility.FromJson<TempDesc012>(json.text);
}
catch
{
try
{
TempDesc_0_1_1 EfdOld1 = JsonUtility.FromJson<TempDesc_0_1_1>(json.text);
EfdTemp = new TempDesc_0_1_2(EfdOld1.Author, EfdOld1.EffectName, EfdOld1.WorksInMenu, true);
var efdOld1 = JsonUtility.FromJson<TempDesc011>(json.text);
efdTemp = new TempDesc012(efdOld1.Author, efdOld1.EffectName, efdOld1.WorksInMenu, true);
}
catch
{
string fileName = Path.GetFileNameWithoutExtension(filePath);
var fileName = Path.GetFileNameWithoutExtension(filePath);
Plugin.Log.Error(string.Format("{0} Failed To Load! Json: {1}", fileName, json.text));
}
}
EffectDiscriptor Efd = Eff.AddComponent<EffectDiscriptor>();
Efd.Author = EfdTemp.Author;
Efd.EffectName = EfdTemp.EffectName;
Efd.WorksInMenu = EfdTemp.WorksInMenu;
Efd.WorksInGame = EfdTemp.WorksInGame;
Efd.coverImage = Cover;
}

async public static void LoadWeatherFinder()
{
WeatherDataRoot weatherData = await WeatherFinder.GetWeatherData();
var efd = eff.AddComponent<EffectDescriptor>();
efd.author = efdTemp.Author;
efd.effectName = efdTemp.EffectName;
efd.worksInMenu = efdTemp.WorksInMenu;
efd.worksInGame = efdTemp.WorksInGame;
efd.coverImage = cover;
}
}
}
35 changes: 0 additions & 35 deletions PC/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,6 @@
<Target Name="CheckBSMTInstalled" AfterTargets="BeforeBuild" Condition="'$(BSMTTaskAssembly)' == ''">
<Warning Text="The BeatSaberModdingTools.Tasks nuget package doesn't seem to be installed, advanced build targets will not work." />
</Target>
<!--Runs a build task to get info about the project used by later targets.-->
<Target Name="GetProjectInfo" AfterTargets="CheckBSMTInstalled" DependsOnTargets="CheckBSMTInstalled" Condition="'$(BSMTTaskAssembly)' != ''">
<Message Text="Using AssemblyVersion defined in project instead of 'Properties\AssemblyInfo.cs'" Importance="high" Condition="'$(AssemblyVersion)' != ''" />
<GetManifestInfo KnownAssemblyVersion="$(AssemblyVersion)" ErrorOnMismatch="$(ErrorOnMismatchedVersions)">
<Output TaskParameter="PluginVersion" PropertyName="PluginVersion" />
<Output TaskParameter="GameVersion" PropertyName="GameVersion" />
<Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion" />
</GetManifestInfo>
<GetCommitInfo ProjectDir="$(ProjectDir)">
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
<Output TaskParameter="Branch" PropertyName="Branch" />
<Output TaskParameter="Modified" PropertyName="GitModified" />
</GetCommitInfo>
<PropertyGroup>
<!--Build name for artifact/zip file-->
<ArtifactName>$(AssemblyName)</ArtifactName>
<ArtifactName Condition="'$(PluginVersion)' != ''">$(ArtifactName)-$(PluginVersion)</ArtifactName>
<ArtifactName Condition="'$(GameVersion)' != ''">$(ArtifactName)-bs$(GameVersion)</ArtifactName>
<ArtifactName Condition="'$(CommitHash)' != '' AND '$(CommitHash)' != 'local'">$(ArtifactName)-$(CommitHash)</ArtifactName>
</PropertyGroup>
</Target>
<!--Build target for Continuous Integration builds. Set up for GitHub Actions.-->
<Target Name="BuildForCI" AfterTargets="Build" DependsOnTargets="GetProjectInfo" Condition="'$(ContinuousIntegrationBuild)' == 'True' AND '$(BSMTTaskAssembly)' != ''">
<PropertyGroup>
<!--Set 'ArtifactName' if it failed before.-->
<ArtifactName Condition="'$(ArtifactName)' == ''">$(AssemblyName)</ArtifactName>
</PropertyGroup>
<Message Text="Building for CI" Importance="high" />
<Message Text="PluginVersion: $(PluginVersion), AssemblyVersion: $(AssemblyVersion), GameVersion: $(GameVersion)" Importance="high" />
<Message Text="::set-output name=filename::$(ArtifactName)" Importance="high" />
<Message Text="::set-output name=assemblyname::$(AssemblyName)" Importance="high" />
<Message Text="::set-output name=artifactpath::$(ProjectDir)$(ArtifactDestination)" Importance="high" />
<Message Text="Copying '$(OutputAssemblyName).dll' to '$(ProjectDir)$(ArtifactDestination)\Plugins\$(AssemblyName).dll'" Importance="high" />
<Copy SourceFiles="$(OutputAssemblyName).dll" DestinationFiles="$(ProjectDir)$(ArtifactDestination)\Plugins\$(AssemblyName).dll" />
</Target>
<!--Creates a BeatMods compliant zip file with the release.-->
<Target Name="ZipRelease" AfterTargets="Build" Condition="'$(DisableZipRelease)' != 'True' AND '$(Configuration)' == 'Release' AND '$(BSMTTaskAssembly)' != ''">
<PropertyGroup>
Expand Down
Loading

0 comments on commit dfb4cf9

Please sign in to comment.