File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed
NetworkingManagerComponents/Binary Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 115
115
<Compile Include =" NetworkingManagerComponents\Binary\BitReaderDeprecated.cs" />
116
116
<Compile Include =" NetworkingManagerComponents\Binary\BinaryHelpers.cs" />
117
117
<Compile Include =" NetworkingManagerComponents\Binary\ByteBool.cs" />
118
+ <Compile Include =" NetworkingManagerComponents\Binary\IBitWritable.cs" />
118
119
<Compile Include =" NetworkingManagerComponents\Binary\ResourcePool.cs" />
119
120
<Compile Include =" NetworkingManagerComponents\Binary\UIntFloat.cs" />
120
121
<Compile Include =" NetworkingManagerComponents\Core\LogHelper.cs" />
Original file line number Diff line number Diff line change @@ -127,8 +127,15 @@ 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
+ {
132
+ object instance = Activator . CreateInstance ( type ) ;
133
+ ( ( IBitWritable ) instance ) . Read ( this . source ) ;
134
+ return instance ;
135
+ }
130
136
if ( type . IsEnum )
131
137
return ReadInt32Packed ( ) ;
138
+
132
139
throw new ArgumentException ( "BitReader cannot read type " + type . Name ) ;
133
140
}
134
141
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 . sink ) ;
151
+ return ;
152
+ }
148
153
else if ( value . GetType ( ) . IsEnum )
149
154
{
150
155
WriteInt32Packed ( ( int ) value ) ;
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using System . Text ;
6
+
7
+ namespace MLAPI . Serialization
8
+ {
9
+ public interface IBitWritable
10
+ {
11
+ void Write ( Stream stream ) ;
12
+ void Read ( Stream stream ) ;
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments