@@ -80,17 +80,56 @@ public bool CanClientRead(uint clientId)
80
80
81
81
public void WriteDeltaToWriter ( BitWriter writer )
82
82
{
83
+ writer . WriteUShort ( ( ushort ) dirtyEvents . Count ) ;
83
84
for ( int i = 0 ; i < dirtyEvents . Count ; i ++ )
84
85
{
85
- //TODO: Write event
86
+ writer . WriteBits ( ( byte ) dirtyEvents [ i ] . eventType , 3 ) ;
87
+ switch ( dirtyEvents [ i ] . eventType )
88
+ {
89
+ //Fuck me these signatures are proper aids
90
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Add :
91
+ {
92
+ //TODO: Write dirtyEvents[i].value
93
+ }
94
+ break ;
95
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Insert :
96
+ {
97
+ writer . WriteInt ( dirtyEvents [ i ] . index ) ;
98
+ //TODO: Write dirtyEvents[i].value
99
+ }
100
+ break ;
101
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Remove :
102
+ {
103
+ //TODO: Write dirtyEvents[i].value
104
+ }
105
+ break ;
106
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . RemoveAt :
107
+ {
108
+ writer . WriteInt ( dirtyEvents [ i ] . index ) ;
109
+ }
110
+ break ;
111
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Value :
112
+ {
113
+ writer . WriteInt ( dirtyEvents [ i ] . index ) ;
114
+ //TODO: Write dirtyEvents[i].value
115
+ }
116
+
117
+ break ;
118
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Clear :
119
+ {
120
+ //Nothing has to be written
121
+ }
122
+ break ;
123
+ }
86
124
}
87
125
}
88
126
89
127
public void WriteFieldToWriter ( BitWriter writer )
90
128
{
129
+ writer . WriteUShort ( ( ushort ) list . Count ) ;
91
130
for ( int i = 0 ; i < list . Count ; i ++ )
92
131
{
93
- //TODO: Write the field
132
+ //TODO: Write the fieldValue
94
133
}
95
134
}
96
135
@@ -108,7 +147,44 @@ public void SetDeltaFromReader(BitReader reader)
108
147
ushort deltaCount = reader . ReadUShort ( ) ;
109
148
for ( int i = 0 ; i < deltaCount ; i ++ )
110
149
{
111
- //TODO: Read the NetworkedListEvent and apply the instruction
150
+ NetworkedListEvent < T > . NetworkedListEventType eventType = ( NetworkedListEvent < T > . NetworkedListEventType ) reader . ReadBits ( 3 ) ;
151
+ switch ( eventType )
152
+ {
153
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Add :
154
+ {
155
+ //TODO: list.Add(readValue);
156
+ }
157
+ break ;
158
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Insert :
159
+ {
160
+ int index = reader . ReadInt ( ) ;
161
+ //TODO: list.Insert(index, readValue);
162
+ }
163
+ break ;
164
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Remove :
165
+ {
166
+ //TODO: list.Remove(readValue);
167
+ }
168
+ break ;
169
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . RemoveAt :
170
+ {
171
+ int index = reader . ReadInt ( ) ;
172
+ list . RemoveAt ( index ) ;
173
+ }
174
+ break ;
175
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Value :
176
+ {
177
+ int index = reader . ReadInt ( ) ;
178
+ //TODO: list[index] = readValue
179
+ }
180
+ break ;
181
+ case global ::MLAPI . Data . NetworkedCollections . NetworkedList < T > . NetworkedListEvent < T > . NetworkedListEventType . Clear :
182
+ {
183
+ //Read nothing
184
+ list . Clear ( ) ;
185
+ }
186
+ break ;
187
+ }
112
188
}
113
189
}
114
190
0 commit comments