r2mods/ilspy_dump/ror2_csproj/RoR2/DisableCollisionsIfInTrigge...

32 lines
732 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
namespace RoR2;
[RequireComponent(typeof(SphereCollider))]
public class DisableCollisionsIfInTrigger : MonoBehaviour
{
public Collider colliderToIgnore;
private SphereCollider trigger;
public void Awake()
{
trigger = GetComponent<SphereCollider>();
}
private void OnTriggerEnter(Collider other)
{
if ((bool)trigger)
{
Vector3 position = base.transform.position;
Vector3 position2 = other.transform.position;
float num = trigger.radius * Mathf.Max(base.transform.lossyScale.x, base.transform.lossyScale.y, base.transform.lossyScale.z);
float num2 = num * num;
if ((position - position2).sqrMagnitude < num2)
{
Physics.IgnoreCollision(colliderToIgnore, other);
}
}
}
}