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); }
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 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; }