0.4.0
This commit is contained in:
commit
ac1cdfec18
|
@ -4,11 +4,11 @@ namespace Syntriax.Modules.Trigger
|
||||||
{
|
{
|
||||||
public class ColliderTrigger : TriggerBase
|
public class ColliderTrigger : TriggerBase
|
||||||
{
|
{
|
||||||
protected IColliderTrigger colliderTrigger = null;
|
protected IColliderTriggerArea colliderTrigger = null;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
colliderTrigger = GetComponent<IColliderTrigger>();
|
colliderTrigger = GetComponent<IColliderTriggerArea>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
|
|
|
@ -4,15 +4,14 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace Syntriax.Modules.Trigger
|
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 Collider2D[] nonAllocResults = new Collider2D[32];
|
||||||
protected int previousTriggerCount = 0;
|
protected int previousTriggerCount = 0;
|
||||||
|
|
||||||
public LayerMask ColliderMask { get; set; } = ~0;
|
public LayerMask ColliderMask { get; set; } = ~0;
|
||||||
public Action<List<Collider2D>> OnTriggeredCollidersUpdated { get; set; } = null;
|
public Action<List<Collider2D>> OnTriggeredCollidersUpdated { get; set; } = null;
|
||||||
|
public List<Collider2D> ColliderList { get; protected set; } = new List<Collider2D>(32);
|
||||||
|
|
||||||
protected abstract int TriggerCount { get; }
|
protected abstract int TriggerCount { get; }
|
||||||
|
|
||||||
|
@ -22,11 +21,11 @@ namespace Syntriax.Modules.Trigger
|
||||||
|
|
||||||
if (triggerCount != previousTriggerCount)
|
if (triggerCount != previousTriggerCount)
|
||||||
{
|
{
|
||||||
results.Clear();
|
ColliderList.Clear();
|
||||||
for (int i = 0; i < triggerCount; i++)
|
for (int i = 0; i < triggerCount; i++)
|
||||||
results.Add(nonAllocResults[i]);
|
ColliderList.Add(nonAllocResults[i]);
|
||||||
|
|
||||||
OnTriggeredCollidersUpdated?.Invoke(results);
|
OnTriggeredCollidersUpdated?.Invoke(ColliderList);
|
||||||
}
|
}
|
||||||
|
|
||||||
previousTriggerCount = triggerCount;
|
previousTriggerCount = triggerCount;
|
||||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace Syntriax.Modules.Trigger
|
namespace Syntriax.Modules.Trigger
|
||||||
{
|
{
|
||||||
public interface IColliderTrigger : ITriggerArea
|
public interface IColliderTriggerArea : ITriggerArea
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="LayerMask"/> value for checking triggers
|
/// <see cref="LayerMask"/> value for checking triggers
|
||||||
|
@ -14,7 +14,10 @@ namespace Syntriax.Modules.Trigger
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called whenever the list of <see cref="Collider2D"/> changes
|
/// Called whenever the list of <see cref="Collider2D"/> changes
|
||||||
/// </summary>
|
/// </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; }
|
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
|
fileFormatVersion: 2
|
||||||
guid: a101e5476051bb74b8012198b1594327
|
guid: efbbfd3aba8fb5843a26ed5446050b32
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.syntriax.trigger",
|
"name": "com.syntriax.trigger",
|
||||||
"version": "0.3.0",
|
"version": "0.4.0",
|
||||||
"displayName": "Trigger Module",
|
"displayName": "Trigger Module",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"documentationUrl": "https://git.syntriax.com/Syntriax/Trigger.git",
|
"documentationUrl": "https://git.syntriax.com/Syntriax/Trigger.git",
|
||||||
|
|
Loading…
Reference in New Issue