File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed
MLAPI/NetworkingManagerComponents/Binary Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -174,10 +174,10 @@ public object ReadObjectPacked(Type type)
174
174
return null ;
175
175
}
176
176
}
177
- if ( typeof ( BitWritable ) . IsAssignableFrom ( type ) )
177
+ if ( typeof ( IBitWritable ) . IsAssignableFrom ( type ) )
178
178
{
179
179
object instance = Activator . CreateInstance ( type ) ;
180
- ( ( BitWritable ) instance ) . Read ( this . source ) ;
180
+ ( ( IBitWritable ) instance ) . Read ( this . source ) ;
181
181
return instance ;
182
182
}
183
183
Original file line number Diff line number Diff line change 4
4
5
5
namespace MLAPI . Serialization
6
6
{
7
- [ Obsolete ( "The IBitWritable interface has been replaced with the abstract BitWritable class" , true ) ]
7
+ /// <summary>
8
+ /// Interface for serializable classes and structs
9
+ /// </summary>
8
10
public interface IBitWritable
9
11
{
10
- [ Obsolete ( "The IBitWritable interface has been replaced with the abstract BitWritable class" , true ) ]
12
+ /// <summary>
13
+ /// Reads the contents from the stream and applies it to the type instance
14
+ /// </summary>
15
+ /// <param name="stream">The stream to read from</param>
11
16
void Read ( Stream stream ) ;
12
- [ Obsolete ( "The IBitWritable interface has been replaced with the abstract BitWritable class" , true ) ]
17
+ /// <summary>
18
+ /// Writes the contents of the type instance to the stream
19
+ /// </summary>
20
+ /// <param name="stream">The stream to write to</param>
13
21
void Write ( Stream stream ) ;
14
22
}
15
23
16
24
/// <summary>
17
25
/// BitWritable is the base class for writable types
18
26
/// </summary>
19
- public abstract class BitWritable
27
+ public abstract class AutoBitWritable : IBitWritable
20
28
{
21
29
/// <summary>
22
30
/// Writes the contents of the type instance to the stream
Original file line number Diff line number Diff line change @@ -190,13 +190,13 @@ public void WriteObjectPacked(object value)
190
190
WriteUInt16Packed ( ( ( NetworkedBehaviour ) value ) . GetBehaviourId ( ) ) ;
191
191
return ;
192
192
}
193
- else if ( value is BitWritable )
193
+ else if ( value is IBitWritable )
194
194
{
195
195
if ( value == null )
196
196
{
197
197
throw new ArgumentException ( "BitWriter cannot write IBitWritable types with a null value" ) ;
198
198
}
199
- ( ( BitWritable ) value ) . Write ( this . sink ) ;
199
+ ( ( IBitWritable ) value ) . Write ( this . sink ) ;
200
200
return ;
201
201
}
202
202
Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Reflection ;
5
+ using MLAPI . Internal ;
5
6
using UnityEngine ;
6
7
7
8
namespace MLAPI . Serialization
@@ -65,7 +66,7 @@ internal static FieldInfo[] GetFieldsForType(Type type)
65
66
/// <returns>Whether or not the type is supported</returns>
66
67
public static bool IsTypeSupported ( Type type )
67
68
{
68
- return type . IsEnum || SupportedTypes . Contains ( type ) || ( typeof ( BitWritable ) . IsAssignableFrom ( type ) ) ;
69
+ return type . IsEnum || SupportedTypes . Contains ( type ) || type . HasInterface ( typeof ( IBitWritable ) ) ;
69
70
}
70
71
}
71
72
}
You can’t perform that action at this time.
0 commit comments