Skip to content

Commit

Permalink
update for u104
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiq-The-Dude committed Jun 2, 2022
1 parent 1efd132 commit 87683df
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/BetterHands/BetterHands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="H3VR.GameLibs" Version="0.100.6-r.0" />
<PackageReference Include="H3VR.GameLibs" Version="0.104.0-r.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="jnm2.ReferenceAssemblies.net35" Version="1.0.1" PrivateAssets="all" />
<PackageReference Include="Sodalite" Version="1.1.0" />
<PackageReference Include="Sodalite" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions src/BetterHands/Configs/Customization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ namespace BetterHands.Configs
{
public class CustomizationConfig
{
public ConfigEntry<Vector4> MaterialA { get; }
public ConfigEntry<Vector4> MaterialB { get; }
public ConfigEntry<Vector4> InteractSphere { get; }
public ConfigEntry<Color> MaterialA { get; }
public ConfigEntry<Color> MaterialB { get; }
public ConfigEntry<Color> InteractSphere { get; }
public ConfigEntry<float> Intensity { get; }
public ConfigEntry<float> FingerSize { get; }
public ConfigEntry<float> PalmSize { get; }
public ConfigEntry<bool> Scale { get; }

public CustomizationConfig(ConfigFile config, string section)
{
var i = new Vector4(81, 140, 255, 1);
MaterialA = config.Bind(section + " Color", nameof(MaterialA), i, "Material A of both hands (RGBA)");
var i = new Vector4(81/255f, 140/255f, 255/255f, 1/1f);
MaterialA = config.Bind(section + " Color", nameof(MaterialA), (Color)i, "Material A of both hands (RGBA)");

var j = new Vector4(197, 120, 179, 1);
MaterialB = config.Bind(section + " Color", nameof(MaterialB), j, "Material B of both hands (RGBA)");
var j = new Vector4(197/255f, 120/255f, 179/255f, 1/1f);
MaterialB = config.Bind(section + " Color", nameof(MaterialB), (Color)j, "Material B of both hands (RGBA)");

InteractSphere = config.Bind(section + " Color", nameof(InteractSphere), i, "Color of interaction spheres (RGBA)");
InteractSphere = config.Bind(section + " Color", nameof(InteractSphere), (Color)i, "Color of interaction spheres (RGBA)");

Intensity = config.Bind(section + " Color", nameof(Intensity), 4f, "Intensity of colors");

Expand Down
36 changes: 27 additions & 9 deletions src/BetterHands/Customization/HandsRecolor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@ public class HandsRecolor

public HandsRecolor(RootConfig config)
{
_config = config;
_config = config;
}

public void Hook()
{
On.FistVR.FVRViveHand.DoInitialize += FVRViveHand_DoInitialize;
_config.Customization.MaterialA.SettingChanged += Recolor_SettingChanged;
_config.Customization.MaterialB.SettingChanged += Recolor_SettingChanged;
_config.Customization.Intensity.SettingChanged += Recolor_SettingChanged;
_config.Customization.InteractSphere.SettingChanged += Recolor_SettingChanged;
}

public void Unhook()
{
On.FistVR.FVRViveHand.DoInitialize -= FVRViveHand_DoInitialize;
_config.Customization.MaterialA.SettingChanged -= Recolor_SettingChanged;
_config.Customization.MaterialB.SettingChanged -= Recolor_SettingChanged;
_config.Customization.Intensity.SettingChanged -= Recolor_SettingChanged;
_config.Customization.InteractSphere.SettingChanged -= Recolor_SettingChanged;
}

private void FVRViveHand_DoInitialize(On.FistVR.FVRViveHand.orig_DoInitialize orig, FVRViveHand self)
Expand All @@ -33,17 +41,27 @@ private void FVRViveHand_DoInitialize(On.FistVR.FVRViveHand.orig_DoInitialize or
CustomizeHand(self);
}

private void CustomizeHand(FVRViveHand fvrhand)
private void Recolor_SettingChanged(object sender, System.EventArgs e)
{
CustomizeHand(GM.CurrentPlayerBody.RightHand);
}

private void CustomizeHand(Transform hand)
{
var hand = fvrhand.transform;
var fvrHand = hand.GetComponent<FVRViveHand>();
CustomizeHand(fvrHand);
CustomizeHand(fvrHand.OtherHand);
}

private void CustomizeHand(FVRViveHand fvrhand)
{
// Set the idle sphere to our color
var cfg = _config.Customization;
fvrhand.TouchSphereMat_NoInteractable.SetColor(COLOR_PROPERTY, Recolor(cfg.InteractSphere, cfg.Intensity.Value));

// Resize interaction spheres & colliders
var scale = new float[] { cfg.FingerSize.Value, cfg.PalmSize.Value };
SphereCollider[] collider = hand.GetComponents<SphereCollider>();
SphereCollider[] collider = fvrhand.transform.GetComponents<SphereCollider>();
Transform[] vis = new Transform[]
{
fvrhand.TouchSphere.transform,
Expand Down Expand Up @@ -85,8 +103,8 @@ private void ColorHandRecursive(GameObject obj)
{
var mat = rend.material;

// All controller geo have two materials, blue & purple
if (mat.name.ToLower().Contains("blue"))
// All controller geo have two materials, blue & purple by default
if (mat.name.IndexOf("blue", System.StringComparison.OrdinalIgnoreCase) != -1)
{
mat.SetColor(COLOR_PROPERTY, Recolor(cfg.MaterialA, intensity));
}
Expand All @@ -100,10 +118,10 @@ private void ColorHandRecursive(GameObject obj)
}
}

// Format the human readable RGBA to what unity wants
private Vector4 Recolor(ConfigEntry<Vector4> cfg, float intensity)
// Format the human readable RGBA to what unity hdr wants
private Vector4 Recolor(ConfigEntry<Color> cfg, float intensity)
{
var color = new Vector4(intensity * (cfg.Value[0] / 255), intensity * (cfg.Value[1] / 255), intensity * (cfg.Value[2] / 255), cfg.Value[3] / 1);
var color = new Vector4(intensity * cfg.Value.r, intensity * cfg.Value.g, intensity * cfg.Value.b, cfg.Value.a);
return color;
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/BetterHands/MagPalming/MagPalm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BetterHands.Configs;
using FistVR;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace BetterHands.MagPalming
Expand Down Expand Up @@ -64,10 +65,13 @@ private void FVRPlayerBody_ConfigureQuickbelt(On.FistVR.FVRPlayerBody.orig_Confi
{
orig(self, index);

ConfigMagPalming(self.RightHand);
ConfigMagPalming(self.LeftHand);
if (!self.QuickbeltSlots.Any(slot => slot.name.Contains(self.LeftHand.name)))
{
ConfigMagPalming(self.RightHand);
ConfigMagPalming(self.LeftHand);

QBList = GM.CurrentPlayerBody.QuickbeltSlots;
QBList = self.QuickbeltSlots;
}
}

private void ConfigMagPalming(Transform hand)
Expand Down
4 changes: 2 additions & 2 deletions src/BetterHands/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace BetterHands
{
[BepInPlugin("maiq.BetterHands", "BetterHands", "1.5.1")]
[BepInPlugin("maiq.BetterHands", "BetterHands", "1.6.0")]
[BepInDependency("nrgill28.Sodalite")]
[BepInProcess("h3vr.exe")]
public class Plugin : BaseUnityPlugin
Expand Down Expand Up @@ -67,7 +67,7 @@ private void ScoreSubmissionManager()
if ((_config.MagPalm.Enable.Value && cfg.CursedPalms.Value) || cfg.SizeLimit.Value > FVRPhysicalObject.FVRPhysicalObjectSize.Medium)
{
Logger.LogDebug("TNH scoring is disabled");
_leaderboardLock ??= LeaderboardAPI.GetLeaderboardDisableLock();
_leaderboardLock ??= LeaderboardAPI.LeaderboardDisabled.TakeLock();
}
else
{
Expand Down
Binary file modified src/libs/MMHOOK_Assembly-CSharp.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions thunderstore/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "BetterHands",
"version_number": "1.5.1",
"version_number": "1.6.0",
"dependencies": [
"nrgill28-Sodalite-1.0.0"
"nrgill28-Sodalite-1.3.0"
],
"description": "Adds mag palming and controller color customization.",
"website_url": "https://github.com/Maiq-The-Dude/BetterHands"
Expand Down

0 comments on commit 87683df

Please sign in to comment.