Skip to content

Commit be6fd5d

Browse files
JPBotelhoTangilJ
authored andcommitted
Added extension methods to flatbuffer datatypes (RLBot#5)
Added ExtensionMethods to autogenerated Vector3 types to convert to System.Numeric ones
1 parent 517bc41 commit be6fd5d

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace RLBotCSharpExample
2+
{
3+
public static class DataConversion
4+
{
5+
public static System.Numerics.Vector3 ToVector3(this rlbot.flat.Vector3 vec)
6+
{
7+
return new System.Numerics.Vector3(vec.X, vec.Y, vec.Z);
8+
}
9+
10+
public static System.Numerics.Vector2 ToVector2(this rlbot.flat.Vector3 vec)
11+
{
12+
return new System.Numerics.Vector2(vec.X, vec.Y);
13+
}
14+
}
15+
}

RLBotCSharpExample/RLBotCSharpExample/RLBotCSharpExample.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<TargetFrameworkProfile />
1415
</PropertyGroup>
1516
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -62,6 +63,7 @@
6263
</Reference>
6364
<Reference Include="System" />
6465
<Reference Include="System.Core" />
66+
<Reference Include="System.Numerics" />
6567
<Reference Include="System.Xml.Linq" />
6668
<Reference Include="System.Data.DataSetExtensions" />
6769
<Reference Include="Microsoft.CSharp" />
@@ -76,10 +78,11 @@
7678
</ItemGroup>
7779
<ItemGroup>
7880
<None Include="App.config" />
81+
<Compile Include="DataConversion.cs" />
7982
<None Include="packages.config" />
8083
<None Include="port.cfg">
8184
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
8285
</None>
8386
</ItemGroup>
8487
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85-
</Project>
88+
</Project>

0 commit comments

Comments
 (0)