gd,refacto: added state chart addon and namespace cleanup
This commit is contained in:
27
godot_state_charts_examples/csharp/StateChartExt.cs
Normal file
27
godot_state_charts_examples/csharp/StateChartExt.cs
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
using GodotStateCharts;
|
||||
|
||||
namespace Movementtests.godot_state_charts_examples.csharp;
|
||||
|
||||
/// <summary>
|
||||
/// This is an example on how to add extension methods to the state chart class to get
|
||||
/// more type safety and a nicer API.
|
||||
/// </summary>
|
||||
// ReSharper disable once CheckNamespace
|
||||
public static class StateChartExt
|
||||
{
|
||||
public static void SetPoisonCount(this StateChart stateChart, int poisonCount)
|
||||
{
|
||||
stateChart.SetExpressionProperty("poison_count", poisonCount);
|
||||
}
|
||||
|
||||
public static int GetPoisonCount(this StateChart stateChart)
|
||||
{
|
||||
return stateChart.GetExpressionProperty("poison_count", 0);
|
||||
}
|
||||
|
||||
public static void SendCuredEvent(this StateChart stateChart)
|
||||
{
|
||||
stateChart.SendEvent("cured");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user