-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMultiplayerPlugin.cs
More file actions
178 lines (168 loc) · 8.01 KB
/
Copy pathMultiplayerPlugin.cs
File metadata and controls
178 lines (168 loc) · 8.01 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using Arch.SystemGroups;
using CrdtEcsBridge.Components.Transform;
using Cysharp.Threading.Tasks;
using DCL.AssetsProvision;
using DCL.AvatarRendering.Emotes;
using DCL.Character;
using DCL.DebugUtilities;
using DCL.Multiplayer.Connections.Archipelago.Rooms;
using DCL.Multiplayer.Connections.FfiClients;
using DCL.Multiplayer.Connections.GateKeeper.Rooms;
using DCL.Multiplayer.Connections.Messaging.Hubs;
using DCL.Multiplayer.Connections.RoomHubs;
using DCL.Multiplayer.Connections.Rooms.Connective;
using DCL.Multiplayer.Connections.Rooms.Status;
using DCL.Multiplayer.Connections.Systems;
using DCL.Multiplayer.Connections.Systems.Throughput;
using DCL.Multiplayer.Profiles.BroadcastProfiles;
using DCL.Multiplayer.Profiles.Entities;
using DCL.Multiplayer.Profiles.Poses;
using DCL.Multiplayer.Profiles.RemoteAnnouncements;
using DCL.Multiplayer.Profiles.RemoteProfiles;
using DCL.Multiplayer.Profiles.RemoveIntentions;
using DCL.Multiplayer.Profiles.Systems;
using DCL.Multiplayer.Profiles.Tables;
using DCL.Multiplayer.SDK.Components;
using DCL.Multiplayer.SDK.Systems.GlobalWorld;
using DCL.Optimization.Pools;
using DCL.Profiles;
using DCL.RealmNavigation;
using DCL.UserInAppInitializationFlow;
using ECS;
using ECS.LifeCycle.Systems;
using ECS.SceneLifeCycle;
using LiveKit.Internal.FFIClients;
using System;
using System.Threading;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Pool;
using Object = UnityEngine.Object;
namespace DCL.PluginSystem.Global
{
public class MultiplayerPlugin : IDCLGlobalPlugin<MultiplayerPlugin.Settings>
{
private readonly IAssetsProvisioner assetsProvisioner;
private readonly IArchipelagoIslandRoom archipelagoIslandRoom;
private readonly ICharacterObject characterObject;
private readonly IDebugContainerBuilder debugContainerBuilder;
private readonly IEmoteStorage emoteStorage;
private readonly IEntityParticipantTable entityParticipantTable;
private readonly IGateKeeperSceneRoom gateKeeperSceneRoom;
private readonly IMessagePipesHub messagePipesHub;
private readonly IProfileBroadcast profileBroadcast;
private readonly IProfileRepository profileRepository;
private readonly ILoadingStatus realFlowLoadingStatus;
private readonly IRealmData realmData;
private readonly IRemoteEntities remoteEntities;
private readonly IRemoteMetadata remoteMetadata;
private readonly RemoteAnnouncements remoteAnnouncements;
private readonly RemoteProfiles remoteProfiles;
private readonly IRoomHub roomHub;
private readonly RoomsStatus roomsStatus;
private readonly IScenesCache scenesCache;
private readonly CharacterDataPropagationUtility characterDataPropagationUtility;
private readonly IComponentPoolsRegistry poolsRegistry;
private readonly ThroughputBufferBunch islandThroughputBufferBunch;
private readonly ThroughputBufferBunch sceneThroughputBufferBunch;
private readonly IActivatableConnectiveRoom chatRoom;
private readonly IActivatableConnectiveRoom voiceChatRoom;
public MultiplayerPlugin(
IAssetsProvisioner assetsProvisioner,
IArchipelagoIslandRoom archipelagoIslandRoom,
IGateKeeperSceneRoom gateKeeperSceneRoom,
IActivatableConnectiveRoom chatRoom,
IRoomHub roomHub,
RoomsStatus roomsStatus,
IProfileRepository profileRepository,
IProfileBroadcast profileBroadcast,
IDebugContainerBuilder debugContainerBuilder,
ILoadingStatus realFlowLoadingStatus,
IEntityParticipantTable entityParticipantTable,
IMessagePipesHub messagePipesHub,
IRemoteMetadata remoteMetadata,
RemoteAnnouncements remoteAnnouncements,
RemoteProfiles remoteProfiles,
ICharacterObject characterObject,
IRealmData realmData,
IRemoteEntities remoteEntities,
IScenesCache scenesCache,
IEmoteStorage emoteStorage,
CharacterDataPropagationUtility characterDataPropagationUtility,
IComponentPoolsRegistry poolsRegistry,
ThroughputBufferBunch islandThroughputBufferBunch,
ThroughputBufferBunch sceneThroughputBufferBunch, IActivatableConnectiveRoom voiceChatRoom)
{
this.assetsProvisioner = assetsProvisioner;
this.archipelagoIslandRoom = archipelagoIslandRoom;
this.gateKeeperSceneRoom = gateKeeperSceneRoom;
this.chatRoom = chatRoom;
this.roomHub = roomHub;
this.roomsStatus = roomsStatus;
this.profileRepository = profileRepository;
this.profileBroadcast = profileBroadcast;
this.debugContainerBuilder = debugContainerBuilder;
this.realFlowLoadingStatus = realFlowLoadingStatus;
this.entityParticipantTable = entityParticipantTable;
this.messagePipesHub = messagePipesHub;
this.remoteMetadata = remoteMetadata;
this.remoteAnnouncements = remoteAnnouncements;
this.remoteProfiles = remoteProfiles;
this.characterObject = characterObject;
this.remoteEntities = remoteEntities;
this.realmData = realmData;
this.scenesCache = scenesCache;
this.emoteStorage = emoteStorage;
this.characterDataPropagationUtility = characterDataPropagationUtility;
this.poolsRegistry = poolsRegistry;
this.islandThroughputBufferBunch = islandThroughputBufferBunch;
this.sceneThroughputBufferBunch = sceneThroughputBufferBunch;
this.voiceChatRoom = voiceChatRoom;
}
public void Dispose()
{
archipelagoIslandRoom.Dispose();
gateKeeperSceneRoom.Dispose();
#if !NO_LIVEKIT_MODE
IFFIClient.Default.Dispose();
#endif
}
public async UniTask InitializeAsync(Settings settings, CancellationToken ct)
{
RemoteAvatarCollider remoteAvatarCollider = (await assetsProvisioner.ProvideMainAssetAsync(settings.RemoteAvatarColliderPrefab, ct)).Value.GetComponent<RemoteAvatarCollider>();
remoteEntities.Initialize(remoteAvatarCollider);
}
public void InjectToWorld(ref ArchSystemsWorldBuilder<Arch.Core.World> builder, in GlobalPluginArguments globalPluginArguments)
{
#if !NO_LIVEKIT_MODE
IFFIClient.Default.EnsureInitialize();
DebugRoomsSystem.InjectToWorld(ref builder, roomsStatus, archipelagoIslandRoom, gateKeeperSceneRoom, chatRoom, voiceChatRoom, entityParticipantTable, remoteMetadata, debugContainerBuilder);
DebugThroughputRoomsSystem.InjectToWorld(ref builder, roomHub, debugContainerBuilder, islandThroughputBufferBunch, sceneThroughputBufferBunch);
MultiplayerProfilesSystem.InjectToWorld(ref builder,
remoteAnnouncements,
new LogRemoveIntentions(
new ThreadSafeRemoveIntentions(roomHub)
),
remoteProfiles,
profileBroadcast,
remoteEntities,
remoteMetadata,
characterObject,
realFlowLoadingStatus,
realmData
);
ResetDirtyFlagSystem<PlayerCRDTEntity>.InjectToWorld(ref builder);
PlayerCRDTEntitiesHandlerSystem.InjectToWorld(ref builder, scenesCache);
PlayerProfileDataPropagationSystem.InjectToWorld(ref builder, characterDataPropagationUtility);
ResetDirtyFlagSystem<AvatarEmoteCommandComponent>.InjectToWorld(ref builder);
AvatarEmoteCommandPropagationSystem.InjectToWorld(ref builder, emoteStorage);
PlayerTransformPropagationSystem.InjectToWorld(ref builder, poolsRegistry.GetReferenceTypePool<SDKTransform>());
#endif
}
[Serializable]
public class Settings : IDCLPluginSettings
{
[SerializeField] public AssetReferenceGameObject RemoteAvatarColliderPrefab;
}
}
}