You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to make the constructor of StateChart (C# class) protected? I would like to extend the class to add custom methods for the different state charts in my game (similar to the extensions methods in the C# example, but I don't want them to be accessible on every state chart).
Example of how I want to use it with the protected constructor :
// PlayerStateChart.cspublicclassPlayerStateChart:StateChart// Inherits from StateChart that inherits from NodeWrapper{protectedPlayerStateChart(Nodewrapped):base(wrapped){}publicnewstaticPlayerStateChartOf(NodestateChart){StateChart.Of(stateChart);// Will throw an exception if the node is not a state chart.returnnewPlayerStateChart(stateChart);}publicvoidSetIsMovementKeyPressed(boolvalue)=>SetExpressionProperty("is_movement_key_pressed",value);}// Player.cspublicoverridevoid_Ready(){varstateChart=PlayerStateChart.Of(GetNode("%StateChart"));stateChart.SetIsMovementKeyPressed(true);}// Enemy.cspublicoverridevoid_Ready(){varstateChart=EnemyStateChart.Of(GetNode("%StateChart"));stateChart.SetIsMovementKeyPressed(true);// I want an error here, this method should only be accessible via the PlayerStateChart class}
My current solution without the protected constructor is to either manually modify the StateChart file to make the constructor protected or to make a wrapper class called PlayerStateChart that exposes the needed methods. The downside of the custom wrapper is that I loose all the other methods of the StateChart & NodeWrapper classes since the are now inside PlayerStateChart. I could make the raw state chart property public, but it does not feel like a good enough solution to me.
Thanks for your time, this Godot extension is awesome!
The text was updated successfully, but these errors were encountered:
Hello!
Would it be possible to make the constructor of
StateChart
(C# class) protected? I would like to extend the class to add custom methods for the different state charts in my game (similar to the extensions methods in the C# example, but I don't want them to be accessible on every state chart).Example of how I want to use it with the protected constructor :
My current solution without the protected constructor is to either manually modify the
StateChart
file to make the constructor protected or to make a wrapper class calledPlayerStateChart
that exposes the needed methods. The downside of the custom wrapper is that I loose all the other methods of theStateChart
&NodeWrapper
classes since the are now insidePlayerStateChart
. I could make the raw state chart property public, but it does not feel like a good enough solution to me.Thanks for your time, this Godot extension is awesome!
The text was updated successfully, but these errors were encountered: