Skip to content
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

refactor: restructure events #827

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

refactor: restructure events #827

wants to merge 2 commits into from

Conversation

TestingPlant
Copy link
Collaborator

Definitions to avoid ambiguity:

  • "Events" - Events from crates/hyperion/src/simulation/event.rs that are currently processed through EventQueue
  • "Event code" - Code in events/, such as the tag event

Events are mostly repackaged Valence packets with some processing, which can easily be done in the event code. Custom events can also already be sent through HandlerRegistry, and keeping the separate events system adds confusion on which system to use. In addition, the EventQueue approach requires allocations and requires us to maintain RuntimeLifetime, which cannot be checked at compile time and causes aborts at runtime if used improperly while the HandlerRegistry does not require allocations to send events and can send events with references to the original packet data that is completely checked at compile time. This PR removes the events system.

Copy link

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  24.0 ns ...  24.0 ns ]      +0.01%
ray_intersection/aabb_size_1                       [  24.0 ns ...  24.1 ns ]      +0.15%
ray_intersection/aabb_size_10                      [  22.7 ns ...  22.7 ns ]      -0.10%
ray_intersection/ray_distance_1                    [   5.3 ns ...   5.3 ns ]      +0.28%
ray_intersection/ray_distance_5                    [   9.4 ns ...   9.4 ns ]      +0.06%
ray_intersection/ray_distance_20                   [   9.4 ns ...   9.4 ns ]      -0.22%
overlap/no_overlap                                 [  30.2 ns ...  31.2 ns ]      +3.22%
overlap/partial_overlap                            [  30.3 ns ...  31.2 ns ]      +2.89%
overlap/full_containment                           [  22.9 ns ...  22.9 ns ]      -0.40%
point_containment/inside                           [   5.9 ns ...   5.9 ns ]      +0.11%
point_containment/outside                          [   5.3 ns ...   5.4 ns ]      +0.46%
point_containment/boundary                         [   5.8 ns ...   5.8 ns ]      +0.07%

Comparing to 9d60273

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 5.74713% with 82 lines in your changes missing coverage. Please review.

Project coverage is 23.03%. Comparing base (9d60273) to head (6450a16).

Files with missing lines Patch % Lines
crates/hyperion-command/src/system.rs 0.00% 34 Missing ⚠️
events/tag/src/module/chat.rs 0.00% 29 Missing ⚠️
crates/hyperion/src/simulation/handlers.rs 0.00% 7 Missing ⚠️
crates/hyperion/src/simulation/packet.rs 41.66% 7 Missing ⚠️
crates/hyperion-gui/src/lib.rs 0.00% 1 Missing ⚠️
crates/hyperion-item/src/lib.rs 0.00% 1 Missing ⚠️
crates/hyperion-respawn/src/lib.rs 0.00% 1 Missing ⚠️
crates/hyperion/src/ingress/mod.rs 0.00% 1 Missing ⚠️
events/tag/src/module/attack.rs 0.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main     #827      +/-   ##
==========================================
+ Coverage   22.96%   23.03%   +0.06%     
==========================================
  Files         159      159              
  Lines       16649    16498     -151     
  Branches      469      468       -1     
==========================================
- Hits         3824     3800      -24     
+ Misses      12727    12601     -126     
+ Partials       98       97       -1     
Files with missing lines Coverage Δ
crates/hyperion-utils/src/lifetime.rs 0.00% <ø> (-13.52%) ⬇️
crates/hyperion/src/net/mod.rs 6.20% <ø> (-0.47%) ⬇️
crates/hyperion/src/simulation/event.rs 0.00% <ø> (ø)
crates/hyperion/src/storage/event/queue/mod.rs 90.62% <ø> (-0.56%) ⬇️
crates/hyperion-gui/src/lib.rs 0.00% <0.00%> (ø)
crates/hyperion-item/src/lib.rs 0.00% <0.00%> (ø)
crates/hyperion-respawn/src/lib.rs 0.00% <0.00%> (ø)
crates/hyperion/src/ingress/mod.rs 24.34% <0.00%> (+0.05%) ⬆️
events/tag/src/module/attack.rs 0.00% <0.00%> (ø)
crates/hyperion/src/simulation/handlers.rs 4.33% <0.00%> (+0.06%) ⬆️
... and 3 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant