private void getFriendsPresenceData() { worldsWithFriends = new HashSet <string>(); DataEntityHandle[] entitiesByType = dataEntityCollection.GetEntitiesByType <FriendData>(); List <string> list = new List <string>(); for (int i = 0; i < entitiesByType.Length; i++) { if (dataEntityCollection.TryGetComponent <PresenceData>(entitiesByType[i], out var component)) { component.PresenceDataUpdated += OnPresenceDataUpdated; } if (dataEntityCollection.TryGetComponent <SwidData>(entitiesByType[i], out var component2)) { list.Add(component2.Swid); } else { Log.LogError(this, "Friend data handle did not have a SwidData component"); } } if (list.Count > 0) { dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <PresenceData> >(OnPresenceDataAdded); Service.Get <INetworkServicesManager>().PlayerStateService.GetOtherPlayerDataBySwids(list); } }
private void Start() { addListeners(); DataEntityHandle[] entitiesByType = dataEntityCollection.GetEntitiesByType <ServerObjectItemData>(); foreach (DataEntityHandle handle in entitiesByType) { onMmoItemAdded(handle, dataEntityCollection.GetComponent <ServerObjectItemData>(handle)); } start(); }
private void loadExistingPlayerHeldExperiences(long playerId) { DataEntityHandle[] entitiesByType = dataEntityCollection.GetEntitiesByType <ServerObjectItemData>(); foreach (DataEntityHandle handle in entitiesByType) { ServerObjectItemData component = dataEntityCollection.GetComponent <ServerObjectItemData>(handle); if (component.Item.Id.Parent != 0) { continue; } CPMMOItem item = component.Item; if (!(item is PlayerHeldItem)) { continue; } PlayerHeldItem playerHeldItem = (PlayerHeldItem)item; if (playerHeldItem.CreatorId != playerId) { continue; } DHeldObject dHeldObject = new DHeldObject(); dHeldObject.ObjectId = playerHeldItem.Type; DataEntityHandle dataEntityHandle = ((!dataEntityCollection.IsLocalPlayer(playerId)) ? dataEntityCollection.FindEntity <SessionIdData, long>(playerId) : dataEntityCollection.LocalPlayerHandle); if (!dataEntityHandle.IsNull) { HeldObjectsData component2 = dataEntityCollection.GetComponent <HeldObjectsData>(dataEntityHandle); PrefabContentKey propExperiencePathFromPropId = getPropExperiencePathFromPropId(playerHeldItem.Type); if (propExperiencePathFromPropId != null && !string.IsNullOrEmpty(propExperiencePathFromPropId.Key)) { component2.IsInvitationalExperience = true; CoroutineRunner.Start(loadPlayerHeldExperience(playerHeldItem), this, "loadPlayerHeldExperience"); } component2.HeldObject = dHeldObject; if (propExperiencePathFromPropId != null && !string.IsNullOrEmpty(propExperiencePathFromPropId.Key)) { component2.IsInvitationalExperience = true; } } } }
private static void updateMembershipDataValues(bool isAllAccessActive) { CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>(); DataEntityHandle[] entitiesByType = cPDataEntityCollection.GetEntitiesByType <MembershipData>(); for (int i = 0; i < entitiesByType.Length; i++) { MembershipData component = cPDataEntityCollection.GetComponent <MembershipData>(entitiesByType[i]); if (component.MembershipType != MembershipType.Member) { component.IsMember = isAllAccessActive; component.MembershipType = (isAllAccessActive ? MembershipType.AllAccessEventMember : MembershipType.None); } } }
private void Awake() { mascotNameToIconMap = new Dictionary <string, Sprite>(); dataEntityCollection = Service.Get <CPDataEntityCollection>(); DataEntityHandle[] entitiesByType = dataEntityCollection.GetEntitiesByType <PlayerStatusData>(); if (entitiesByType.Length > 0) { for (int i = 0; i < entitiesByType.Length; i++) { PlayerStatusData component = dataEntityCollection.GetComponent <PlayerStatusData>(entitiesByType[i]); onPlayerStatusDataAdded(new DataEntityEvents.ComponentAddedEvent <PlayerStatusData>(entitiesByType[i], component)); } } dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <PlayerStatusData> >(onPlayerStatusDataAdded); dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentRemovedEvent>(onComponentRemoved); PlayerNameController.OnPlayerNameAdded += onPlayerTagAdded; }