Added new GizmoTypes

typeof(CVRGizmos_ToggleStateTrigger),
            typeof(CVRGizmos_Avatar),
            typeof(CVRGizmos_AvatarPickupMarker),
            //may be broken
            typeof(CVRGizmos_DistanceConstrain),
This commit is contained in:
NotAKidoS 2022-09-14 18:29:14 -05:00
parent 7ca182ad62
commit 65b57db665
6 changed files with 232 additions and 0 deletions

View file

@ -20,6 +20,10 @@ namespace CVRGizmos
typeof(CVRGizmos_DistanceLod),
typeof(CVRGizmos_HapticZone),
typeof(CVRGizmos_HapticAreaChest),
typeof(CVRGizmos_ToggleStateTrigger),
typeof(CVRGizmos_Avatar),
typeof(CVRGizmos_AvatarPickupMarker),
typeof(CVRGizmos_DistanceConstrain),
};
void Start()

View file

@ -0,0 +1,46 @@
using ABI.CCK.Components;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
{
public class CVRGizmos_Avatar : CVRGizmoBase
{
public static CVRAvatar[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(CVRAvatar)) as CVRAvatar[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (CVRAvatar)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Count(); i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].isActiveAndEnabled)
{
//viewPosition & voicePosition seem to be rounded... not good, may be why viewpoint drift is bad on scale
Gizmos.Color = Color.green;
Gizmos.Matrix = Matrix4x4.TRS(references[i].transform.position, references[i].transform.rotation, references[i].transform.localScale);
Gizmos.Sphere(references[i].viewPosition, 0.01f);
Gizmos.Color = Color.red;
Gizmos.Sphere(references[i].voicePosition, 0.01f);
}
}
}
}
}

View file

@ -0,0 +1,51 @@
using ABI.CCK.Components;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
{
public class CVRGizmos_AvatarPickupMarker : CVRGizmoBase
{
public static CVRAvatarPickupMarker[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(CVRAvatarPickupMarker)) as CVRAvatarPickupMarker[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (CVRAvatarPickupMarker)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Count(); i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].isActiveAndEnabled)
{
Gizmos.Color = Color.magenta;
Gizmos.Matrix = Matrix4x4.TRS(references[i].transform.position, references[i].transform.rotation, references[i].transform.lossyScale);
Gizmos.Cube(new Vector3(0f, 0.75f, 0f), Quaternion.identity, new Vector3(1f, 1.5f, 0f));
Gizmos.Cube(new Vector3(0f, 0.7f, 0f), Quaternion.identity, new Vector3(0.8f, 0.1f, 0f));
Gizmos.Cube(new Vector3(0f, 0.615f, 0f), Quaternion.identity, new Vector3(0.6f, 0.07f, 0f));
Gizmos.Cube(new Vector3(0.24f, 0.28f, 0f), Quaternion.identity, new Vector3(0.32f, 0.42f, 0f));
Gizmos.Cube(new Vector3(-0.24f, 0.28f, 0f), Quaternion.identity, new Vector3(0.32f, 0.42f, 0f));
Vector3 lossyScale = references[i].transform.lossyScale;
lossyScale.Scale(new Vector3(1f, 1f, 0f));
Gizmos.Matrix = Matrix4x4.TRS(references[i].transform.position, references[i].transform.rotation, lossyScale);
Gizmos.Sphere(new Vector3(0f, 1.11f, 0f), 0.31f);
}
}
}
}
}

View file

@ -0,0 +1,79 @@
using ABI.CCK.Components;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
namespace CVRGizmos.GismoTypes
{
public class CVRGizmos_DistanceConstrain : CVRGizmoBase
{
public static CVRDistanceConstrain[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(CVRDistanceConstrain)) as CVRDistanceConstrain[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (CVRDistanceConstrain)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Count(); i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].target == null)
{
break;
}
if (references[i].maxDistance < references[i].minDistance && references[i].maxDistance != 0f)
{
break;
}
Vector3 normalized = (references[i].transform.position - references[i].target.position).normalized;
//BUG: Matrix addition isn't reset, other gizmo types Matrix will persist.
//This gizmo type could be a bit fucked, but I don't have the time to test.
Gizmos.Matrix = Matrix4x4.identity;
if (references[i].minDistance == 0f)
{
if (references[i].maxDistance == 0f)
{
Gizmos.Color = Color.green;
Gizmos.Line(references[i].target.position, normalized * 9999f);
break;
}
Gizmos.Color = Color.green;
Gizmos.Line(references[i].target.position, references[i].target.position + normalized * references[i].maxDistance);
break;
}
else
{
if (references[i].maxDistance == 0f)
{
Gizmos.Color = Color.red;
Gizmos.Line(references[i].target.position, references[i].target.position + normalized * references[i].minDistance);
Gizmos.Color = Color.green;
Gizmos.Line(references[i].target.position + normalized * references[i].minDistance, normalized * 9999f);
break;
}
Gizmos.Color = Color.red;
Gizmos.Line(references[i].target.position, references[i].target.position + normalized * references[i].minDistance);
Gizmos.Color = Color.green;
Gizmos.Line(references[i].target.position + normalized * references[i].minDistance, references[i].target.position + normalized * references[i].maxDistance);
break;
}
}
}
}
}

View file

@ -0,0 +1,49 @@
using ABI.CCK.Components;
using UnityEngine;
using Gizmos = Popcron.Gizmos;
/**
CVRToggleStateTrigger **can** be local using CVROfflinePreview or similar mods.
**/
namespace CVRGizmos.GismoTypes
{
public class CVRGizmos_ToggleStateTrigger : CVRGizmoBase
{
public static CVRToggleStateTrigger[] references;
public override void CacheGizmos()
{
var found = Resources.FindObjectsOfTypeAll(typeof(CVRToggleStateTrigger)) as CVRToggleStateTrigger[];
if (CVRGizmoManager.Instance.g_localOnly)
{
references = Array.ConvertAll(GetLocalOnly(found), item => (CVRToggleStateTrigger)item);
}
else
{
references = found;
}
}
public override void DrawGizmos()
{
for (int i = 0; i < references.Count(); i++)
{
if (references[i] == null)
{
CacheGizmos();
break;
}
if (references[i].isActiveAndEnabled)
{
Gizmos.Color = Color.green;
Gizmos.Matrix = Matrix4x4.TRS(references[i].transform.position, references[i].transform.rotation, references[i].transform.lossyScale);
Gizmos.Cube(references[i].areaOffset, Quaternion.identity, references[i].areaSize);
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using ABI_RC.Core.Player;
using MelonLoader;
using UnityEngine;
using System.Collections;
namespace CVRGizmos;
@ -35,11 +36,13 @@ public class CVRGizmos : MelonMod
public void CVRGizmosEnabled()
{
if (!CVRGizmoManager.Instance) return;
CVRGizmoManager.Instance.EnableGizmos(m_entryCVRGizmosEnabled.Value);
}
public void CVRGizmosLocalOnly()
{
if (!CVRGizmoManager.Instance) return;
CVRGizmoManager.Instance.g_localOnly = m_entryCVRGizmosLocalOnly.Value;
CVRGizmoManager.Instance.RefreshGizmos();
}