Added Error Reporting & Updated The Submodules & Bug Fixes
This commit is contained in:
parent
062c3015ed
commit
19a061c1d6
|
@ -24,7 +24,7 @@ namespace Syntriax.Modules.Movement
|
||||||
_canTakeOver = value;
|
_canTakeOver = value;
|
||||||
|
|
||||||
if (isNewValue)
|
if (isNewValue)
|
||||||
OnTakeOverStateChanged.Invoke(value);
|
OnTakeOverStateChanged?.Invoke(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace Syntriax.Modules.Movement
|
||||||
_activeMovement = value;
|
_activeMovement = value;
|
||||||
|
|
||||||
if (oldMovement != null)
|
if (oldMovement != null)
|
||||||
OnMovementDeactivated.Invoke(oldMovement);
|
OnMovementDeactivated?.Invoke(oldMovement);
|
||||||
OnMovementActivated.Invoke(value);
|
OnMovementActivated?.Invoke(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,38 +34,38 @@ namespace Syntriax.Modules.Movement
|
||||||
protected IToggleState toggleState = null;
|
protected IToggleState toggleState = null;
|
||||||
|
|
||||||
protected virtual void Awake()
|
protected virtual void Awake()
|
||||||
{
|
=> Movements = new List<IMovement>(32);
|
||||||
Movements = new List<IMovement>(32);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Start()
|
protected virtual void Start()
|
||||||
{
|
{
|
||||||
toggleState = GetComponent<IToggleState>();
|
|
||||||
RecacheMovements();
|
RecacheMovements();
|
||||||
|
toggleState = GetComponent<IToggleState>();
|
||||||
|
if (toggleState == null)
|
||||||
|
Debug.LogError("Movement Controller component needs one Monobehaviour attached that implements IToggleState interface", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void FixedUpdate()
|
protected virtual void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (!toggleState.Toggled)
|
if (!toggleState.IsToggledNullChecked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ActiveMovement.ApplyMovement();
|
ActiveMovement?.ApplyMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RecacheMovements()
|
public virtual void RecacheMovements()
|
||||||
{
|
{
|
||||||
foreach (IMovement movement in Movements)
|
foreach (IMovement movement in Movements)
|
||||||
movement.OnTakeOverStateChanged -= OnTakeOverListener;
|
movement.OnTakeOverStateChanged -= OnTakeOver;
|
||||||
|
|
||||||
Movements.Clear();
|
Movements.Clear();
|
||||||
GetComponents<IMovement>(Movements);
|
GetComponents<IMovement>(Movements);
|
||||||
UpdateActiveMovement();
|
UpdateActiveMovement();
|
||||||
|
|
||||||
foreach (IMovement movement in Movements)
|
foreach (IMovement movement in Movements)
|
||||||
movement.OnTakeOverStateChanged += OnTakeOverListener;
|
movement.OnTakeOverStateChanged += OnTakeOver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTakeOverListener(bool arg0) => UpdateActiveMovement();
|
private void OnTakeOver(bool arg0) => UpdateActiveMovement();
|
||||||
|
|
||||||
protected virtual void UpdateActiveMovement()
|
protected virtual void UpdateActiveMovement()
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,8 @@ namespace Syntriax.Modules.Movement
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMovement = Movements[Movements.Count - 1];
|
try { ActiveMovement = Movements[Movements.Count - 1]; }
|
||||||
|
catch (System.Exception) { Debug.LogError("Movement Controller component needs at least one Monobehaviour attached that implements IMovement interface", this); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7574769637791a9bd8c8f7559b579e5968a308ae
|
Subproject commit 463182ab43595e92fcdb5d51be815d13e473c6a3
|
2
Trigger
2
Trigger
|
@ -1 +1 @@
|
||||||
Subproject commit 4f2217bb63ee3584a841e2f8c7d9e484d816ec33
|
Subproject commit 330a41a87ffacfda51465a2937ee5ce170bf6b72
|
Loading…
Reference in New Issue