Unity Package Structure
This commit is contained in:
24
Runtime/Box2DColliderTrigger.cs
Normal file
24
Runtime/Box2DColliderTrigger.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
|
||||
public class Box2DColliderTrigger : Trigger, IColliderTrigger
|
||||
{
|
||||
public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; }
|
||||
[SerializeField] private LayerMask colliderMask = 0;
|
||||
|
||||
private Collider2D[] results = new Collider2D[8];
|
||||
|
||||
protected void FixedUpdate()
|
||||
=> IsTrigerred = Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, results, ColliderMask) > 0;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = IsTrigerred ? Color.green : Color.red;
|
||||
Gizmos.DrawWireCube(transform.position, transform.lossyScale);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Runtime/Box2DColliderTrigger.cs.meta
Normal file
11
Runtime/Box2DColliderTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20a6baf9a256917448a4d7ad09d0c51a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Runtime/Box2DColliderTriggerWithRotation.cs
Normal file
25
Runtime/Box2DColliderTriggerWithRotation.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
|
||||
public class Box2DColliderTriggerWithRotation : Trigger, IColliderTrigger
|
||||
{
|
||||
public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; }
|
||||
[SerializeField] private LayerMask colliderMask = 0;
|
||||
|
||||
private Collider2D[] results = new Collider2D[8];
|
||||
|
||||
protected void FixedUpdate()
|
||||
=> IsTrigerred = Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, transform.rotation.eulerAngles.z, results, ColliderMask) > 0;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = IsTrigerred ? Color.green : Color.red;
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireCube(Vector3.zero, Vector3.one);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Runtime/Box2DColliderTriggerWithRotation.cs.meta
Normal file
11
Runtime/Box2DColliderTriggerWithRotation.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e56ea33695c0c83438ea8b7bf11d1cf8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Runtime/Ground.meta
Normal file
8
Runtime/Ground.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8747cc51a59e7a14fae4687c7136d15b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4
Runtime/Ground/Box2DGroundTrigger.cs
Normal file
4
Runtime/Ground/Box2DGroundTrigger.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public class Box2DGroundTrigger : Box2DColliderTrigger, IGroundTrigger { }
|
||||
}
|
11
Runtime/Ground/Box2DGroundTrigger.cs.meta
Normal file
11
Runtime/Ground/Box2DGroundTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7804f3e8384c7a54482f585b4f43264a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4
Runtime/Ground/Box2DGroundTriggerWithRotation.cs
Normal file
4
Runtime/Ground/Box2DGroundTriggerWithRotation.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public class Box2DGroundTriggerWithRotation : Box2DColliderTriggerWithRotation, IGroundTrigger { }
|
||||
}
|
11
Runtime/Ground/Box2DGroundTriggerWithRotation.cs.meta
Normal file
11
Runtime/Ground/Box2DGroundTriggerWithRotation.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b544fd215b0df4192a7889e6f2db4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4
Runtime/Ground/IGroundTrigger.cs
Normal file
4
Runtime/Ground/IGroundTrigger.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public interface IGroundTrigger : IColliderTrigger { }
|
||||
}
|
11
Runtime/Ground/IGroundTrigger.cs.meta
Normal file
11
Runtime/Ground/IGroundTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dc876763de82b74cb9a05685d57e841
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Runtime/IColliderTrigger.cs
Normal file
9
Runtime/IColliderTrigger.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public interface IColliderTrigger : ITrigger
|
||||
{
|
||||
LayerMask ColliderMask { get; set; }
|
||||
}
|
||||
}
|
11
Runtime/IColliderTrigger.cs.meta
Normal file
11
Runtime/IColliderTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e199ccade2250b646abfd859e4aa1e7a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Runtime/ITrigger.cs
Normal file
14
Runtime/ITrigger.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public interface ITrigger
|
||||
{
|
||||
/// <summary>
|
||||
/// Called everytime the IsTrigerred field is changed
|
||||
/// </summary>
|
||||
/// <value>The new value of IsTrigerred</value>
|
||||
Action<bool> OnTriggered { get; set; }
|
||||
bool IsTrigerred { get; }
|
||||
}
|
||||
}
|
11
Runtime/ITrigger.cs.meta
Normal file
11
Runtime/ITrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c3dcc511ff3a4b4ca6777800f34d17c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Runtime/ITriggerExtensions.cs
Normal file
14
Runtime/ITriggerExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public static class ITriggerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the provided parameter ITrigger is toggled, if the parameter is null returns the nullValue parameter
|
||||
/// </summary>
|
||||
/// <param name="trigger">ITrigger to be checked if toggled or not</param>
|
||||
/// <param name="nullValue">The value that will be returned if toggleState is null. Default value: true</param>
|
||||
/// <returns>ITrigger's toggle value, or if null return nullValue parameter</returns>
|
||||
public static bool IsTriggeredNullChecked(this ITrigger trigger, bool nullValue = true)
|
||||
=> trigger == null ? nullValue : trigger.IsTrigerred;
|
||||
}
|
||||
}
|
11
Runtime/ITriggerExtensions.cs.meta
Normal file
11
Runtime/ITriggerExtensions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4664637bbd2ba574c85953b5c5d67598
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Runtime/Syntriax.Modules.Trigger.asmdef
Normal file
3
Runtime/Syntriax.Modules.Trigger.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "Syntriax.Modules.Trigger"
|
||||
}
|
7
Runtime/Syntriax.Modules.Trigger.asmdef.meta
Normal file
7
Runtime/Syntriax.Modules.Trigger.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f5f15fe7e49bdb48a76c5ce9b1c9f2f
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Runtime/Trigger.cs
Normal file
24
Runtime/Trigger.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Trigger
|
||||
{
|
||||
public class Trigger : MonoBehaviour, ITrigger
|
||||
{
|
||||
public Action<bool> OnTriggered { get; set; } = null;
|
||||
|
||||
private bool _isTrigerred = false;
|
||||
public bool IsTrigerred
|
||||
{
|
||||
get => _isTrigerred;
|
||||
protected set
|
||||
{
|
||||
if (value == _isTrigerred)
|
||||
return;
|
||||
|
||||
_isTrigerred = value;
|
||||
OnTriggered?.Invoke(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Runtime/Trigger.cs.meta
Normal file
11
Runtime/Trigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e3718079b1e1024a997ca7eaa425903
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user