playerlightmanager.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. class ActionTargetLighSource : ActionTarget
  2. {
  3. bool m_Remove;
  4. }
  5. //WIP
  6. class PlayerLightManager
  7. {
  8. int m_SelectedLightSource;
  9. ref ActionTargetLighSource m_LightItemTarget;
  10. ref array<ref ActionTarget> m_ValidLightItems;
  11. PlayerBase m_Player;
  12. void PlayerLightManager(PlayerBase player)
  13. {
  14. m_LightItemTarget = null;
  15. m_ValidLightItems = new array<ref ActionTarget>;
  16. m_Player = player;
  17. }
  18. // can be anything, as long as it has appropriate actions for handling lights, see Mich2001Helmet
  19. void AddLightSource(Object object)
  20. {
  21. m_LightItemTarget = new ActionTargetLighSource(object, null, -1, vector.Zero, -1);
  22. UpdateLightSourceList();
  23. }
  24. void RemoveLightSource(Object object)
  25. {
  26. m_LightItemTarget = new ActionTargetLighSource(object, null, -1, vector.Zero, -1);
  27. m_LightItemTarget.m_Remove = true;
  28. UpdateLightSourceList();
  29. }
  30. void UpdateLightSourceList()
  31. {
  32. if ( m_LightItemTarget )
  33. {
  34. if ( !m_LightItemTarget.m_Remove )
  35. {
  36. m_ValidLightItems.Insert(m_LightItemTarget);
  37. }
  38. else
  39. {
  40. m_ValidLightItems.RemoveItem(m_LightItemTarget);
  41. }
  42. }
  43. }
  44. ref array<ref ActionTarget> GetLightSourceList()
  45. {
  46. return m_ValidLightItems;
  47. }
  48. void SetSelectedLightSourceIdx(int value)
  49. {
  50. m_SelectedLightSource = value;
  51. }
  52. int GetSelectedLightSourceIdx()
  53. {
  54. return m_SelectedLightSource;
  55. }
  56. void SelectLightSourceTarget(ActionTarget target) //should be ActionTarget?
  57. {
  58. int idx = m_ValidLightItems.Find(target);
  59. SetSelectedLightSourceIdx(idx);
  60. }
  61. ref ActionTarget GetSelectedLightSourceTarget()
  62. {
  63. return m_ValidLightItems.Get(m_SelectedLightSource);
  64. }
  65. };