Merge branch 'development'
This commit is contained in:
commit
3ccaea0434
|
@ -4,11 +4,11 @@ namespace Syntriax.Modules.Trigger
|
|||
{
|
||||
public class ColliderTrigger : TriggerBase
|
||||
{
|
||||
protected IColliderTrigger colliderTrigger = null;
|
||||
protected IColliderTriggerArea colliderTrigger = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
colliderTrigger = GetComponent<IColliderTrigger>();
|
||||
colliderTrigger = GetComponent<IColliderTriggerArea>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
|
|
|
@ -4,15 +4,14 @@ using UnityEngine;
|
|||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public abstract class ColliderTriggerAreaBase : MonoBehaviour, IColliderTrigger
|
||||
public abstract class ColliderTriggerAreaBase : MonoBehaviour, IColliderTriggerArea
|
||||
{
|
||||
protected List<Collider2D> results = new List<Collider2D>(32);
|
||||
|
||||
protected Collider2D[] nonAllocResults = new Collider2D[32];
|
||||
protected int previousTriggerCount = 0;
|
||||
|
||||
public LayerMask ColliderMask { get; set; } = ~0;
|
||||
public Action<List<Collider2D>> OnTriggeredCollidersUpdated { get; set; } = null;
|
||||
public List<Collider2D> ColliderList { get; protected set; } = new List<Collider2D>(32);
|
||||
|
||||
protected abstract int TriggerCount { get; }
|
||||
|
||||
|
@ -22,11 +21,11 @@ namespace Syntriax.Modules.Trigger
|
|||
|
||||
if (triggerCount != previousTriggerCount)
|
||||
{
|
||||
results.Clear();
|
||||
ColliderList.Clear();
|
||||
for (int i = 0; i < triggerCount; i++)
|
||||
results.Add(nonAllocResults[i]);
|
||||
ColliderList.Add(nonAllocResults[i]);
|
||||
|
||||
OnTriggeredCollidersUpdated?.Invoke(results);
|
||||
OnTriggeredCollidersUpdated?.Invoke(ColliderList);
|
||||
}
|
||||
|
||||
previousTriggerCount = triggerCount;
|
||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
|||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public interface IColliderTrigger : ITriggerArea
|
||||
public interface IColliderTriggerArea : ITriggerArea
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="LayerMask"/> value for checking triggers
|
||||
|
@ -14,7 +14,10 @@ namespace Syntriax.Modules.Trigger
|
|||
/// <summary>
|
||||
/// Called whenever the list of <see cref="Collider2D"/> changes
|
||||
/// </summary>
|
||||
/// <value>List of <see cref="Collider2D"/> that triggered the <see cref="IColliderTrigger"/></value>
|
||||
/// <value>List of <see cref="Collider2D"/> that triggered the <see cref="IColliderTriggerArea"/></value>
|
||||
Action<List<Collider2D>> OnTriggeredCollidersUpdated { get; set; }
|
||||
|
||||
/// <value>List of <see cref="Collider2D"/> that triggered the <see cref="IColliderTriggerArea"/></value>
|
||||
List<Collider2D> ColliderList { get; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a101e5476051bb74b8012198b1594327
|
||||
guid: efbbfd3aba8fb5843a26ed5446050b32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
Loading…
Reference in New Issue