Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.1KB

  1. using System;
  2. using System.IO;
  3. using System.Runtime.CompilerServices;
  4. using Game.Handhelds;
  5. using NetworkFramework.Shared;
  6. using UnityEngine;
  7. namespace CLre_server.API.Synergy.Tweaks
  8. {
  9. public struct SerializedCLreTerrainModifyRejection: ISerializedNetData
  10. {
  11. public RejectionFlag Flags;
  12. public uint resourceId;
  13. public Vector3 hit;
  14. public string toolKey;
  15. public ToolModeType toolMode;
  16. public byte[] Serialize()
  17. {
  18. using (MemoryStream stream = new MemoryStream())
  19. {
  20. using (BinaryWriter writer = new BinaryWriter(stream))
  21. {
  22. writer.Write((byte)Flags);
  23. writer.Write(resourceId);
  24. writer.Write(hit.x);
  25. writer.Write(hit.y);
  26. writer.Write(hit.z);
  27. writer.Write(toolKey);
  28. writer.Write((byte)toolMode);
  29. return stream.ToArray();
  30. }
  31. }
  32. }
  33. public void Deserialize(byte[] data)
  34. {
  35. using (MemoryStream stream = new MemoryStream(data))
  36. {
  37. using (BinaryReader reader = new BinaryReader(stream))
  38. {
  39. Flags = (RejectionFlag)reader.ReadByte();
  40. resourceId = reader.ReadUInt32();
  41. float x = reader.ReadSingle();
  42. float y = reader.ReadSingle();
  43. float z = reader.ReadSingle();
  44. hit = new Vector3(x, y, z);
  45. toolKey = reader.ReadString();
  46. toolMode = (ToolModeType)reader.ReadByte();
  47. }
  48. }
  49. }
  50. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  51. public bool Ok()
  52. {
  53. return (Flags & RejectionFlag.Rejection) == RejectionFlag.None;
  54. }
  55. }
  56. [Flags]
  57. public enum RejectionFlag : byte
  58. {
  59. None = 0,
  60. Rejection = 1,
  61. Proximity = 1 << 1,
  62. Permission = 1 << 2,
  63. AccountNotFound = 1 << 3,
  64. InitError = 1 << 4,
  65. }
  66. }