Skip to content

Commit

Permalink
feat: [クラスラッパー]背景モデルを操作できるように
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic9045 committed Sep 20, 2023
1 parent 4737b37 commit 8d78997
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions Libs/BveTypes/BveTypes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<Compile Include="ClassWrappers\Public\AssistantText.cs" />
<Compile Include="ClassWrappers\Public\AssistantTextBase.cs" />
<Compile Include="ClassWrappers\Public\AssistantTextDrawer.cs" />
<Compile Include="ClassWrappers\Public\Background.cs" />
<Compile Include="ClassWrappers\Public\BasicBrake.cs" />
<Compile Include="ClassWrappers\Public\Beacon.cs" />
<Compile Include="ClassWrappers\Public\BrakeControllerBase.cs" />
Expand Down
64 changes: 64 additions & 0 deletions Libs/BveTypes/ClassWrappers/Public/Background.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using SlimDX;

using FastMember;
using TypeWrapping;

namespace BveTypes.ClassWrappers
{
/// <summary>
/// 背景モデルを表します。
/// </summary>
public class Background : ClassWrapperBase
{
[InitializeClassWrapper]
private static void Initialize(BveTypeSet bveTypes)
{
ClassMemberSet members = bveTypes.GetClassInfoOf<Background>();

BackgroundObjectsField = members.GetSourceFieldOf(nameof(BackgroundObjects));

DrawMethod = members.GetSourceMethodOf(nameof(Draw));
}

/// <summary>
/// オリジナル オブジェクトから <see cref="Background"/> クラスの新しいインスタンスを初期化します。
/// </summary>
/// <param name="src">ラップするオリジナル オブジェクト。</param>
protected Background(object src) : base(src)
{
}

/// <summary>
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。
/// </summary>
/// <param name="src">ラップするオリジナル オブジェクト。</param>
/// <returns>オリジナル オブジェクトをラップした <see cref="Background"/> クラスのインスタンス。</returns>
[CreateClassWrapperFromSource]
public static Background FromSource(object src) => src is null ? null : new Background(src);


private static FastField BackgroundObjectsField;
/// <summary>
/// 背景ストラクチャーのリストを取得・設定します。
/// </summary>
public MapFunctionList BackgroundObjects
{
get => MapFunctionList.FromSource(BackgroundObjectsField.GetValue(Src));
set => BackgroundObjectsField.SetValue(Src, value.Src);
}

private static FastMethod DrawMethod;
/// <summary>
/// 回転角度を指定して背景モデルを描画します。
/// </summary>
/// <param name="direct3DProvider">描画に使用する <see cref="Direct3DProvider"/>。</param>
/// <param name="rotationMatrix">方角に合わせるための回転行列。</param>
public void Draw(Direct3DProvider direct3DProvider, Matrix rotationMatrix) => DrawMethod.Invoke(Src, new object[] { direct3DProvider, rotationMatrix });
}
}
6 changes: 6 additions & 0 deletions Libs/BveTypes/WrapTypes/5.8.7554.391.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
</Property>
</Class>

<Class Wrapper="Background" Original="ch">
<Field WrapperProperty="BackgroundObjects" Original="a" IsOriginalNonPublic="true"/>

<Method Wrapper="Draw" WrapperParams="atsex:Direct3DProvider; SlimDX.Matrix, SlimDX" Original="a"/>
</Class>

<Class Wrapper="BasicBrake" Original="bw">
<Property Wrapper="PistonArea">
<Getter Original="b"/>
Expand Down
6 changes: 6 additions & 0 deletions Libs/BveTypes/WrapTypes/6.0.7554.619.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
</Property>
</Class>

<Class Wrapper="Background" Original="ch">
<Field WrapperProperty="BackgroundObjects" Original="a" IsOriginalNonPublic="true"/>

<Method Wrapper="Draw" WrapperParams="atsex:Direct3DProvider; SlimDX.Matrix, SlimDX" Original="a"/>
</Class>

<Class Wrapper="BasicBrake" Original="bw">
<Property Wrapper="PistonArea">
<Getter Original="b"/>
Expand Down

0 comments on commit 8d78997

Please sign in to comment.