PseudoState.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. namespace Wayne.Lib.StateEngine.Generic
  2. {
  3. /// <summary>
  4. /// Generic pseudo state class that has a main object of a generic type.
  5. /// </summary>
  6. /// <typeparam name="TMain">Specifies the type of the main object.</typeparam>
  7. /// <typeparam name="TData">Specifies the type of state data the state uses.</typeparam>
  8. public abstract class PseudoState<TMain, TData> : PseudoState<TMain> where TData : StateData
  9. {
  10. #region Fields
  11. private IStateWithData dataCompositeState;
  12. #endregion
  13. #region Properties
  14. /// <summary>
  15. /// Gets the state data for this state.
  16. /// </summary>
  17. protected TData Data
  18. {
  19. get
  20. {
  21. if (dataCompositeState == null)
  22. {
  23. dataCompositeState = StateData.GetParentCompositeStateWithStateData<TData>(this);
  24. }
  25. return dataCompositeState.StateData as TData;
  26. }
  27. }
  28. #endregion
  29. }
  30. }