VFXExpressionAbstractFloatOperation.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Linq;
  3. using System.Runtime.CompilerServices;
  4. using UnityEngine;
  5. using UnityEngine.VFX;
  6. namespace UnityEditor.VFX
  7. {
  8. abstract class VFXExpressionUnaryFloatOperation : VFXExpressionUnaryNumericOperation
  9. {
  10. public VFXExpressionUnaryFloatOperation(VFXExpression parent, VFXExpressionOperation operation) : base(parent, operation)
  11. {
  12. if (!IsFloatValueType(parent.valueType))
  13. {
  14. throw new ArgumentException("Incorrect VFXExpressionUnaryFloatOperation");
  15. }
  16. }
  17. sealed protected override int ProcessUnaryOperation(int input)
  18. {
  19. throw new NotImplementedException();
  20. }
  21. sealed protected override uint ProcessUnaryOperation(uint input)
  22. {
  23. throw new NotImplementedException();
  24. }
  25. sealed protected override bool ProcessUnaryOperation(bool input)
  26. {
  27. throw new NotImplementedException();
  28. }
  29. sealed protected override string GetUnaryOperationCode(string x, VFXValueType type)
  30. {
  31. if (type != VFXValueType.Float)
  32. throw new InvalidOperationException("VFXExpressionUnaryFloatOperation : Unexpected type");
  33. return GetUnaryOperationCode(x);
  34. }
  35. abstract protected string GetUnaryOperationCode(string x);
  36. }
  37. abstract class VFXExpressionBinaryFloatOperation : VFXExpressionBinaryNumericOperation
  38. {
  39. protected VFXExpressionBinaryFloatOperation(VFXExpression parentLeft, VFXExpression parentRight, VFXExpressionOperation operation)
  40. : base(parentLeft, parentRight, operation)
  41. {
  42. if (!IsFloatValueType(parentLeft.valueType) || !IsFloatValueType(parentRight.valueType))
  43. {
  44. throw new ArgumentException("Incorrect VFXExpressionBinaryFloatOperation (not float type)");
  45. }
  46. }
  47. sealed protected override int ProcessBinaryOperation(int x, int y)
  48. {
  49. throw new NotImplementedException();
  50. }
  51. sealed protected override uint ProcessBinaryOperation(uint x, uint y)
  52. {
  53. throw new NotImplementedException();
  54. }
  55. sealed protected override bool ProcessBinaryOperation(bool x, bool y)
  56. {
  57. throw new NotImplementedException();
  58. }
  59. sealed protected override string GetBinaryOperationCode(string x, string y, VFXValueType type)
  60. {
  61. if (type != VFXValueType.Float)
  62. {
  63. throw new InvalidOperationException("Invalid VFXExpressionBinaryFloatOperation");
  64. }
  65. return GetBinaryOperationCode(x, y);
  66. }
  67. protected abstract string GetBinaryOperationCode(string x, string y);
  68. }
  69. }