OSDN Git Service

VS 1.17 Hot-Fix, minor tweaks
[automap/automap.git] / Automap / Data / CommandData.cs
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Drawing;
5 using System.IO;
6
7 using ProtoBuf;
8
9 using Vintagestory.API.Common;
10 using Vintagestory.API.Datastructures;
11
12 namespace Automap
13 {
14         [ProtoContract(SkipConstructor = true)]
15         //[ProtoInclude(5,typeof(DelegateState))]
16         public class CommandData : IAttribute
17         {
18                 [ProtoMember(1)]
19                 public CommandType State { get; set; }//Run , Stop, SingleSnapshot -> Stop
20
21
22
23                 [ProtoMember(3)]
24                 public string Notation { get; set; }
25
26                 //POI Delegate list {enabled/Disable}, color?
27                 //Other params...? Tick rate?
28                 //Choose : Renderer(s)
29
30
31                 public CommandData(CommandType assumeState)
32                 {
33                         State = assumeState;
34
35
36
37                 }
38
39
40                 public void FromBytes(BinaryReader stream)
41                 {
42                         var temp = ProtoBuf.Serializer.Deserialize<CommandData>(stream.BaseStream);
43                         this.State = temp.State;
44
45
46                 }
47
48                 public void ToBytes(BinaryWriter stream)
49                 {
50                         ProtoBuf.Serializer.Serialize<CommandData>(stream.BaseStream, this);
51
52
53                 }
54
55
56
57                 public int GetAttributeId()
58                 {
59                         return 12346;
60                 }
61
62                 public object GetValue()
63                 {
64                         return this;
65                 }
66
67
68                 public string ToJsonToken()
69                 {
70                         return $"Command-Type:{State} ";
71                 }
72
73                 public bool Equals(IWorldAccessor worldForResolve, IAttribute attr)
74                 {
75                         var other = attr.GetValue() as CommandData;
76
77                         if (this.State == other.State)
78                         {
79                                 return true;
80                         }
81
82                         return false;
83                 }
84
85                 public IAttribute Clone( )
86                 {
87                 var cloneCmd = new CommandData(this.State);
88                 cloneCmd.Notation = this.Notation;
89                 return cloneCmd;
90                 }
91         }
92 }
93