-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathGlobalDeferredLoadingSystem.cs
More file actions
97 lines (88 loc) · 4.37 KB
/
Copy pathGlobalDeferredLoadingSystem.cs
File metadata and controls
97 lines (88 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using Arch.Core;
using Arch.SystemGroups;
using Arch.SystemGroups.DefaultSystemGroups;
using DCL.AvatarRendering.Emotes;
using DCL.AvatarRendering.Wearables.Components;
using DCL.AvatarRendering.Wearables.Components.Intentions;
using DCL.AvatarRendering.Wearables.Helpers;
using DCL.Ipfs;
using DCL.Optimization.PerformanceBudgeting;
using DCL.Profiles;
using ECS.Groups;
using ECS.SceneLifeCycle;
using ECS.SceneLifeCycle.Components;
using ECS.SceneLifeCycle.SceneDefinition;
using ECS.SceneLifeCycle.Systems;
using ECS.StreamableLoading.AssetBundles;
using ECS.StreamableLoading.AssetBundles.InitialSceneState;
using ECS.StreamableLoading.AudioClips;
using ECS.StreamableLoading.DeferredLoading;
using ECS.StreamableLoading.GLTF;
using ECS.StreamableLoading.Textures;
using SceneRunner.Scene;
namespace DCL.GlobalPartitioning
{
/// <summary>
/// Weighs asset, definitions and scenes loading against each other according to their partition in the global world
/// </summary>
[UpdateInGroup(typeof(PresentationSystemGroup))]
[UpdateAfter(typeof(PrepareGlobalAssetBundleLoadingParametersSystem))]
[UpdateBefore(typeof(LoadGlobalSystemGroup))]
public partial class GlobalDeferredLoadingSystem : DeferredLoadingSystem
{
private static readonly QueryDescription[] COMPONENT_HANDLERS_SCENES_ASSETS;
private static readonly QueryDescription[] COMPONENT_HANDLERS_SCENES;
private readonly IScenesCache scenesCache;
private readonly Entity playerEntity;
static GlobalDeferredLoadingSystem()
{
COMPONENT_HANDLERS_SCENES_ASSETS = new[]
{
CreateQuery<GetSceneDefinitionList, SceneDefinitions>(),
CreateQuery<GetSceneDefinition, SceneEntityDefinition>(),
CreateQuery<GetISSDescriptor, ISSDescriptor>(),
CreateQuery<GetSceneFacadeIntention, ISceneFacade>(),
CreateQuery<GetWearableDTOByPointersIntention, WearablesDTOList>(),
CreateQuery<GetTrimmedWearableByParamIntention, IWearable[]>(),
CreateQuery<GetSmartWearableSceneIntention, GetSmartWearableSceneIntention.Result>(),
CreateQuery<GetAssetBundleManifestIntention, SceneAssetBundleManifest>(),
CreateQuery<GetAssetBundleIntention, AssetBundleData>(),
CreateQuery<GetGLTFIntention, GLTFData>(),
CreateQuery<GetTextureIntention, TextureData>(),
CreateQuery<GetEmotesDTOByPointersFromRealmIntention, EmotesDTOList>(),
CreateQuery<GetTrimmedEmotesByParamIntention, TrimmedEmotesResponse>(),
CreateQuery<GetAudioClipIntention, AudioClipData>(),
CreateQuery<GetProfilesBatchIntent, ProfilesBatchResult>(),
};
COMPONENT_HANDLERS_SCENES = new[]
{
CreateQuery<GetSceneDefinitionList, SceneDefinitions>(),
CreateQuery<GetSceneDefinition, SceneEntityDefinition>(),
CreateQuery<GetISSDescriptor, ISSDescriptor>(),
};
}
public GlobalDeferredLoadingSystem(World world, IReleasablePerformanceBudget releasablePerformanceLoadingBudget, IPerformanceBudget memoryBudget, IScenesCache scenesCache, Entity playerEntity)
: base(world, COMPONENT_HANDLERS_SCENES, releasablePerformanceLoadingBudget, memoryBudget)
{
this.scenesCache = scenesCache;
this.playerEntity = playerEntity;
}
protected override void Update(float t)
{
FilterHandlersIfInTeleport();
base.Update(t);
}
private void FilterHandlersIfInTeleport()
{
bool downloadOnlySceneMetadata = false;
//We check if the player is teleporting, and if the scene we want to teleport to has started.
//If so, only scene metadata will be allowed to de downloaded
TeleportUtils.PlayerTeleportingState teleportParcel = TeleportUtils.GetTeleportParcel(World, playerEntity);
if (teleportParcel.IsTeleporting
&& scenesCache.TryGetByParcel(teleportParcel.Parcel, out ISceneFacade scene)
&& scene.SceneStateProvider.State == SceneState.Running)
downloadOnlySceneMetadata = true;
sameBoatQueries = downloadOnlySceneMetadata ? COMPONENT_HANDLERS_SCENES : COMPONENT_HANDLERS_SCENES_ASSETS;
}
}
}