Give each phase interface its own order member instead of a shared IOrderable - #487
Merged
Conversation
|
✅ Development package |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IOrderablegave rendering and updating one sharedOrder. A class implementing bothIRenderer<T>andIUpdatablecould therefore only state one position, which is the wrong coupling: those are two independent phases.IUpdatabledid not even inherit the interface, so the update registry had to type-test each service at every comparison and fall back to0.Each phase interface now names its own order.
IUpdatabledeclaresint UpdateOrder => 0;IRenderer<in TRenderContext>declaresint RenderOrder => 0;, next to theViewScope => defaultmember already thereIOrderableis deletedBoth registry comparisons collapse to a direct property read, and the runtime type test disappears:
UiRenderer,PencuilRendererandTestRendererexposeRenderOrder;UiUpdateSystemexposesUpdateOrderand dropsIOrderable. Their constructor parameters follow, matching therenderOrderandupdateOrdernames the extension methods already used at the call sites.Input
Input ordering is not a property of a handler object. It is an argument to each subscription, and a single system commonly subscribes to several events at once, so there is no interface to move a member onto. The value was named
priorityin the service interfaces butinputOrderat every call site and in the docs. It is noworderthroughout, giving all three phases one vocabulary:IMouseService,IKeyboardService,IGamepadService,ITextInputServiceand their implementations.PriorityEventHandlersandViewScopedPriorityEventHandlersbecomeOrderedEventHandlersandViewScopedOrderedEventHandlers. The priority queue inPixely.PathFindingis untouched, that is a different meaning of the word.Breaking changes
IOrderablemust declare their ownint Order => 0;.docs/subrenderers.mdshows this and explains why there is no shared ordering interface.priority:must useorder:.Testing
dotnet buildclean,dotnet testgreen across all 13 test projects.