Moved few Implemantations to Samples Folder

This commit is contained in:
2022-12-17 12:04:14 +03:00
parent e95462af00
commit c244ddeb98
13 changed files with 41 additions and 11 deletions

View File

@@ -1,7 +1,10 @@
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations
namespace Syntriax.Modules.Movement
{
/// <summary>
/// A <see cref="IMovement" with no implementation, added by <see cref="MovementController" by default as a fallback implementation/>/>
/// </summary>
public class DefaultMovement : MovementBase
{
public override void ApplyMovement() { }

View File

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

View File

@@ -1,49 +0,0 @@
using Syntriax.Modules.Trigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations
{
[RequireComponent(typeof(Rigidbody2D))]
public class AirMovement1D : MovementBase1D
{
protected override float moveValue { get; set; } = 0f;
protected IGroundTrigger groundTrigger = null;
protected Rigidbody2D rigid = null;
protected override void Start()
{
base.Start();
rigid = GetComponent<Rigidbody2D>();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
if (groundTrigger != null)
{
groundTrigger.OnTriggerStateChanged += OnGroundTrigger;
CanTakeOver = false;
}
}
private void OnGroundTrigger(bool isGrounded)
=> CanTakeOver = !isGrounded;
public override void ApplyMovement()
{
Vector2 velocity = rigid.velocity;
velocity.x += moveValue * Time.fixedDeltaTime;
if (moveValue != 0f)
{
if (Mathf.Abs(velocity.x) > Mathf.Abs(moveValue))
velocity.x = moveValue;
else if (Mathf.Abs(velocity.x - moveValue) > Mathf.Abs(moveValue))
velocity.x += moveValue * Time.fixedDeltaTime;
}
rigid.velocity = velocity;
}
protected override void OnDeactivated() { }
protected override void OnActivated() { }
}
}

View File

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

View File

@@ -1,42 +0,0 @@
using Syntriax.Modules.Trigger;
using UnityEngine;
namespace Syntriax.Modules.Movement.Implementations
{
[RequireComponent(typeof(Rigidbody2D))]
public class GroundMovement1D : MovementBase1D
{
protected override float moveValue { get; set; } = 0f;
protected IGroundTrigger groundTrigger = null;
protected Rigidbody2D rigid = null;
private void Awake() => CanTakeOver = true;
protected override void Start()
{
base.Start();
rigid = GetComponent<Rigidbody2D>();
groundTrigger = GetComponentInChildren<IGroundTrigger>();
if (groundTrigger != null)
{
groundTrigger.OnTriggerStateChanged += OnGroundTrigger;
CanTakeOver = false;
}
}
private void OnGroundTrigger(bool isGrounded)
=> CanTakeOver = isGrounded;
public override void ApplyMovement()
{
Vector2 velocity = rigid.velocity;
velocity.x = moveValue;
rigid.velocity = velocity;
}
protected override void OnDeactivated() { }
protected override void OnActivated() { }
}
}

View File

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

View File

@@ -41,8 +41,8 @@ namespace Syntriax.Modules.Movement
protected virtual void Start()
{
if (GetComponent<Implementations.DefaultMovement>() == null)
gameObject.AddComponent<Implementations.DefaultMovement>();
if (GetComponent<DefaultMovement>() == null)
gameObject.AddComponent<DefaultMovement>();
RecacheMovements();
toggleStateOnGameObject = GetComponent<IToggleState>();