File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
MLAPI/NetworkingManagerComponents/Binary Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,11 @@ public object ReadObjectPacked(Type type)
127
127
return ReadRotation ( 3 ) ;
128
128
if ( type == typeof ( char ) )
129
129
return ReadCharPacked ( ) ;
130
+ if ( type == typeof ( IBitWritable ) ) {
131
+ object instance = Activator . CreateInstance ( type ) ;
132
+ ( ( IBitWritable ) instance ) . Read ( this ) ;
133
+ return instance ;
134
+ }
130
135
throw new ArgumentException ( "BitReader cannot read type " + type . Name ) ;
131
136
}
132
137
Original file line number Diff line number Diff line change @@ -145,6 +145,11 @@ public void WriteObjectPacked(object value)
145
145
WriteCharPacked ( ( char ) value ) ;
146
146
return ;
147
147
}
148
+ else if ( value is IBitWritable )
149
+ {
150
+ ( ( IBitWritable ) value ) . Write ( this ) ;
151
+ return ;
152
+ }
148
153
149
154
throw new ArgumentException ( "BitWriter cannot write type " + value . GetType ( ) . Name ) ;
150
155
}
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+
6
+ namespace MLAPI . Serialization {
7
+ interface IBitWritable {
8
+ void Write ( BitWriter writer ) ;
9
+ void Read ( BitReader reader ) ;
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments