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 115115 <Compile Include =" NetworkingManagerComponents\Binary\BitReaderDeprecated.cs" />
116116 <Compile Include =" NetworkingManagerComponents\Binary\BinaryHelpers.cs" />
117117 <Compile Include =" NetworkingManagerComponents\Binary\ByteBool.cs" />
118+ <Compile Include =" NetworkingManagerComponents\Binary\IBitWritable.cs" />
118119 <Compile Include =" NetworkingManagerComponents\Binary\ResourcePool.cs" />
119120 <Compile Include =" NetworkingManagerComponents\Binary\UIntFloat.cs" />
120121 <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)
127127 return ReadRotation ( 3 ) ;
128128 if ( type == typeof ( char ) )
129129 return ReadCharPacked ( ) ;
130+ if ( type == typeof ( IBitWritable ) )
131+ {
132+ object instance = Activator . CreateInstance ( type ) ;
133+ ( ( IBitWritable ) instance ) . Read ( this . source ) ;
134+ return instance ;
135+ }
130136 if ( type . IsEnum )
131137 return ReadInt32Packed ( ) ;
138+
132139 throw new ArgumentException ( "BitReader cannot read type " + type . Name ) ;
133140 }
134141
Original file line number Diff line number Diff line change @@ -145,6 +145,11 @@ public void WriteObjectPacked(object value)
145145 WriteCharPacked ( ( char ) value ) ;
146146 return ;
147147 }
148+ else if ( value is IBitWritable )
149+ {
150+ ( ( IBitWritable ) value ) . Write ( this . sink ) ;
151+ return ;
152+ }
148153 else if ( value . GetType ( ) . IsEnum )
149154 {
150155 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