OSDN Git Service

indentation
[automap/automap.git] / Automap / Data / StatusData.cs
1 using System;
2 using System.IO;
3 using Vintagestory.API.Common;
4 using Vintagestory.API.Datastructures;
5
6 namespace Automap {
7         public class StatusData : IAttribute {
8                 public uint TotalUpdates { get; set; }
9                 public uint VoidChunks { get; set; }
10                 public uint Delta { get; set; }
11                 public uint Max_N, Max_E, Max_S, Max_W;
12                 public RunState CurrentState { get; set; }
13
14                 public StatusData(uint totalUpdates, uint voidChunks, uint delta, RunState currently) {
15                         TotalUpdates = totalUpdates;
16                         VoidChunks = voidChunks;
17                         Delta = delta;
18                         CurrentState = currently;
19                 }
20
21                 public void FromBytes(BinaryReader stream) {
22                         TotalUpdates = stream.ReadUInt32();
23                         VoidChunks = stream.ReadUInt32();
24                         Delta = stream.ReadUInt32();
25                         CurrentState = (RunState) stream.ReadByte();
26                 }
27
28                 public int GetAttributeId() {
29                         return 12345;
30                 }
31
32                 public object GetValue() {
33                         return this;
34                 }
35
36                 public void ToBytes(BinaryWriter stream) {
37                         stream.Write(TotalUpdates);
38                         stream.Write(VoidChunks);
39                         stream.Write(Delta);
40                         stream.Write((byte) CurrentState);
41                 }
42
43                 public string ToJsonToken() {
44                         return $"TotalUpdate:{TotalUpdates}, VoidChunks:{VoidChunks}, Delta:{Delta}";
45                 }
46
47                 public bool Equals(IWorldAccessor worldForResolve, IAttribute attr) {
48                         StatusData other = attr.GetValue() as StatusData;
49
50                         if (this.TotalUpdates == other.TotalUpdates &&
51                                 this.VoidChunks == other.VoidChunks &&
52                                 this.Delta == other.Delta &&
53                                 this.CurrentState == other.CurrentState) {
54                                 return true;
55                         }
56                         return false;
57                 }
58         }
59 }
60