Contents
Class EntityTrackerSystems
java.lang.Object
com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems
Current system structure:
== Update Player Movement from packets
== Update Entity Positions
== Update SpatialStructure's
- Query(Position, Model): Update SpatialStructure for entities with Position's and Model's
++ Repeat for different entity archetypes that should be visible
== Update EntityViewer components
- Query(EntityViewer) parallel: Iterate all entities with EntityViewer component
- Clear EntityViewer#visible
- Query(EntityViewer, Position) parallel: Iterate all entities with EntityViewer and Position components
- Find all Query(Position, Model)'s in range using SpatialStructure
- Skip if culled by LOD (LOD is handled automatically for Model's)
- Add to EntityViewer#visible
++ Repeat for different entity archetypes that should be visible
++ Other systems can run to filter visible entities in EntityViewer#visible
- eg. Hidden players
++++ TODO: For this to work well we need to have an optimized iteration for EntityViewer#visible using a Query
(Could easily have a custom structure for this, but what happens when an entity archetype changes, this structure will be stale?)
== Update Visible components
- Query(Visible) parallel: Iterate all entities with Visible component
- Clear Visible#visibleTo
- Query(EntityViewer) parallel: Iterate all entities with EntityViewer component
- Query(not(Visible)) from EntityViewer#visible
- (CommandBuffer) Add Visible component
- Query(EntityViewer) parallel: Iterate all entities with EntityViewer component
- Query(Visible) EntityViewer#visible
- Add EntityViewer to Visible#visibleTo (ConcurrentHashMap.newKeySet() so we can add in parallel)
- Query(Visible) parallel: Iterate all entities with Visible component
- If Visible#visibleTo is empty
- (CommandBuffer) Remove Visible component
== Generate Component Updates
- Query(Visible, Model) parallel:
- If model changed
- Generate model packet
- For each Visible#visibleTo
- Queue component update in EntityViewer#updates
- Else Visible#newlyVisibleTo not empty
- Generate model packet
- For each Visible#newlyVisibleTo
- Queue component update in EntityViewer#updates
// Note: Since we are pushing packets to queues the packet generation can be handled by the system
// meaning its easy to have global, grouped or per viewer packets.
++ Repeat for different components that sync state
== Send Packets
- Query(EntityViewer) parallel: Iterate all entities with EntityViewer component
- Send packet
removed entities (exists in EntityViewer#sent but not EntityViewer#visible)
removed components (exists in EntityViewer#sent but not in the entity Archetype)
updated components
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classAn entity ticking system that handles updating the effects controller based on visible entitiesstatic classstatic classQueuesModelUpdatepackets for newly visible and updated entities with aModelComponent.static classQueuesPlayerSkinUpdatepackets for newly visible and updated entities with aPlayerSkinComponent.static classstatic classAn entity viewer is a core part of the entity tracker and is what allows things to 'see' other entities.static classFilters the visible set of entities by removing player entities that the viewing player has hidden.static classUses the bounding box on entities to apply LOD culling to the visible set of entities.static classstatic classThis system removes theEntityTrackerSystems.Visiblecomponent from entities when they are removed from the store.static classstatic classThis component tracks whatEntityTrackerSystems.EntityViewer's can currently see this entity. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemGroup<EntityStore> A SystemGroup to make it easy for others to add systems for finding visible entities (eg.static final SystemGroup<EntityStore> A SystemGroup to make it easy for others to add systems for queuing packets -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanclear(Holder<EntityStore> holder) static booleanclear(Ref<EntityStore> viewerRef, Store<EntityStore> store) static booleandespawnAll(Ref<EntityStore> viewerRef, Store<EntityStore> store)
-
Field Details
-
FIND_VISIBLE_ENTITIES_GROUP
A SystemGroup to make it easy for others to add systems for finding visible entities (eg. Item instead of Model) -
QUEUE_UPDATE_GROUP
A SystemGroup to make it easy for others to add systems for queuing packets
-
-
Constructor Details
-
EntityTrackerSystems
public EntityTrackerSystems()
-
-
Method Details
-
despawnAll
public static boolean despawnAll(@Nonnull Ref<EntityStore> viewerRef, @Nonnull Store<EntityStore> store) -
clear
-
clear
Clears the viewer's sent-entity state from aHolder, for use when the viewer is between worlds and therefore not present in any activeStore.Unlike
clear(Ref, Store), this variant does not clean upEntityTrackerSystems.Visible.visibleTobecause the refs insentbelong to a previous world's store and are no longer relevant.- Parameters:
holder- The holder of the viewer entity.- Returns:
trueif the viewer component was found and cleared,falseotherwise.
-