2020-03-01 20:26:06 -05:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityAtoms.BaseAtoms;
|
2019-10-15 19:43:51 -04:00
|
|
|
|
2020-03-01 20:26:06 -05:00
|
|
|
namespace UnityAtoms.MonoHooks
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Base class for all `MonoHook`s of type `Collider2D`.
|
|
|
|
/// </summary>
|
|
|
|
[EditorIcon("atom-icon-delicate")]
|
|
|
|
public abstract class Collider2DHook : MonoHook<
|
|
|
|
Collider2DEvent,
|
|
|
|
Collider2D,
|
2020-03-02 13:52:08 -05:00
|
|
|
Collider2DEventReference,
|
2020-03-01 20:26:06 -05:00
|
|
|
GameObjectGameObjectFunction>
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Event including a GameObject reference.
|
|
|
|
/// </summary>
|
2020-03-02 13:52:08 -05:00
|
|
|
public Collider2DGameObjectEvent EventWithGameObject
|
|
|
|
{
|
|
|
|
get => _eventWithGameObjectReference != null ? _eventWithGameObjectReference.GetEvent<Collider2DGameObjectEvent>() : null;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (_eventWithGameObjectReference != null)
|
|
|
|
{
|
|
|
|
_eventWithGameObjectReference.SetEvent<Collider2DGameObjectEvent>(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-01 20:26:06 -05:00
|
|
|
|
|
|
|
[SerializeField]
|
2020-03-02 14:27:38 -05:00
|
|
|
private Collider2DGameObjectEventReference _eventWithGameObjectReference = default(Collider2DGameObjectEventReference);
|
2020-03-01 20:26:06 -05:00
|
|
|
|
|
|
|
protected override void RaiseWithGameObject(Collider2D value, GameObject gameObject)
|
|
|
|
{
|
2020-03-02 13:52:08 -05:00
|
|
|
if (EventWithGameObject)
|
2020-03-02 13:36:52 -05:00
|
|
|
{
|
2020-03-02 13:52:08 -05:00
|
|
|
EventWithGameObject.Raise(new Collider2DGameObject() { Collider2D = value, GameObject = gameObject });
|
2020-03-02 13:36:52 -05:00
|
|
|
}
|
2020-03-01 20:26:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|