diff --git a/CVRGizmos/CVRGizmoManager.cs b/CVRGizmos/CVRGizmoManager.cs index f29cb97..948783c 100644 --- a/CVRGizmos/CVRGizmoManager.cs +++ b/CVRGizmos/CVRGizmoManager.cs @@ -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() diff --git a/CVRGizmos/GizmoTypes/CVRAvatar.cs b/CVRGizmos/GizmoTypes/CVRAvatar.cs new file mode 100644 index 0000000..3686fc0 --- /dev/null +++ b/CVRGizmos/GizmoTypes/CVRAvatar.cs @@ -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); + } + } + } + } +} \ No newline at end of file diff --git a/CVRGizmos/GizmoTypes/CVRAvatarPickupMarker.cs b/CVRGizmos/GizmoTypes/CVRAvatarPickupMarker.cs new file mode 100644 index 0000000..186de96 --- /dev/null +++ b/CVRGizmos/GizmoTypes/CVRAvatarPickupMarker.cs @@ -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); + } + } + } + } +} \ No newline at end of file diff --git a/CVRGizmos/GizmoTypes/CVRDistanceConstrain.cs b/CVRGizmos/GizmoTypes/CVRDistanceConstrain.cs new file mode 100644 index 0000000..09fd75c --- /dev/null +++ b/CVRGizmos/GizmoTypes/CVRDistanceConstrain.cs @@ -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; + } + } + } + } +} \ No newline at end of file diff --git a/CVRGizmos/GizmoTypes/CVRToggleStateTrigger.cs b/CVRGizmos/GizmoTypes/CVRToggleStateTrigger.cs new file mode 100644 index 0000000..6f9e940 --- /dev/null +++ b/CVRGizmos/GizmoTypes/CVRToggleStateTrigger.cs @@ -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); + } + } + } + } +} \ No newline at end of file diff --git a/CVRGizmos/Main.cs b/CVRGizmos/Main.cs index 376fdce..966b1f8 100644 --- a/CVRGizmos/Main.cs +++ b/CVRGizmos/Main.cs @@ -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(); }