2022-02-19 15:03:06 +03:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation
|
|
|
|
{
|
|
|
|
public class SimpleVariableMovementController : MonoBehaviour, IVariableMovementController
|
|
|
|
{
|
2022-02-19 16:49:34 +03:00
|
|
|
protected IVariableMovement _defaultVariableMovement = new SimpleVariableMovement();
|
|
|
|
protected IVariableMovementCollection _variableMovementCollection = null;
|
2022-02-19 15:03:06 +03:00
|
|
|
|
|
|
|
public bool StateEnabled { get; set; } = false;
|
|
|
|
|
|
|
|
public List<IVariableMovement> VariableMovements { get; protected set; } = new List<IVariableMovement>();
|
2022-02-19 16:49:34 +03:00
|
|
|
|
|
|
|
public IVariableMovementCollection VariableMovementCollection
|
|
|
|
{
|
|
|
|
get => _variableMovementCollection;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_variableMovementCollection = value;
|
|
|
|
|
|
|
|
VariableMovements.Clear();
|
|
|
|
|
|
|
|
_defaultVariableMovement.VariableMovementAsset = value.DefaultVariableMovementsAsset;
|
|
|
|
_defaultVariableMovement.StateEnabled = true;
|
|
|
|
|
|
|
|
if (VariableMovements.Capacity < value.VariableMovementsAssets.Count)
|
|
|
|
VariableMovements.Capacity = value.VariableMovementsAssets.Count;
|
|
|
|
|
|
|
|
foreach (var asset in value.VariableMovementsAssets)
|
|
|
|
VariableMovements.Add(new SimpleVariableMovement(asset));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-19 15:03:06 +03:00
|
|
|
public IVariableMovement CurrentVariableMovement
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (!StateEnabled)
|
2022-02-19 16:49:34 +03:00
|
|
|
return _defaultVariableMovement;
|
2022-02-19 15:03:06 +03:00
|
|
|
|
|
|
|
foreach (IVariableMovement variableMovement in VariableMovements)
|
|
|
|
if (variableMovement.StateEnabled)
|
|
|
|
return variableMovement;
|
|
|
|
|
2022-02-19 16:49:34 +03:00
|
|
|
return _defaultVariableMovement;
|
2022-02-19 15:03:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|