Add Float2/Float3/Float4 replication in C#
This commit is contained in:
@@ -338,6 +338,60 @@ namespace FlaxEngine.Networking
|
||||
return new Vector4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data of type <see cref="Float2"/> into the message.
|
||||
/// </summary>
|
||||
public void WriteFloat2(Float2 value)
|
||||
{
|
||||
WriteSingle(value.X);
|
||||
WriteSingle(value.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads and returns data of type <see cref="Float2"/> from the message.
|
||||
/// </summary>
|
||||
public Float2 ReadFloat2()
|
||||
{
|
||||
return new Float2(ReadSingle(), ReadSingle());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data of type <see cref="Float3"/> into the message.
|
||||
/// </summary>
|
||||
public void WriteFloat3(Float3 value)
|
||||
{
|
||||
WriteSingle(value.X);
|
||||
WriteSingle(value.Y);
|
||||
WriteSingle(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads and returns data of type <see cref="Float3"/> from the message.
|
||||
/// </summary>
|
||||
public Float3 ReadFloat3()
|
||||
{
|
||||
return new Float3(ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data of type <see cref="Float4"/> into the message.
|
||||
/// </summary>
|
||||
public void WriteFloat4(Float4 value)
|
||||
{
|
||||
WriteSingle(value.X);
|
||||
WriteSingle(value.Y);
|
||||
WriteSingle(value.Z);
|
||||
WriteSingle(value.W);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads and returns data of type <see cref="Float4"/> from the message.
|
||||
/// </summary>
|
||||
public Float4 ReadFloat4()
|
||||
{
|
||||
return new Float4(ReadSingle(), ReadSingle(), ReadSingle(), ReadSingle());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data of type <see cref="Quaternion"/> into the message.
|
||||
/// </summary>
|
||||
|
||||
@@ -58,6 +58,9 @@ namespace Flax.Build.Plugins
|
||||
{ "FlaxEngine.Vector2", new InBuildSerializer("WriteVector2", "ReadVector2") },
|
||||
{ "FlaxEngine.Vector3", new InBuildSerializer("WriteVector3", "ReadVector3") },
|
||||
{ "FlaxEngine.Vector4", new InBuildSerializer("WriteVector4", "ReadVector4") },
|
||||
{ "FlaxEngine.Float2", new InBuildSerializer("WriteFloat2", "ReadFloat2") },
|
||||
{ "FlaxEngine.Float3", new InBuildSerializer("WriteFloat3", "ReadFloat3") },
|
||||
{ "FlaxEngine.Float4", new InBuildSerializer("WriteFloat4", "ReadFloat4") },
|
||||
{ "FlaxEngine.Quaternion", new InBuildSerializer("WriteQuaternion", "ReadQuaternion") },
|
||||
};
|
||||
|
||||
|
||||
@@ -33,17 +33,26 @@ namespace Flax.Build
|
||||
|
||||
public static MethodDefinition GetMethod(this TypeDefinition type, string name)
|
||||
{
|
||||
return type.Methods.First(x => x.Name == name);
|
||||
var result = type.Methods.FirstOrDefault(x => x.Name == name);
|
||||
if (result == null)
|
||||
throw new Exception($"Failed to find method '{name}' in '{type.FullName}'.");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static MethodDefinition GetMethod(this TypeDefinition type, string name, int argCount)
|
||||
{
|
||||
return type.Methods.First(x => x.Name == name && x.Parameters.Count == argCount);
|
||||
var result = type.Methods.First(x => x.Name == name && x.Parameters.Count == argCount);
|
||||
if (result == null)
|
||||
throw new Exception($"Failed to find method '{name}' (args={argCount}) in '{type.FullName}'.");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static FieldDefinition GetField(this TypeDefinition type, string name)
|
||||
{
|
||||
return type.Fields.First(x => x.Name == name);
|
||||
var result = type.Fields.First(x => x.Name == name);
|
||||
if (result == null)
|
||||
throw new Exception($"Failed to find field '{name}' in '{type.FullName}'.");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool IsScriptingObject(this TypeDefinition type)
|
||||
|
||||
Reference in New Issue
Block a user