55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using NeoFPS.CharacterMotion;
|
|
using NeoFPS.CharacterMotion.Parameters;
|
|
|
|
namespace NeoFPS.CharacterMotion.Conditions
|
|
{
|
|
[MotionGraphElement("Parameters/Compare Integers")]
|
|
public class CompareIntsCondition : MotionGraphCondition
|
|
{
|
|
[SerializeField] private IntParameter m_PropertyA = null;
|
|
[SerializeField] private IntParameter m_PropertyB = null;
|
|
[SerializeField] private ComparisonType m_Comparison = ComparisonType.Equal;
|
|
|
|
public enum ComparisonType
|
|
{
|
|
Equal,
|
|
NotEqual,
|
|
Greater,
|
|
GreaterOrEqual,
|
|
Less,
|
|
LessOrEqual
|
|
}
|
|
|
|
public override bool CheckCondition(MotionGraphConnectable connectable)
|
|
{
|
|
if (m_PropertyA != null && m_PropertyB != null)
|
|
{
|
|
switch (m_Comparison)
|
|
{
|
|
case ComparisonType.Equal:
|
|
return m_PropertyA.value == m_PropertyB.value;
|
|
case ComparisonType.NotEqual:
|
|
return m_PropertyA.value != m_PropertyB.value;
|
|
case ComparisonType.Greater:
|
|
return m_PropertyA.value > m_PropertyB.value;
|
|
case ComparisonType.GreaterOrEqual:
|
|
return m_PropertyA.value >= m_PropertyB.value;
|
|
case ComparisonType.Less:
|
|
return m_PropertyA.value < m_PropertyB.value;
|
|
case ComparisonType.LessOrEqual:
|
|
return m_PropertyA.value <= m_PropertyB.value;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void CheckReferences(IMotionGraphMap map)
|
|
{
|
|
m_PropertyA = map.Swap(m_PropertyA);
|
|
m_PropertyB = map.Swap(m_PropertyB);
|
|
}
|
|
}
|
|
} |