// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.MixedReality.Toolkit.UI
{
///
/// State data model, state management and comparison instructions
///
[System.Serializable]
public class State
{
///
/// Name of state
///
public string Name;
///
/// Index of State in all available state list
///
public int Index;
///
/// Bitwise value of state for comparison
///
public int Bit;
///
/// Current value of state (e.g on/off etc)
///
public int Value;
///
/// Index of state in current list
///
public int ActiveIndex;
public override string ToString()
{
return Name;
}
[System.Obsolete("Use Index property")]
public int ToInt()
{
return Index;
}
[System.Obsolete("Use Bit property")]
public int ToBit()
{
return Bit;
}
///
/// Create copy of current State with identical values
///
/// copied instance of this State
public State Copy()
{
return new State()
{
ActiveIndex = this.ActiveIndex,
Bit = this.Bit,
Index = this.Index,
Name = this.Name,
Value = this.Value,
};
}
///
/// Returns true if two state objects have identical internal values, false otherwise
///
/// other State object to compare against
/// true if identical internal values, false otherwise
public bool CompareState(State s)
{
if (s == null)
{
return false;
}
return this.Name == s.Name
&& this.Index == s.Index
&& this.Bit == s.Bit
&& this.Value == s.Value
&& this.ActiveIndex == s.ActiveIndex;
}
}
}