OSDN Git Service

W.I.P. VI: Automap Commanded by local event bus
[automap/automap.git] / Automap / Data / CommandData.cs
1 using System;
2 using System.IO;
3
4 using Vintagestory.API.Common;
5 using Vintagestory.API.Datastructures;
6
7 namespace Automap
8 {
9         public class CommandData : IAttribute
10         {
11                 public RunState State { get; set; }//Run , Stop, SingleSnapshot -> Stop
12
13                 //POI Delegate list {enabled/Disable}
14                 //Other params...? Tick rate?
15                 //Choose : Renderer(s)
16
17
18                 public CommandData( RunState assumeState)
19                 {
20                 State = assumeState;
21
22                 }
23
24
25
26                 public void FromBytes(BinaryReader stream)
27                 {
28                 State = ( RunState )stream.ReadByte( );
29                 
30
31                 }
32
33                 public int GetAttributeId( )
34                 {
35                 return 12346;
36                 }
37
38                 public object GetValue( )
39                 {
40                 return this;
41                 }
42
43                 public void ToBytes(BinaryWriter stream)
44                 {
45                 stream.Write(( byte )State);
46                 
47                 }
48
49                 public string ToJsonToken( )
50                 {
51                 return $"New-State:{State},  ";
52                 }
53
54                 public bool Equals(IWorldAccessor worldForResolve, IAttribute attr)
55                 {
56                 var other = attr.GetValue( ) as CommandData;
57
58                         if (this.State == other.State )
59                         {
60                         return true;
61                         }
62
63                 return false;
64                 }
65         }
66 }
67