StringOptions.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using Unity.Collections;
  3. namespace LitMotion
  4. {
  5. /// <summary>
  6. /// Type of characters used to fill in invisible strings.
  7. /// </summary>
  8. public enum ScrambleMode : byte
  9. {
  10. /// <summary>
  11. /// None
  12. /// </summary>
  13. None = 0,
  14. /// <summary>
  15. /// A-Z
  16. /// </summary>
  17. Uppercase = 1,
  18. /// <summary>
  19. /// a-z
  20. /// </summary>
  21. Lowercase = 2,
  22. /// <summary>
  23. /// 0-9
  24. /// </summary>
  25. Numerals = 3,
  26. /// <summary>
  27. /// A-Z, a-z, 0-9
  28. /// </summary>
  29. All = 4,
  30. /// <summary>
  31. /// Custom characters.
  32. /// </summary>
  33. Custom = 5
  34. }
  35. /// <summary>
  36. /// Options for string type motion.
  37. /// </summary>
  38. public struct StringOptions : IMotionOptions, IEquatable<StringOptions>
  39. {
  40. public ScrambleMode ScrambleMode;
  41. public bool RichTextEnabled;
  42. public FixedString64Bytes CustomScrambleChars;
  43. public Unity.Mathematics.Random RandomState;
  44. public readonly bool Equals(StringOptions other)
  45. {
  46. return other.ScrambleMode == ScrambleMode &&
  47. other.RichTextEnabled == RichTextEnabled &&
  48. other.CustomScrambleChars == CustomScrambleChars &&
  49. other.RandomState.state == RandomState.state;
  50. }
  51. public override readonly bool Equals(object obj)
  52. {
  53. if (obj is StringOptions options) return Equals(options);
  54. return false;
  55. }
  56. public override readonly int GetHashCode()
  57. {
  58. return HashCode.Combine(ScrambleMode, RichTextEnabled, CustomScrambleChars, RandomState);
  59. }
  60. }
  61. }