Fixed Mistakes

This commit is contained in:
Syntriax 2022-11-14 14:28:00 +03:00
parent 330a41a87f
commit b7fafaa09f
3 changed files with 7 additions and 8 deletions

View File

@ -5,15 +5,14 @@ namespace Syntriax.Modules.Trigger
public class Box2DColliderTrigger : Trigger, IColliderTrigger public class Box2DColliderTrigger : Trigger, IColliderTrigger
{ {
private Collider2D[] results = new Collider2D[8];
public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; } public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; }
[SerializeField] private LayerMask colliderMask = 0; [SerializeField] private LayerMask colliderMask = 0;
private Collider2D[] results = new Collider2D[8];
protected void FixedUpdate() protected void FixedUpdate()
=> IsTrigerred = Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, results, ColliderMask) > 0; => IsTrigerred = Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, results, ColliderMask) > 0;
#if UNITY_EDITOR #if UNITY_EDITOR
private void OnDrawGizmosSelected() private void OnDrawGizmosSelected()
{ {

View File

@ -4,7 +4,11 @@ namespace Syntriax.Modules.Trigger
{ {
public interface ITrigger public interface ITrigger
{ {
bool IsTrigerred { get; } /// <summary>
/// Called everytime the IsTrigerred field is changed
/// </summary>
/// <value>The new value of IsTrigerred</value>
Action<bool> OnTriggered { get; set; } Action<bool> OnTriggered { get; set; }
bool IsTrigerred { get; }
} }
} }

View File

@ -5,10 +5,6 @@ namespace Syntriax.Modules.Trigger
{ {
public class Trigger : MonoBehaviour, ITrigger public class Trigger : MonoBehaviour, ITrigger
{ {
/// <summary>
/// Called everytime the IsTrigerred field is changed
/// </summary>
/// <value>The new value of IsTrigerred</value>
public Action<bool> OnTriggered { get; set; } = null; public Action<bool> OnTriggered { get; set; } = null;
private bool _isTrigerred = false; private bool _isTrigerred = false;