actionvariantsmanager.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. class ActionVariantManager
  2. {
  3. protected ref array<ref ActionBase> m_VariantActions;
  4. protected typename m_type;
  5. protected ref ScriptInvoker e_OnUpdate;
  6. void ActionVariantManager( typename type )
  7. {
  8. m_type = type;
  9. m_VariantActions = new array<ref ActionBase>;
  10. e_OnUpdate = new ScriptInvoker();
  11. }
  12. ScriptInvoker GetOnUpdateInvoker()
  13. {
  14. return e_OnUpdate;
  15. }
  16. void Clear()
  17. {
  18. m_VariantActions.Clear();
  19. }
  20. void SetActionVariantCount( int count )
  21. {
  22. if ( count < m_VariantActions.Count() )
  23. {
  24. m_VariantActions.Clear();
  25. }
  26. for (int i = m_VariantActions.Count(); i < count; i++ )
  27. {
  28. ActionBase action = ActionManagerBase.GetActionVariant( m_type );
  29. action.SetVariantID(i);
  30. m_VariantActions.Insert(action);
  31. }
  32. }
  33. int GetActions( out array<ref ActionBase> variants_action)
  34. {
  35. variants_action = m_VariantActions;
  36. return m_VariantActions.Count();
  37. }
  38. int GetActionsCount()
  39. {
  40. return m_VariantActions.Count();
  41. }
  42. void UpdateVariants( Object item, Object target, int componet_index )
  43. {
  44. e_OnUpdate.Invoke( item, target, componet_index );
  45. }
  46. }