25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

62 lines
1.8KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Sends the message to the current target. First, it checks the Actor's methods cache.
  8. /// If the receiving method found in cache, it will be called directly without passing the message to the GameObject.
  9. /// If there's no listener in cache, message will be sent GameObject (and Unity does it VERY slow).
  10. /// </summary>
  11. class ActionSendMessage : ActionInstant
  12. {
  13. protected string message;
  14. protected object param;
  15. protected SendMessageOptions options = SendMessageOptions.DontRequireReceiver;
  16. public ActionSendMessage(string targetMessage)
  17. : base()
  18. {
  19. message = targetMessage;
  20. }
  21. public ActionSendMessage(string targetMessage, object targetParam)
  22. : base()
  23. {
  24. message = targetMessage;
  25. param = targetParam;
  26. }
  27. public ActionSendMessage(string targetMessage, object targetParam, SendMessageOptions targetOptions)
  28. : base()
  29. {
  30. message = targetMessage;
  31. param = targetParam;
  32. options = targetOptions;
  33. }
  34. public override ActionInstant Clone()
  35. {
  36. return new ActionSendMessage(message, param, options);
  37. }
  38. public override ActionInstant Reverse()
  39. {
  40. return new ActionSendMessage(message, param, options);
  41. }
  42. public override void Start()
  43. {
  44. base.Start();
  45. if (param != null)
  46. {
  47. target.ReceiveMessage(message, param, options);
  48. }
  49. else
  50. {
  51. target.ReceiveMessage(message, options);
  52. }
  53. }
  54. }
  55. }