[CVRGizmos] cleanup & new gizmos

This commit is contained in:
NotAKidoS 2023-05-02 12:57:13 -05:00
parent 6f24bd6ff3
commit e512c9dd70
21 changed files with 724 additions and 565 deletions

View file

@ -1,8 +1,8 @@
using CVRGizmos.GismoTypes;
using NAK.CVRGizmos.GismoTypes;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos
namespace NAK.CVRGizmos
{
public class CVRGizmoManager : MonoBehaviour
{
@ -25,6 +25,9 @@ namespace CVRGizmos
typeof(CVRGizmos_Avatar),
typeof(CVRGizmos_AvatarPickupMarker),
typeof(CVRGizmos_DistanceConstrain),
typeof(CVRGizmos_BoxCollider),
typeof(CVRGizmos_SphereCollider),
typeof(CVRGizmos_CapsuleCollider),
};
void Start()

View file

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"/>
<Project Sdk="Microsoft.NET.Sdk" />

View file

@ -8,10 +8,10 @@ CVRAdvancedAvatarSettingsPointer shouldn't really be used at this point. Only in
**/
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_AdvancedAvatarSettingsPointer : CVRGizmoBase
{
public class CVRGizmos_AdvancedAvatarSettingsPointer : CVRGizmoBase
{
public static CVRAdvancedAvatarSettingsPointer[] references;
public override void CacheGizmos()
@ -45,5 +45,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -3,10 +3,10 @@ using ABI_RC.Core.Player;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_AdvancedAvatarSettingsTrigger : CVRGizmoBase
{
public class CVRGizmos_AdvancedAvatarSettingsTrigger : CVRGizmoBase
{
public static CVRAdvancedAvatarSettingsTrigger[] references;
public override void CacheGizmos()
@ -109,5 +109,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -2,10 +2,10 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_Avatar : CVRGizmoBase
{
public class CVRGizmos_Avatar : CVRGizmoBase
{
public static CVRAvatar[] references;
public override void CacheGizmos()
@ -46,5 +46,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -2,10 +2,10 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_AvatarPickupMarker : CVRGizmoBase
{
public class CVRGizmos_AvatarPickupMarker : CVRGizmoBase
{
public static CVRAvatarPickupMarker[] references;
public override void CacheGizmos()
@ -47,5 +47,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -2,10 +2,10 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_DistanceConstrain : CVRGizmoBase
{
public class CVRGizmos_DistanceConstrain : CVRGizmoBase
{
public static CVRDistanceConstrain[] references;
public override void CacheGizmos()
@ -75,5 +75,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -2,10 +2,10 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_DistanceLod : CVRGizmoBase
{
public class CVRGizmos_DistanceLod : CVRGizmoBase
{
public static CVRDistanceLod[] references;
private static Color[] _gizmoColors = new Color[]
@ -58,5 +58,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -1,10 +1,10 @@
using UnityEngine;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmoBase : MonoBehaviour
{
public class CVRGizmoBase : MonoBehaviour
{
public MonoBehaviour[] GetLocalOnly(MonoBehaviour[] input)
public Component[] GetLocalOnly(Component[] input)
{
return input.Where(c => c.gameObject.scene.name == "DontDestroyOnLoad").ToArray();
}
@ -33,5 +33,4 @@ namespace CVRGizmos.GismoTypes
public virtual void DrawGizmos()
{
}
}
}

View file

@ -3,10 +3,10 @@ using HarmonyLib;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_HapticAreaChest : CVRGizmoBase
{
public class CVRGizmos_HapticAreaChest : CVRGizmoBase
{
public static CVRHapticAreaChest[] references;
public override void CacheGizmos()
@ -49,5 +49,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -2,10 +2,10 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_HapticZone : CVRGizmoBase
{
public class CVRGizmos_HapticZone : CVRGizmoBase
{
public static CVRHapticZone[] references;
public override void CacheGizmos()
@ -41,5 +41,4 @@ namespace CVRGizmos.GismoTypes
Gizmos.Sphere(references[i].center, references[i].bounds.x);
}
}
}
}

View file

@ -2,10 +2,10 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_Pointer : CVRGizmoBase
{
public class CVRGizmos_Pointer : CVRGizmoBase
{
public static CVRPointer[] references;
public override void CacheGizmos()
@ -40,5 +40,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -8,10 +8,10 @@ CVRSpawnableTrigger **can** be local using CVROfflinePreview or similar mods.
**/
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_SpawnableTrigger : CVRGizmoBase
{
public class CVRGizmos_SpawnableTrigger : CVRGizmoBase
{
public static CVRSpawnableTrigger[] references;
public override void CacheGizmos()
@ -123,5 +123,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -8,10 +8,10 @@ CVRToggleStateTrigger **can** be local using CVROfflinePreview or similar mods.
**/
namespace CVRGizmos.GismoTypes
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_ToggleStateTrigger : CVRGizmoBase
{
public class CVRGizmos_ToggleStateTrigger : CVRGizmoBase
{
public static CVRToggleStateTrigger[] references;
public override void CacheGizmos()
@ -45,5 +45,4 @@ namespace CVRGizmos.GismoTypes
}
}
}
}
}

View file

@ -0,0 +1,47 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_BoxCollider : CVRGizmoBase
{
public static BoxCollider[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(BoxCollider)) as BoxCollider[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (BoxCollider)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Length; i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].gameObject.activeInHierarchy)
{
BoxCollider box = references[i];
Gizmos.Color = Color.green;
Vector3 position = box.transform.TransformPoint(box.center);
Quaternion rotation = box.transform.rotation;
Vector3 scaledSize = Vector3.Scale(box.size, box.transform.lossyScale);
Gizmos.Matrix = Matrix4x4.TRS(position, rotation, Vector3.one);
Gizmos.Cube(Vector3.zero, Quaternion.identity, scaledSize);
}
}
}
}

View file

@ -0,0 +1,84 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_CapsuleCollider : CVRGizmoBase
{
public static CapsuleCollider[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(CapsuleCollider)) as CapsuleCollider[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (CapsuleCollider)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Length; i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].gameObject.activeInHierarchy)
{
CapsuleCollider capsule = references[i];
Gizmos.Color = Color.green;
Vector3 position = capsule.transform.position;
Quaternion rotation = capsule.transform.rotation;
Vector3 lossyScale = capsule.transform.lossyScale;
float maxLossyScale = Mathf.Max(Mathf.Max(lossyScale.x, lossyScale.y), lossyScale.z);
Vector3 scaledCenter = Vector3.Scale(capsule.center, lossyScale);
float scaledRadius = capsule.radius * maxLossyScale;
float scaledHeight = capsule.height * maxLossyScale;
Gizmos.Matrix = Matrix4x4.TRS(position, rotation, Vector3.one);
// Draw top sphere
Vector3 topSphereOffset = Vector3.zero;
topSphereOffset[capsule.direction] = (scaledHeight - (2 * scaledRadius)) / 2;
Gizmos.Sphere(scaledCenter + topSphereOffset, scaledRadius);
// Draw bottom sphere
Vector3 bottomSphereOffset = Vector3.zero;
bottomSphereOffset[capsule.direction] = -(scaledHeight - (2 * scaledRadius)) / 2;
Gizmos.Sphere(scaledCenter + bottomSphereOffset, scaledRadius);
// Draw cylinder
int cylinderResolution = 24;
Vector3 previousTopPoint = Vector3.zero;
Vector3 previousBottomPoint = Vector3.zero;
for (int j = 0; j <= cylinderResolution; j++)
{
float angle = j * 2 * Mathf.PI / cylinderResolution;
Vector3 directionVector = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle));
directionVector[capsule.direction] = 0;
Vector3 topPoint = (scaledCenter + topSphereOffset) + directionVector * scaledRadius;
Vector3 bottomPoint = (scaledCenter + bottomSphereOffset) + directionVector * scaledRadius;
if (j > 0)
{
Gizmos.Line(previousTopPoint, topPoint);
Gizmos.Line(previousBottomPoint, bottomPoint);
Gizmos.Line(previousTopPoint, previousBottomPoint);
Gizmos.Line(topPoint, bottomPoint);
}
previousTopPoint = topPoint;
previousBottomPoint = bottomPoint;
}
}
}
}
}

View file

@ -0,0 +1,49 @@
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace NAK.CVRGizmos.GismoTypes;
public class CVRGizmos_SphereCollider : CVRGizmoBase
{
public static SphereCollider[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(SphereCollider)) as SphereCollider[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (SphereCollider)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Length; i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].gameObject.activeInHierarchy)
{
Gizmos.Color = Color.green;
Vector3 position = references[i].transform.position;
Quaternion rotation = references[i].transform.rotation;
Vector3 lossyScale = references[i].transform.lossyScale;
float maxLossyScale = Mathf.Max(Mathf.Max(lossyScale.x, lossyScale.y), lossyScale.z);
Vector3 scaledCenter = Vector3.Scale(references[i].center, lossyScale);
float scaledRadius = references[i].radius * maxLossyScale;
Gizmos.Matrix = Matrix4x4.TRS(position, rotation, Vector3.one);
Gizmos.Sphere(scaledCenter, scaledRadius);
}
}
}
}

View file

@ -2,7 +2,7 @@
using MelonLoader;
using System.Collections;
namespace CVRGizmos;
namespace NAK.CVRGizmos;
public class CVRGizmos : MelonMod
{
@ -17,6 +17,8 @@ public class CVRGizmos : MelonMod
public override void OnInitializeMelon()
{
EntryEnabled.OnEntryValueChangedUntyped.Subscribe(CVRGizmosEnabled);
EntryLocalOnly.OnEntryValueChangedUntyped.Subscribe(CVRGizmosLocalOnly);
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
}
@ -28,13 +30,13 @@ public class CVRGizmos : MelonMod
PlayerSetup.Instance.gameObject.AddComponent<CVRGizmoManager>();
}
public void CVRGizmosEnabled()
public void CVRGizmosEnabled(object arg1, object arg2)
{
if (!CVRGizmoManager.Instance) return;
CVRGizmoManager.Instance.EnableGizmos(EntryEnabled.Value);
}
public void CVRGizmosLocalOnly()
public void CVRGizmosLocalOnly(object arg1, object arg2)
{
if (!CVRGizmoManager.Instance) return;
CVRGizmoManager.Instance.g_localOnly = EntryLocalOnly.Value;

View file

@ -1,17 +1,17 @@
using CVRGizmos.Properties;
using NAK.CVRGizmos.Properties;
using MelonLoader;
using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyTitle(nameof(CVRGizmos))]
[assembly: AssemblyTitle(nameof(NAK.CVRGizmos))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(CVRGizmos))]
[assembly: AssemblyProduct(nameof(NAK.CVRGizmos))]
[assembly: MelonInfo(
typeof(CVRGizmos.CVRGizmos),
nameof(CVRGizmos),
typeof(NAK.CVRGizmos.CVRGizmos),
nameof(NAK.CVRGizmos),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/CVRGizmos"
@ -21,9 +21,9 @@ using System.Reflection;
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
namespace CVRGizmos.Properties;
namespace NAK.CVRGizmos.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.0";
public const string Version = "1.0.1";
public const string Author = "NotAKidoS";
}

View file

@ -1,23 +1,23 @@
{
"_id": 95,
"_id": 97,
"name": "CVRGizmos",
"modversion": "1.1.0",
"gameversion": "2022r168",
"loaderversion": "0.5.4",
"modversion": "1.0.1",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "Corrects MM and QM position when avatar is scaled.\nAdditional option to scale player collision.",
"description": "Adds runtime gizmos to common CCK components.",
"searchtags": [
"menu",
"scale",
"avatarscale",
"slider"
"gizmo",
"components",
"cck",
"visual"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/CVRGizmos.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/CVRGizmos/",
"changelog": "Added option to scale player collision. Fixed some VR specific issues.",
"changelog": "- Removed SaveToFile().",
"embedcolor": "804221"
}

View file

@ -2,22 +2,9 @@
using System.Reflection;
using UnityEngine;
using static NAK.ThirdPerson.CameraLogic;
using BuildInfo = NAK.ThirdPerson.BuildInfo;
[assembly: AssemblyCopyright("Created by " + BuildInfo.Author)]
[assembly: MelonInfo(typeof(NAK.ThirdPerson.ThirdPerson), BuildInfo.Name, BuildInfo.Version, BuildInfo.Author)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonColor(ConsoleColor.DarkMagenta)]
namespace NAK.ThirdPerson;
public static class BuildInfo
{
public const string Name = "ThirdPerson";
public const string Author = "Davi & NotAKidoS";
public const string Version = "1.0.2";
}
public class ThirdPerson : MelonMod
{
internal static MelonLogger.Instance Logger;
@ -26,9 +13,8 @@ public class ThirdPerson : MelonMod
{
Logger = LoggerInstance;
MelonCoroutines.Start(SetupCamera());
Patches.Apply(HarmonyInstance);
MelonCoroutines.Start(SetupCamera());
}
public override void OnUpdate()