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); }
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); }
public void OnReceivedOutgoingFriendInvitation(IOutgoingFriendInvitation outgoingFriendInvitation) { string text = outgoingFriendInvitation.Invitee.DisplayName.Text; if (!dataEntityCollection.TryFindEntity <DisplayNameData, string>(text, out var dataEntityHandle)) { dataEntityHandle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, text); } addOutgoingInvitation(dataEntityHandle, outgoingFriendInvitation); onOutgoingInvitationsListUpdated(); }
public void OnOutgoingInvitationsListReady(List <IOutgoingFriendInvitation> outgoingFriendInvitations) { for (int i = 0; i < outgoingFriendInvitations.Count; i++) { string text = outgoingFriendInvitations[i].Invitee.DisplayName.Text; if (text == null || text.Length <= 0) { Log.LogError(this, "DisplayName is empty for a Mix friend, will not add friend to list."); continue; } DataEntityHandle handle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, outgoingFriendInvitations[i].Invitee.DisplayName.Text); addOutgoingInvitation(handle, outgoingFriendInvitations[i]); } }
public void OnFriendsListReady(List <IFriend> friends) { for (int i = 0; i < friends.Count; i++) { string text = friends[i].DisplayName.Text; if (text == null || text.Length <= 0) { Log.LogError(this, "DisplayName is empty for a Mix friend, will not add friend to list."); continue; } DataEntityHandle handle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, friends[i].DisplayName.Text); addFriendStatusAndSwid(handle, friends[i]); } }
private void addOtherPlayerIglooListing(IglooListItem iglooListItem) { DataEntityHandle handle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, iglooListItem.ownerData.name); if (!dataEntityCollection.TryGetComponent <IglooListingData>(handle, out var component)) { component = dataEntityCollection.AddComponent <IglooListingData>(handle); } RoomPopulationScale roomPopulation = RoomPopulationScale.ZERO; if (iglooListItem.iglooPopulation.HasValue) { roomPopulation = iglooListItem.iglooPopulation.Value; } component.RoomPopulation = roomPopulation; }
public void OnFindUserSent(bool success, IUnidentifiedUser searchedUser) { if (!success) { return; } if (!dataEntityCollection.TryFindEntity <DisplayNameData, string>(searchedUser.DisplayName.Text, out var dataEntityHandle)) { dataEntityHandle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, searchedUser.DisplayName.Text); } if (!dataEntityCollection.TryGetComponent <SearchedUserData>(dataEntityHandle, out var component)) { DataEntityHandle entityByType = dataEntityCollection.GetEntityByType <SearchedUserData>(); if (!entityByType.IsNull) { dataEntityCollection.RemoveComponent <SearchedUserData>(entityByType); } component = dataEntityCollection.AddComponent <SearchedUserData>(dataEntityHandle); } component.SearchedUser = searchedUser; }
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); }
private void addOtherPlayerDetails(OtherPlayerData data) { DataEntityHandle handle; if (data.id.type == PlayerId.PlayerIdType.SWID) { handle = dataEntityCollection.FindEntity <SwidData, string>(data.id.id); if (DataEntityHandle.IsNullValue(handle)) { handle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, data.name); } } else { handle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, data.name); } if (!dataEntityCollection.TryGetComponent <AvatarDetailsData>(handle, out var component)) { component = dataEntityCollection.AddComponent <AvatarDetailsData>(handle); } if (!dataEntityCollection.TryGetComponent <ProfileData>(handle, out var component2)) { component2 = dataEntityCollection.AddComponent <ProfileData>(handle); } if (!dataEntityCollection.TryGetComponent <MembershipData>(handle, out var component3)) { component3 = dataEntityCollection.AddComponent <MembershipData>(handle); } if (!dataEntityCollection.TryGetComponent <PresenceData>(handle, out var component4)) { component4 = dataEntityCollection.AddComponent <PresenceData>(handle); } setUpAvatarDetails(component, data); setUpProfile(component2, component4, component3, data); component4.IsDisconnecting = false; }