Files Moved from Movement

This commit is contained in:
Syntriax 2022-11-14 12:15:32 +03:00
parent 77e48938d6
commit 4f2217bb63
16 changed files with 177 additions and 0 deletions

25
Box2DColliderTrigger.cs Normal file
View File

@ -0,0 +1,25 @@
using UnityEngine;
namespace Syntriax.Modules.Trigger
{
public class Box2DColliderTrigger : Trigger, IColliderTrigger
{
private Collider2D[] results = new Collider2D[8];
public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; }
[SerializeField] private LayerMask colliderMask = 0;
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
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20a6baf9a256917448a4d7ad09d0c51a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Ground.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8747cc51a59e7a14fae4687c7136d15b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,4 @@
namespace Syntriax.Modules.Trigger
{
public class Box2DGroundTrigger : Box2DColliderTrigger, IGroundTrigger { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7804f3e8384c7a54482f585b4f43264a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

4
Ground/IGroundTrigger.cs Normal file
View File

@ -0,0 +1,4 @@
namespace Syntriax.Modules.Trigger
{
public interface IGroundTrigger : IColliderTrigger { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8dc876763de82b74cb9a05685d57e841
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
namespace Syntriax.Modules.Trigger
{
public static class IColliderTriggerExtensions
{
public static bool IsTriggeredNullChecked(this IColliderTrigger colliderCheck)
=> colliderCheck == null ? true : colliderCheck.IsTrigerred;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d1b41d4e3ee5ce24eaef42d5c8fc8c3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
IColliderTrigger.cs Normal file
View File

@ -0,0 +1,9 @@
using UnityEngine;
namespace Syntriax.Modules.Trigger
{
public interface IColliderTrigger : ITrigger
{
LayerMask ColliderMask { get; set; }
}
}

11
IColliderTrigger.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e199ccade2250b646abfd859e4aa1e7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

10
ITrigger.cs Normal file
View File

@ -0,0 +1,10 @@
using System;
namespace Syntriax.Modules.Trigger
{
public interface ITrigger
{
bool IsTrigerred { get; }
Action<bool> OnTriggered { get; set; }
}
}

11
ITrigger.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7c3dcc511ff3a4b4ca6777800f34d17c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
README.md.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 44cae1d5afff6464cb93313a45605b8f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

25
Trigger.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using UnityEngine;
namespace Syntriax.Modules.Trigger
{
public class Trigger : MonoBehaviour, ITrigger
{
private bool _isTrigerred = false;
public Action<bool> OnTriggered { get; set; } = null;
public bool IsTrigerred
{
get => _isTrigerred;
protected set
{
bool oldValue = _isTrigerred;
_isTrigerred = value;
if (oldValue != value)
OnTriggered?.Invoke(value);
}
}
}
}

11
Trigger.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e3718079b1e1024a997ca7eaa425903
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: