-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert movement packets #492
base: arena-vertical-slice
Are you sure you want to change the base?
Conversation
- Started to replace polling mechanism with event based mechanism
@garrettluskey I'm not that happy with the I'm open for suggestions, I will try something to find a better solution. EDIT: I rewrote part of the code and chose Polly. |
source/Missions/Services/Agents/Messages/MovementInputVectorChanged.cs
Outdated
Show resolved
Hide resolved
source/Missions/Services/Agents/Messages/LookDirectionChanged.cs
Outdated
Show resolved
Hide resolved
Also could you create some tests for rate limiting/testing each event |
Thanks for the feedback. Sorry for the delay so far, I gotta invest some more time into this. |
- Unsure what to make of Polly with this, as it seems like the cleaner solution - Implemented basic delta-management-logic
- refactored classes - added missing comments
…tion and deserialization work
If you could make the MovementHandler use the new methods that have been created in the NetworkAgentRegistry that would be great :) |
Will do while resolving the merge conflict 👍 |
…ord-Coop-Team/BannerlordCoop into convert-movement-packets
- Refactored AgentMovement.Apply() - Refactored AgentMovement into struct - Added operator overload to AgentEquipmentData due to default comparison in AgentMovement
To be able to close this PR a publisher of these events is still needed. Create a publisher class under the Agent folder that only manages the PlayerControlled Agent (Agent.Main). In this class poll the agents values that are in AgentMovement. Save those values in a AgentMovement variable. If these values change publish an event associated with that change. |
and sending events down the messageBroker - Some refactoring of events
…ord-Coop-Team/BannerlordCoop into convert-movement-packets
Should be good to go |
Also removed / 3 division
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 very small things to fix. Also check that this works in game. If needed I can help you get it working with some pair programming in the future. Just let me know
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behaviour?
The movement packets are currently actively polled and not rate limited.
What is the new behaviour?
Resolves #468
Subscribe
MovementHandler
toMessageBroker<Movement>
events which then get handled instead of being polled.In order to implement the rate-limit of 30 messages per second per agent, a Polly RateLimit-Policy has been introduced.
The desired amount of packets and the timespan can be adjusted via constant/static values at the top of the class.
Each AgentId is assigned their own policy, reason is given via code comment.
Other information
Writing a test proved difficult, as there is no way of getting a valid and initialized instance of
Agent
as far as I've seen. If there is a known way for this, please feel free to tag me and I will include tests.