|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using System.IO;
- using System.Runtime.CompilerServices;
- using Game.Handhelds;
- using NetworkFramework.Shared;
- using UnityEngine;
-
- namespace CLre_server.API.Synergy.Tweaks
- {
- public struct SerializedCLreTerrainModifyRejection: ISerializedNetData
- {
- public RejectionFlag Flags;
-
- public uint resourceId;
-
- public Vector3 hit;
-
- public string toolKey;
-
- public ToolModeType toolMode;
-
- public byte[] Serialize()
- {
- using (MemoryStream stream = new MemoryStream())
- {
- using (BinaryWriter writer = new BinaryWriter(stream))
- {
- writer.Write((byte)Flags);
- writer.Write(resourceId);
- writer.Write(hit.x);
- writer.Write(hit.y);
- writer.Write(hit.z);
- writer.Write(toolKey);
- writer.Write((byte)toolMode);
- return stream.ToArray();
- }
- }
- }
-
- public void Deserialize(byte[] data)
- {
- using (MemoryStream stream = new MemoryStream(data))
- {
- using (BinaryReader reader = new BinaryReader(stream))
- {
- Flags = (RejectionFlag)reader.ReadByte();
- resourceId = reader.ReadUInt32();
- float x = reader.ReadSingle();
- float y = reader.ReadSingle();
- float z = reader.ReadSingle();
- hit = new Vector3(x, y, z);
- toolKey = reader.ReadString();
- toolMode = (ToolModeType)reader.ReadByte();
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Ok()
- {
- return (Flags & RejectionFlag.Rejection) == RejectionFlag.None;
- }
- }
-
- [Flags]
- public enum RejectionFlag : byte
- {
- None = 0,
- Rejection = 1,
- Proximity = 1 << 1,
- Permission = 1 << 2,
- AccountNotFound = 1 << 3,
- InitError = 1 << 4,
- }
- }
|