/// <summary>
        /// Compare with another input.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public bool Compare(InputData input)
        {
            if (input.Inputs.Count != Inputs.Count)
            {
                return(false);
            }

            for (int i = 0; i < Inputs.Count; i++)
            {
                InputTypeBase data = Inputs[i];

                InputTypeBase other = input.Inputs[i];

                if (data.GetType() != other.GetType())
                {
                    return(false);
                }

                if (!data.Compare(other))
                {
                    return(false);
                }
            }

            return(true);
        }
        public void ReadData(byte[] data)
        {
            NetworkWriter writer = new NetworkWriter(data);

            Time = writer.ReadSingle();

            int count = writer.ReadInt16();

            for (int i = 0; i < count; i++)
            {
                InputTypeBase input  = (InputTypeBase)Activator.CreateInstance(m_ExpectedInputs[i]);
                int           bCount = writer.ReadInt16();
                input.Deserialize(writer.ReadBytes(bCount));
                Inputs.Add(input);
            }

            int simCount = writer.ReadInt16();

            for (int i = 0; i < simCount; i++)
            {
                float     time  = writer.ReadSingle();
                InputData input = new InputData(time)
                {
                    Inputs = this.Inputs
                };
                Similar.Add(input);
            }
        }
        public override bool Compare(InputTypeBase other)
        {
            if (other is FloatInput f)
            {
                return(f.Value == Value);
            }

            return(false);
        }
        public override bool Compare(InputTypeBase other)
        {
            if (other is TriggerInput v)
            {
                return(v.Value == Value);
            }

            return(false);
        }
        public override bool Compare(InputTypeBase other)
        {
            if (other is BoolInput b)
            {
                return(b.Value == Value);
            }

            return(false);
        }
        /// <summary>
        /// Collect input values.
        /// </summary>
        /// <param name="time">The timestamp.</param>
        public InputData GetInput(float time, bool add = true, bool overriteLast = false)
        {
            if (m_InputData == null)
            {
                m_InputData = new List <InputData>();
            }

            InputData data = new InputData(time);

            Build(data);

            if (m_InputData.Count > 0)
            {
                InputData last = m_InputData[m_InputData.Count - 1];

                for (int i = 0; i < last.Inputs.Count; i++)
                {
                    InputTypeBase inputType = last.Inputs[i];

                    if (inputType is TriggerInput t)
                    {
                        if (t.Value)
                        {
                            TriggerInput other = data.Inputs[i] as TriggerInput;

                            other.Value = t.Value;
                        }
                    }
                }

                if (overriteLast)
                {
                    m_InputData[m_InputData.Count - 1] = data;
                }

                if (last.Compare(data))
                {
                    if (add)
                    {
                        last.AddSimilar(data);
                    }
                    return(data);
                }
            }

            if (add)
            {
                m_InputData.Add(data);
            }

            return(data);
        }
        /// <summary>
        /// Retrieves the expected input types based on the <see cref="Build(InputData)"/> function.
        /// </summary>
        /// <returns></returns>
        private Type[] GetExpectedInputTypes()
        {
            if (m_ExpectedTypes != null)
            {
                return(m_ExpectedTypes);
            }

            InputData temp = new InputData();

            Build(temp);
            m_ExpectedTypes = new Type[temp.Inputs.Count];
            for (int i = 0; i < temp.Inputs.Count; i++)
            {
                InputTypeBase tempData = temp.Inputs[i];
                m_ExpectedTypes[i] = tempData.GetType();
            }

            return(m_ExpectedTypes);
        }
 /// <summary>
 /// Add an input.
 /// </summary>
 /// <param name="input"></param>
 public void Add(InputTypeBase input)
 {
     Inputs.Add(input);
 }
 public abstract bool Compare(InputTypeBase other);