Skip to content

Commit

Permalink
feat: [クラスラッパー]マップオブジェクトの通過時に通知するイベントを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic9045 committed Nov 1, 2023
1 parent fd529d3 commit 63b909f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Libs/BveTypes/ClassWrappers/Public/MapObjectList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ private static void Initialize(BveTypeSet bveTypes)
CurrentIndexGetMethod = members.GetSourcePropertyGetterOf(nameof(CurrentIndex));
CurrentIndexSetMethod = members.GetSourcePropertySetterOf(nameof(CurrentIndex));

ObjectPassedEvent = members.GetSourceEventOf(nameof(ObjectPassed));

GoToAndGetCurrentMethod = members.GetSourceMethodOf(nameof(GoToAndGetCurrent));
GoToMethod = members.GetSourceMethodOf(nameof(GoTo));
}
Expand Down Expand Up @@ -62,6 +64,21 @@ public int CurrentIndex
set => CurrentIndexSetMethod.Invoke(Src, new object[] { value });
}

private static FastEvent ObjectPassedEvent;
/// <summary>
/// <see cref="CurrentIndex"/> の値が変更されたときに発生します。
/// </summary>
public event ObjectPassedEventHandler ObjectPassed
{
add => ObjectPassedEvent.Add(Src, value);
remove => ObjectPassedEvent.Remove(Src, value);
}
/// <summary>
/// <see cref="ObjectPassed"/> イベントを実行します。
/// </summary>
/// <param name="args">自列車が通過したマップ オブジェクト。</param>
public void ObjectPassed_Invoke(ObjectPassedEventArgs args) => ObjectPassedEvent.Invoke(Src, new object[] { Src, args.Src });

private static FastMethod GoToAndGetCurrentMethod;
/// <summary>
/// コレクションの指定した距離程に対応する要素へ移動し、それを取得します。
Expand All @@ -79,5 +96,8 @@ public MapObjectBase GoToAndGetCurrent(double location)
/// </summary>
/// <param name="index">移動先のインデックス。</param>
public void GoTo(int index) => GoToMethod.Invoke(Src, new object[] { index });


public delegate void ObjectPassedEventHandler(object sender, ObjectPassedEventArgs e);
}
}
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 @@ -524,11 +524,17 @@
</Class>

<Class Wrapper="MapObjectList" Original="b6">
<Children>
<Delegate Wrapper="ObjectPassedEventHandler" Original="a"/>
</Children>

<Property Wrapper="CurrentIndex">
<Getter Original="g"/>
<Setter Original="d"/>
</Property>

<Event Wrapper="ObjectPassed" OriginalAddAccessor="b" OriginalRemoveAccessor="a" OriginalDelegateField="b"/>

<Method Wrapper="GoToAndGetCurrent" WrapperParams="System.Double" Original="c"/>
<Method Wrapper="GoTo" WrapperParams="System.Int32" Original="f"/>
</Class>
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 @@ -524,11 +524,17 @@
</Class>

<Class Wrapper="MapObjectList" Original="b6">
<Children>
<Delegate Wrapper="ObjectPassedEventHandler" Original="a"/>
</Children>

<Property Wrapper="CurrentIndex">
<Getter Original="g"/>
<Setter Original="d"/>
</Property>

<Event Wrapper="ObjectPassed" OriginalAddAccessor="b" OriginalRemoveAccessor="a" OriginalDelegateField="b"/>

<Method Wrapper="GoToAndGetCurrent" WrapperParams="System.Double" Original="c"/>
<Method Wrapper="GoTo" WrapperParams="System.Int32" Original="f"/>
</Class>
Expand Down

0 comments on commit 63b909f

Please sign in to comment.