[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 UnityEngine;
using Gizmos = Popcron.Gizmos; using Gizmos = Popcron.Gizmos;
namespace CVRGizmos namespace NAK.CVRGizmos
{ {
public class CVRGizmoManager : MonoBehaviour public class CVRGizmoManager : MonoBehaviour
{ {
@ -25,6 +25,9 @@ namespace CVRGizmos
typeof(CVRGizmos_Avatar), typeof(CVRGizmos_Avatar),
typeof(CVRGizmos_AvatarPickupMarker), typeof(CVRGizmos_AvatarPickupMarker),
typeof(CVRGizmos_DistanceConstrain), typeof(CVRGizmos_DistanceConstrain),
typeof(CVRGizmos_BoxCollider),
typeof(CVRGizmos_SphereCollider),
typeof(CVRGizmos_CapsuleCollider),
}; };
void Start() void Start()

View file

@ -8,8 +8,8 @@ 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 static CVRAdvancedAvatarSettingsPointer[] references;
@ -46,4 +46,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -3,8 +3,8 @@ using ABI_RC.Core.Player;
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRAdvancedAvatarSettingsTrigger[] references;
@ -110,4 +110,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -2,8 +2,8 @@
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRAvatar[] references;
@ -47,4 +47,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -2,8 +2,8 @@
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRAvatarPickupMarker[] references;
@ -48,4 +48,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -2,8 +2,8 @@
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRDistanceConstrain[] references;
@ -76,4 +76,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -2,8 +2,8 @@
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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; public static CVRDistanceLod[] references;
@ -59,4 +59,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -1,10 +1,10 @@
using UnityEngine; 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(); return input.Where(c => c.gameObject.scene.name == "DontDestroyOnLoad").ToArray();
} }
@ -34,4 +34,3 @@ namespace CVRGizmos.GismoTypes
{ {
} }
} }
}

View file

@ -3,8 +3,8 @@ using HarmonyLib;
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRHapticAreaChest[] references;
@ -50,4 +50,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -2,8 +2,8 @@
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRHapticZone[] references;
@ -42,4 +42,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -2,8 +2,8 @@
using UnityEngine; using UnityEngine;
using Gizmos = Popcron.Gizmos; 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 static CVRPointer[] references;
@ -41,4 +41,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

@ -8,8 +8,8 @@ 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 static CVRSpawnableTrigger[] references;
@ -124,4 +124,3 @@ namespace CVRGizmos.GismoTypes
} }
} }
} }
}

View file

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

View file

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

View file

@ -1,23 +1,23 @@
{ {
"_id": 95, "_id": 97,
"name": "CVRGizmos", "name": "CVRGizmos",
"modversion": "1.1.0", "modversion": "1.0.1",
"gameversion": "2022r168", "gameversion": "2022r170",
"loaderversion": "0.5.4", "loaderversion": "0.5.7",
"modtype": "Mod", "modtype": "Mod",
"author": "NotAKidoS", "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": [ "searchtags": [
"menu", "gizmo",
"scale", "components",
"avatarscale", "cck",
"slider" "visual"
], ],
"requirements": [ "requirements": [
"None" "None"
], ],
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/CVRGizmos.dll", "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/CVRGizmos.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/CVRGizmos/", "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" "embedcolor": "804221"
} }

View file

@ -2,22 +2,9 @@
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using static NAK.ThirdPerson.CameraLogic; 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; 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 public class ThirdPerson : MelonMod
{ {
internal static MelonLogger.Instance Logger; internal static MelonLogger.Instance Logger;
@ -26,9 +13,8 @@ public class ThirdPerson : MelonMod
{ {
Logger = LoggerInstance; Logger = LoggerInstance;
MelonCoroutines.Start(SetupCamera());
Patches.Apply(HarmonyInstance); Patches.Apply(HarmonyInstance);
MelonCoroutines.Start(SetupCamera());
} }
public override void OnUpdate() public override void OnUpdate()