Unity Package Structure
This commit is contained in:
77
Runtime/Bases/MovementBase.cs
Normal file
77
Runtime/Bases/MovementBase.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement
|
||||
{
|
||||
public abstract class MovementBase : MonoBehaviour, IMovement
|
||||
{
|
||||
protected IToggleState toggleState = null;
|
||||
protected IMovementController movementController = null;
|
||||
|
||||
public float BaseSpeed { get; set; } = 1f;
|
||||
public float MovementMultiplier { get; set; } = 1f;
|
||||
|
||||
public Action<bool> OnTakeOverStateChanged { get; set; } = null;
|
||||
private bool _canTakeOver = false;
|
||||
public bool CanTakeOver
|
||||
{
|
||||
get => _canTakeOver;
|
||||
protected set
|
||||
{
|
||||
if (value == _canTakeOver)
|
||||
return;
|
||||
|
||||
_canTakeOver = value;
|
||||
OnTakeOverStateChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
public IToggleState ToggleState { get; protected set; } = null;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void ApplyMovement();
|
||||
|
||||
public abstract void Move(float x = 0, float y = 0, float z = 0);
|
||||
|
||||
/// <summary>
|
||||
/// Called when this <see cref="IMovement"/> is activated.
|
||||
/// </summary>
|
||||
protected abstract void OnActivated();
|
||||
|
||||
/// <summary>
|
||||
/// Called when this <see cref="IMovement"/> is deactivated.
|
||||
/// </summary>
|
||||
protected abstract void OnDeactivated();
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
toggleState = GetComponent<IToggleState>();
|
||||
movementController = GetComponent<IMovementController>();
|
||||
|
||||
movementController.OnMovementActivated += OnActivated;
|
||||
movementController.OnMovementDeactivated += OnDeactivated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="IMovementController"/> activates one of it's <see cref="IMovement"/>s.
|
||||
/// </summary>
|
||||
private void OnActivated(IMovement movement)
|
||||
{
|
||||
if ((object)movement != this)
|
||||
return;
|
||||
OnActivated();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="IMovementController"/> activates one of it's <see cref="IMovement"/>s.
|
||||
/// </summary>
|
||||
private void OnDeactivated(IMovement movement)
|
||||
{
|
||||
if ((object)movement != this)
|
||||
return;
|
||||
OnDeactivated();
|
||||
}
|
||||
}
|
||||
}
|
11
Runtime/Bases/MovementBase.cs.meta
Normal file
11
Runtime/Bases/MovementBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d471aae4aaf4636459646d73603689e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
10
Runtime/Bases/MovementBase1D.cs
Normal file
10
Runtime/Bases/MovementBase1D.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Syntriax.Modules.Movement
|
||||
{
|
||||
public abstract class MovementBase1D : MovementBase
|
||||
{
|
||||
protected abstract float moveValue { get; set; }
|
||||
|
||||
public override void Move(float x = 0, float y = 0, float z = 0)
|
||||
=> moveValue = x * BaseSpeed * MovementMultiplier;
|
||||
}
|
||||
}
|
11
Runtime/Bases/MovementBase1D.cs.meta
Normal file
11
Runtime/Bases/MovementBase1D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 938515a22b53ad6468e4152f1328b6ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Runtime/Bases/MovementBase2D.cs
Normal file
12
Runtime/Bases/MovementBase2D.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement
|
||||
{
|
||||
public abstract class MovementBase2D : MovementBase
|
||||
{
|
||||
protected abstract Vector2 moveValue { get; set; }
|
||||
|
||||
public override void Move(float x = 0, float y = 0, float z = 0)
|
||||
=> moveValue = new Vector2(x, y) * BaseSpeed * MovementMultiplier;
|
||||
}
|
||||
}
|
11
Runtime/Bases/MovementBase2D.cs.meta
Normal file
11
Runtime/Bases/MovementBase2D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 408740142766625499af221fe7c964ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Runtime/Bases/MovementBase3D.cs
Normal file
12
Runtime/Bases/MovementBase3D.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Movement
|
||||
{
|
||||
public abstract class MovementBase3D : MovementBase
|
||||
{
|
||||
protected abstract Vector3 moveValue { get; set; }
|
||||
|
||||
public override void Move(float x = 0, float y = 0, float z = 0)
|
||||
=> moveValue = new Vector3(x, y, z) * BaseSpeed * MovementMultiplier;
|
||||
}
|
||||
}
|
11
Runtime/Bases/MovementBase3D.cs.meta
Normal file
11
Runtime/Bases/MovementBase3D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c60740cee0555543b46e6417ce6daca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user