Skip to content

Commit

Permalink
BSIPA and BS1.6.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibodan authored and Ibodan committed Dec 24, 2019
1 parent e0625a5 commit bbf852f
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 35 deletions.
60 changes: 43 additions & 17 deletions RumbleEnhancerOculus/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using System.Linq;
using IllusionPlugin;
using IPA;
using IPA.Config;
using Harmony;
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using IPALogger = IPA.Logging.Logger;

namespace RumbleEnhancerOculus
{
public class Plugin : IPlugin
public class Plugin : IBeatSaberPlugin
{
public static OVRHapticsClip CutClip;
public static OVRHapticsClip MissCutClip;
Expand All @@ -16,8 +19,31 @@ public class Plugin : IPlugin
public static OVRHapticsClip ClashClip;
public static OVRHapticsClip ObstacleClip;

public string Name => "RumbleEnhancerOculus";
public string Version => "1.0.6";
internal static IPALogger logger;

public void Init(IPALogger logger, [Config.Prefer("json")] IConfigProvider configProvider)
{
IPA.Logging.StandardLogger.PrintFilter = IPA.Logging.Logger.LogLevel.All;
Plugin.logger = logger;
var config = configProvider.MakeLink<PluginConfig>((p, v) =>
{
if (v.Value._fresh)
{
Plugin.logger.Debug("Generating settings file.");
v.Value._fresh = false;
p.Store(v.Value);
}
});
Plugin.logger.Debug("RumbleEnhancerOculus Initialized, using settings:");
config.Value.LogValues();

CutClip = createHapticsClip(config.Value.CutClip);
MissCutClip = createHapticsClip(config.Value.MissCutClip);
BombClip = createHapticsClip(config.Value.BombClip);
UIClip = createHapticsClip(config.Value.UIClip);
ClashClip = createHapticsClip(config.Value.SaberClashClip);
ObstacleClip = createHapticsClip(config.Value.ObstacleClip);
}

private OVRHapticsClip createHapticsClip(string strPattern)
{
Expand All @@ -33,29 +59,17 @@ private OVRHapticsClip createHapticsClip(string strPattern)
return clip;
}

public static void Log(string s)
{
Console.WriteLine("[RumbleEnhancerOculus] " + s);
}

public void OnApplicationStart()
{
SharedCoroutineStarter.instance.StartCoroutine(Patch());

CutClip = createHapticsClip(ModPrefs.GetString(Name, "CutClip", "0,0,0,0,255,255,255,0,255,255,255,0,255,255,0,255,255,0,200,200,0,200,200,0,120,120,0,90,90,0,90,90", true));
MissCutClip = createHapticsClip(ModPrefs.GetString(Name, "MissCutClip", "0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255", true));
BombClip = createHapticsClip(ModPrefs.GetString(Name, "BombClip", "0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255", true));
UIClip = createHapticsClip(ModPrefs.GetString(Name, "UIClip", "80,100,0,0,0,0", true));
ClashClip = createHapticsClip(ModPrefs.GetString(Name, "SaberClashClip", "45,90,135,180,0,0,0,0,0,0", true));
ObstacleClip = createHapticsClip(ModPrefs.GetString(Name, "ObstacleClip", "255,255,255,0,255,255,255,0", true));
}

private IEnumerator Patch()
{
yield return new WaitForSecondsRealtime(0.2f);
var harmony = HarmonyInstance.Create("HapticTest");
harmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
Console.WriteLine("[RumbleEnhancerOculus] patch applied now.");
logger.Debug("Harmony patches applied now.");
}

public void OnApplicationQuit()
Expand All @@ -77,5 +91,17 @@ public void OnUpdate()
public void OnFixedUpdate()
{
}

public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
{
}

public void OnSceneUnloaded(Scene scene)
{
}

public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
{
}
}
}
29 changes: 29 additions & 0 deletions RumbleEnhancerOculus/PluginConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RumbleEnhancerOculus
{
internal class PluginConfig
{
public string CutClip = "0,0,0,0,255,255,255,0,255,255,255,0,255,255,0,255,255,0,200,200,0,200,200,0,120,120,0,90,90,0,90,90";
public string MissCutClip = "0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255";
public string BombClip = "0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255";
public string UIClip = "80,100,0,0,0,0";
public string SaberClashClip = "45,90,135,180,0,0,0,0,0,0";
public string ObstacleClip = "255,255,255,0,255,255,255,0";
public bool _fresh = true;

public void LogValues()
{
Plugin.logger?.Debug($" CutClip: {CutClip}");
Plugin.logger?.Debug($" MissCutClip: {MissCutClip}");
Plugin.logger?.Debug($" BombClip: {BombClip}");
Plugin.logger?.Debug($" UIClip: {UIClip}");
Plugin.logger?.Debug($" SaberClashClip: {SaberClashClip}");
Plugin.logger?.Debug($" ObstacleClip: {ObstacleClip}");
}
}
}
4 changes: 2 additions & 2 deletions RumbleEnhancerOculus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.6.0")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
42 changes: 26 additions & 16 deletions RumbleEnhancerOculus/RumbleEnhancerOculus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RumbleEnhancerOculus</RootNamespace>
<AssemblyName>RumbleEnhancerOculus</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -33,19 +33,21 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\Steam7\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
<Reference Include="0Harmony.1.2.0.1">
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Libs\0Harmony.1.2.0.1.dll</HintPath>
</Reference>
<Reference Include="HMLib">
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\HMLib.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>J:\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="IPA.Loader">
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
</Reference>
<Reference Include="IllusionPlugin">
<HintPath>J:\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
<Reference Include="MainAssembly">
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\MainAssembly.dll</HintPath>
</Reference>
<Reference Include="Oculus.VR, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\Steam7\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Oculus.VR.dll</HintPath>
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Oculus.VR.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -54,28 +56,36 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>J:\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UnityEngine.VRModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\Steam7\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.XRModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\Steam7\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.XRModule.dll</HintPath>
<HintPath>D:\SteamAnnex\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.XRModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="HarmonyPatches.cs" />
<Compile Include="MyHapticFeedbackHelper.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="PluginConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="manifest.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"C:\Users\kataho\Desktop\beat saber workspace\PluginVersionSetter.exe" $(ProjectDir)Properties\AssemblyInfo.cs $(ProjectDir)Plugin.cs
</PreBuildEvent>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
</Project>
13 changes: 13 additions & 0 deletions RumbleEnhancerOculus/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json",
"author": "Ibodan",
"description": "BeatSaber haptic feedback rebuilding for Oculus Touch.",
"gameVersion": "1.6.0",
"id": "RumbleEnhancerOculus",
"name": "RumbleEnhancerOculus",
"version": "1.1.0",
"dependsOn": {
"BSIPA": "^3.13.4"
},
"features": []
}

0 comments on commit bbf852f

Please sign in to comment.