mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Added CVR Pointer particle system support.
This commit is contained in:
parent
3763bcbc9f
commit
6b3dc31dbd
3 changed files with 70 additions and 11 deletions
|
@ -1,49 +1,90 @@
|
||||||
using ABI.CCK.Components;
|
using ABI.CCK.Components;
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
|
using ABI_RC.Core.Savior;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ml_prm
|
namespace ml_prm
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
class RagdollTrigger : MonoBehaviour
|
public class RagdollTrigger : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
const string c_ragdollPointerType = "ragdoll";
|
||||||
|
|
||||||
Collider m_collider = null;
|
Collider m_collider = null;
|
||||||
Collider m_lastTrigger = null;
|
Collider m_lastColliderTrigger = null;
|
||||||
|
ParticleSystem m_lastParticleSystemTrigger = null;
|
||||||
bool m_triggered = false;
|
bool m_triggered = false;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
m_collider = this.GetComponent<Collider>();
|
m_collider = this.GetComponent<Collider>();
|
||||||
|
CVRParticlePointerManager.volumes.Add(new RagdollTriggerVolume() {
|
||||||
|
collider = m_collider,
|
||||||
|
trigger = this,
|
||||||
|
});
|
||||||
|
CVRParticlePointerManager.UpdateParticleSystems();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy() {
|
||||||
|
CVRParticlePointerManager.RemoveTrigger(m_collider);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if(!ReferenceEquals(m_lastTrigger, null))
|
if(!ReferenceEquals(m_lastColliderTrigger, null))
|
||||||
{
|
{
|
||||||
if(m_lastTrigger != null)
|
if(m_lastColliderTrigger != null)
|
||||||
{
|
{
|
||||||
if(!m_collider.bounds.Intersects(m_lastTrigger.bounds))
|
if(!m_collider.bounds.Intersects(m_lastColliderTrigger.bounds))
|
||||||
m_lastTrigger = null;
|
m_lastColliderTrigger = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_lastTrigger = null;
|
m_lastColliderTrigger = null;
|
||||||
|
}
|
||||||
|
if(!ReferenceEquals(m_lastParticleSystemTrigger, null))
|
||||||
|
{
|
||||||
|
if(m_lastParticleSystemTrigger != null)
|
||||||
|
{
|
||||||
|
if (m_lastParticleSystemTrigger.particleCount == 0)
|
||||||
|
m_lastParticleSystemTrigger = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_lastParticleSystemTrigger = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerEnter(Collider p_other)
|
void OnTriggerEnter(Collider p_other)
|
||||||
{
|
{
|
||||||
CVRPointer l_pointer = p_other.GetComponent<CVRPointer>();
|
CVRPointer l_pointer = p_other.GetComponent<CVRPointer>();
|
||||||
if((l_pointer != null) && (l_pointer.type == "ragdoll") && !IsIgnored(l_pointer.transform) && (m_lastTrigger != p_other))
|
if((l_pointer != null) && (l_pointer.type == c_ragdollPointerType) && !IsIgnored(l_pointer.transform) && (m_lastColliderTrigger != p_other))
|
||||||
{
|
{
|
||||||
m_lastTrigger = p_other;
|
m_lastColliderTrigger = p_other;
|
||||||
m_triggered = true;
|
m_triggered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerExit(Collider p_other)
|
void OnTriggerExit(Collider p_other)
|
||||||
{
|
{
|
||||||
if(m_lastTrigger == p_other)
|
if(m_lastColliderTrigger == p_other)
|
||||||
m_lastTrigger = null;
|
m_lastColliderTrigger = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPointerParticleEnter(CVRPointer p_pointer)
|
||||||
|
{
|
||||||
|
if (!gameObject.activeInHierarchy) return;
|
||||||
|
if ((p_pointer.type == c_ragdollPointerType) && !IsIgnored(p_pointer.transform) && (m_lastParticleSystemTrigger != p_pointer.particleSystem))
|
||||||
|
{
|
||||||
|
m_lastParticleSystemTrigger = p_pointer.particleSystem;
|
||||||
|
m_triggered = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPointerParticleExit(CVRPointer p_pointer)
|
||||||
|
{
|
||||||
|
// This seems to be very unreliable, and it's causing weird behavior
|
||||||
|
// if (!gameObject.activeInHierarchy) return;
|
||||||
|
// if(m_lastParticleSystemTrigger == p_pointer.particleSystem)
|
||||||
|
// m_lastParticleSystemTrigger = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetStateWithReset()
|
public bool GetStateWithReset()
|
||||||
|
|
14
ml_prm/RagdollTriggerVolume.cs
Normal file
14
ml_prm/RagdollTriggerVolume.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using ABI_RC.Core.Savior;
|
||||||
|
using ABI.CCK.Components;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ml_prm {
|
||||||
|
|
||||||
|
public class RagdollTriggerVolume : CVRTriggerVolume
|
||||||
|
{
|
||||||
|
public Collider collider { get; set; }
|
||||||
|
public RagdollTrigger trigger { get; set; }
|
||||||
|
public void TriggerEnter(CVRPointer pointer) => trigger.OnPointerParticleEnter(pointer);
|
||||||
|
public void TriggerExit(CVRPointer pointer) => trigger.OnPointerParticleExit(pointer);
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,6 +65,10 @@
|
||||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ParticleSystemModule">
|
||||||
|
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.ParticleSystemModule.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue