using System.Collections.Generic; using UnityEngine; namespace Syntriax.Modules.Movement.VariableMovement.SimpleImplementation { public class SimpleVariableMovementController : MonoBehaviour, IVariableMovementController { protected IVariableMovement _defaultVariableMovement = new SimpleVariableMovement(); protected IVariableMovementCollection _variableMovementCollection = null; public bool StateEnabled { get; set; } = false; public List VariableMovements { get; protected set; } = new List(); 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)); } } public IVariableMovement CurrentVariableMovement { get { if (!StateEnabled) return _defaultVariableMovement; foreach (IVariableMovement variableMovement in VariableMovements) if (variableMovement.StateEnabled) return variableMovement; return _defaultVariableMovement; } } } }