コード例 #1
0
        private bool OnPlayerJoins(WorldServiceEvents.PlayerJoinRoomEvent evt)
        {
            if (isLocalPlayer(evt.SessionId))
            {
                return(false);
            }
            DataEntityHandle handle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, evt.Name, evt.SessionId);

            PlayerDataEntityFactory.AddCommonDataComponents(dataEntityCollection, handle);
            PlayerDataEntityFactory.AddCommonZoneScopeDataComponents(dataEntityCollection, handle);
            if (!dataEntityCollection.HasComponent <RemotePlayerData>(handle))
            {
                dataEntityCollection.AddComponent <RemotePlayerData>(handle);
            }
            if (!dataEntityCollection.HasComponent <ParticipationData>(handle))
            {
                dataEntityCollection.AddComponent <ParticipationData>(handle);
            }
            PresenceData component = dataEntityCollection.GetComponent <PresenceData>(handle);

            if (dataEntityCollection.TryGetComponent <PresenceData>(dataEntityCollection.LocalPlayerHandle, out var component2))
            {
                component.World             = component2.World;
                component.Room              = component2.Room;
                component.ContentIdentifier = component2.ContentIdentifier;
                component.InstanceRoom      = component2.InstanceRoom;
            }
            component.IsDisconnecting = false;
            eventDispatcher.DispatchEvent(new NetworkControllerEvents.RemotePlayerJoinedRoomEvent(handle));
            return(false);
        }
コード例 #2
0
        protected virtual bool onRoomJoined(WorldServiceEvents.SelfRoomJoinedEvent evt)
        {
            DataEntityHandle localPlayerHandle = dataEntityCollection.LocalPlayerHandle;

            if (localPlayerHandle.IsNull)
            {
                throw new MissingReferenceException("The local player handle does not exist!");
            }
            PlayerDataEntityFactory.AddCommonDataComponents(dataEntityCollection, localPlayerHandle);
            PlayerDataEntityFactory.AddCommonZoneScopeDataComponents(dataEntityCollection, localPlayerHandle);
            dataEntityCollection.AddComponent <LocalPlayerInZoneData>(localPlayerHandle);
            PresenceData component2 = dataEntityCollection.GetComponent <PresenceData>(localPlayerHandle);

            if (string.IsNullOrEmpty(evt.Room.zoneId.instanceId))
            {
                component2.World             = evt.Room.world;
                component2.Room              = evt.Room.zoneId.name;
                component2.ContentIdentifier = evt.Room.contentIdentifier;
                component2.InstanceRoom      = null;
            }
            else
            {
                component2.InstanceRoom = evt.Room.zoneId;
            }
            DataEntityHandle[] remotePlayerHandles = dataEntityCollection.GetRemotePlayerHandles();
            for (int i = 0; i < remotePlayerHandles.Length; i++)
            {
                PresenceData component3 = dataEntityCollection.GetComponent <PresenceData>(remotePlayerHandles[i]);
                if (string.IsNullOrEmpty(evt.Room.zoneId.instanceId))
                {
                    component3.World             = evt.Room.world;
                    component3.Room              = evt.Room.zoneId.name;
                    component3.ContentIdentifier = evt.Room.contentIdentifier;
                    component3.InstanceRoom      = null;
                }
                else
                {
                    component3.InstanceRoom = evt.Room.zoneId;
                }
            }
            if (dataEntityCollection.TryGetComponent <SessionIdData>(localPlayerHandle, out var component4))
            {
                component4.SessionId = evt.SessionId;
            }
            else
            {
                component4 = dataEntityCollection.AddComponent(localPlayerHandle, delegate(SessionIdData component)
                {
                    component.SessionId = evt.SessionId;
                });
            }
            eventDispatcher.DispatchEvent(new NetworkControllerEvents.LocalPlayerJoinedRoomEvent(localPlayerHandle, evt.Room.world, evt.Room.zoneId.name));
            return(false);
        }
コード例 #3
0
        private bool onLocalPlayerDataReceived(PlayerStateServiceEvents.LocalPlayerDataReceived evt)
        {
            if (dataEntityCollection == null)
            {
                return(false);
            }
            DataEntityHandle localPlayerHandle = dataEntityCollection.LocalPlayerHandle;
            bool             flag = !dataEntityCollection.HasComponent <DisplayNameData>(localPlayerHandle);

            PlayerDataEntityFactory.AddLocalPlayerProfileDataComponents(dataEntityCollection, evt.Data, isOnline: true);
            if (flag)
            {
                PlayerDataEntityFactory.AddCommonDataComponents(dataEntityCollection, localPlayerHandle);
                PlayerDataEntityFactory.AddLocalPlayerSessionScopeDataComponents(dataEntityCollection, localPlayerHandle);
                doFTUECheck(localPlayerHandle);
                ILocalUser localUser = Service.Get <SessionManager>().LocalUser;
                networkServicesManager.FriendsService.SetLocalUser(localUser);
                setLocalUser(localUser);
                string text = "free";
                if (dataEntityCollection.IsLocalPlayerMember())
                {
                    text = "member";
                }
                string tier = (EnvironmentManager.AreHeadphonesConnected ? "headphone_on" : "headphone_off");
                Service.Get <ICPSwrveService>().Action("login", text, localUser.HashedId, tier);
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("status", text);
                Service.Get <ICPSwrveService>().UserUpdate(dictionary);
                eventDispatcher.DispatchEvent(new NetworkControllerEvents.LocalPlayerDataReadyEvent(localPlayerHandle));
            }
            if (evt.Data.minigameProgress != null)
            {
                foreach (MinigameProgress item in evt.Data.minigameProgress)
                {
                    dataEntityCollection.GetComponent <MiniGamePlayCountData>(localPlayerHandle)?.SetMinigamePlayCount(item.gameId, item.playCount);
                }
            }
            return(false);
        }