-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from chickensoft-games/fix/override-handler-d…
…iagrams fix: correctly resolve overridden input handlers for diagram visualization
- Loading branch information
Showing
5 changed files
with
93 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Chickensoft.LogicBlocks.DiagramGenerator.Tests/test_cases/OverriddenHandlers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Chickensoft.LogicBlocks.ScratchPad; | ||
|
||
using Chickensoft.Introspection; | ||
|
||
[Meta, LogicBlock(typeof(State), Diagram = true)] | ||
public partial class OverriddenHandlers : LogicBlock<OverriddenHandlers.State> { | ||
public override Transition GetInitialState() => To<State.Idle>(); | ||
|
||
public static class Input { | ||
public readonly record struct SomeInput(); | ||
public readonly record struct SomeOtherInput(); | ||
|
||
} | ||
|
||
public static class Output { | ||
public readonly record struct SomeOutput(); | ||
public readonly record struct SomeOtherOutput(); | ||
} | ||
|
||
public abstract record State : StateLogic<State>, | ||
IGet<Input.SomeInput>, IGet<Input.SomeOtherInput> { | ||
|
||
public virtual Transition On(in Input.SomeInput input) { | ||
Output(new Output.SomeOutput()); | ||
|
||
return ToSelf(); | ||
} | ||
|
||
public Transition On(in Input.SomeOtherInput input) { | ||
Output(new Output.SomeOtherOutput()); | ||
|
||
return ToSelf(); | ||
} | ||
|
||
public record Idle : State { | ||
public override Transition On(in Input.SomeInput input) { | ||
Output(new Output.SomeOtherOutput()); | ||
|
||
return ToSelf(); | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Chickensoft.LogicBlocks.DiagramGenerator.Tests/test_cases/OverriddenHandlers.g.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@startuml OverriddenHandlers | ||
state "OverriddenHandlers State" as Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State { | ||
state "Idle" as Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State_Idle | ||
} | ||
|
||
Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State --> Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State : SomeInput | ||
Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State --> Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State : SomeOtherInput | ||
Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State_Idle --> Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State_Idle : SomeInput | ||
|
||
Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State : OnSomeInput → SomeOutput | ||
Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State : OnSomeOtherInput → SomeOtherOutput | ||
Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State_Idle : OnSomeInput → SomeOtherOutput | ||
|
||
[*] --> Chickensoft_LogicBlocks_ScratchPad_OverriddenHandlers_State_Idle | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters