暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. namespace Unity.VisualScripting
  2. {
  3. [UnitOrder(102)]
  4. public abstract class Subtract<T> : Unit
  5. {
  6. /// <summary>
  7. /// The first value (minuend).
  8. /// </summary>
  9. [DoNotSerialize]
  10. [PortLabel("A")]
  11. public ValueInput minuend { get; private set; }
  12. /// <summary>
  13. /// The second value (subtrahend).
  14. /// </summary>
  15. [DoNotSerialize]
  16. [PortLabel("B")]
  17. public ValueInput subtrahend { get; private set; }
  18. /// <summary>
  19. /// The difference, that is the minuend minus the subtrahend.
  20. /// </summary>
  21. [DoNotSerialize]
  22. [PortLabel("A \u2212 B")]
  23. public ValueOutput difference { get; private set; }
  24. [DoNotSerialize]
  25. protected virtual T defaultMinuend => default(T);
  26. [DoNotSerialize]
  27. protected virtual T defaultSubtrahend => default(T);
  28. protected override void Definition()
  29. {
  30. minuend = ValueInput(nameof(minuend), defaultMinuend);
  31. subtrahend = ValueInput(nameof(subtrahend), defaultSubtrahend);
  32. difference = ValueOutput(nameof(difference), Operation).Predictable();
  33. Requirement(minuend, difference);
  34. Requirement(subtrahend, difference);
  35. }
  36. public abstract T Operation(T a, T b);
  37. public T Operation(Flow flow)
  38. {
  39. return Operation(flow.GetValue<T>(minuend), flow.GetValue<T>(subtrahend));
  40. }
  41. }
  42. }