OSDN Git Service

24f73446a127b1b857f9fb0e637c05fd7796240d
[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 {
8         public class StatusData : IAttribute
9         {
10                 public uint TotalUpdates { get; set; }
11                 public uint VoidChunks { get; set; }
12                 public uint Delta { get; set; }
13
14
15                 public StatusData(uint totalUpdates, uint voidChunks, uint delta  )
16                 {
17                 TotalUpdates = totalUpdates;
18                 VoidChunks = voidChunks;
19                 Delta = delta;
20                 }
21
22
23
24                 public void FromBytes(BinaryReader stream)
25                 {
26                 TotalUpdates = stream.ReadUInt32( );
27                 VoidChunks = stream.ReadUInt32( );
28                 Delta = stream.ReadUInt32( );
29                 }
30
31                 public int GetAttributeId( )
32                 {
33                 return 12345;
34                 }
35
36                 public object GetValue( )
37                 {
38                 return this;
39                 }
40
41                 public void ToBytes(BinaryWriter stream)
42                 {
43                 stream.Write(TotalUpdates);
44                 stream.Write(VoidChunks);
45                 stream.Write(Delta);
46                 }
47
48                 public string ToJsonToken( )
49                 {
50                 return $"TotalUpdate:{TotalUpdates}, VoidChunks:{VoidChunks}, Delta:{Delta}";
51                 }
52
53                 public bool Equals(IWorldAccessor worldForResolve, IAttribute attr)
54                 {
55                 StatusData other = attr.GetValue( ) as StatusData;
56
57                 if (this.TotalUpdates == other.TotalUpdates &&
58                         this.VoidChunks == other.VoidChunks &&
59                         this.Delta == other.Delta) {
60                 return true;
61                 }
62                 return false;
63                 }
64         }
65 }
66