VFXExpressionSpawnerState.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. using UnityEngine.VFX;
  6. namespace UnityEditor.VFX
  7. {
  8. #pragma warning disable 0659
  9. sealed class VFXSpawnerStateExpression : VFXExpression
  10. {
  11. public static readonly VFXExpression NewLoop = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateNewLoop);
  12. public static readonly VFXExpression LoopState = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateLoopState);
  13. public static readonly VFXExpression SpawnCount = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateSpawnCount);
  14. public static readonly VFXExpression DeltaTime = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateDeltaTime);
  15. public static readonly VFXExpression TotalTime = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateTotalTime);
  16. public static readonly VFXExpression DelayBeforeLoop = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateDelayBeforeLoop);
  17. public static readonly VFXExpression LoopDuration = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateLoopDuration);
  18. public static readonly VFXExpression DelayAfterLoop = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateDelayAfterLoop);
  19. public static readonly VFXExpression LoopIndex = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateLoopIndex);
  20. public static readonly VFXExpression LoopCount = new VFXSpawnerStateExpression(VFXExpressionOperation.SpawnerStateLoopCount);
  21. private static readonly VFXExpression[] AllExpressions = VFXReflectionHelper.CollectStaticReadOnlyExpression<VFXExpression>(typeof(VFXBuiltInExpression));
  22. public static readonly VFXExpressionOperation[] All = AllExpressions.Select(e => e.operation).ToArray();
  23. private VFXExpressionOperation m_Operation;
  24. private VFXSpawnerStateExpression(VFXExpressionOperation op)
  25. : base(Flags.InvalidOnGPU | Flags.PerSpawn)
  26. {
  27. m_Operation = op;
  28. }
  29. public sealed override VFXExpressionOperation operation => m_Operation;
  30. public override bool Equals(object obj)
  31. {
  32. if (!(obj is VFXSpawnerStateExpression))
  33. return false;
  34. var other = (VFXSpawnerStateExpression)obj;
  35. return operation == other.operation;
  36. }
  37. protected override int GetInnerHashCode()
  38. {
  39. return operation.GetHashCode();
  40. }
  41. protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
  42. {
  43. return this;
  44. }
  45. }
  46. #pragma warning restore 0659
  47. }