public void Initialize(DataEntityHandle handle) { mapCategoriesStrings(); DataEntityCollection dataEntityCollection = Service.Get <CPDataEntityCollection>(); DisplayNameData component = dataEntityCollection.GetComponent <DisplayNameData>(handle); if (component != null && !string.IsNullOrEmpty(component.DisplayName)) { displayName = component.DisplayName; NameText.text = displayName; } else { Log.LogError(this, "Could not find display name data on this handle"); destroy(); } if (dataEntityCollection.TryGetComponent <AvatarDetailsData>(handle, out var component2)) { AvatarRenderTextureComponent.RenderAvatar(component2); } else { Log.LogError(this, "AvatarDetailsData was not found"); } if (dataEntityCollection.TryGetComponent <ProfileData>(handle, out profileData)) { bool flag = profileData != null && profileData.HasPublicIgloo; reportIglooButton.ToggleButton(flag); } else { Log.LogError(this, "Could not find ProfileData for this handle."); reportIglooButton.ToggleButton(enabled: false); } }
private string getPlayerName(GameObject playerObj) { if (AvatarDataHandle.TryGetPlayerHandle(playerObj, out var handle) && dataEntityCollection.TryGetComponent <DisplayNameData>(handle, out var component)) { return(component.DisplayName); } return("Error: name not found"); }
public static DataEntityHandle CreateRemotePlayerEntity(DataEntityCollection dataEntityCollection, string displayName, string swid) { DataEntityHandle dataEntityHandle = createRemotePlayerEntity(dataEntityCollection, displayName); if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out SwidData component)) { component = dataEntityCollection.AddComponent <SwidData>(dataEntityHandle); } component.Swid = swid; return(dataEntityHandle); }
private string createHash(DataEntityHandle handle, string context) { string text = null; if (dataEntityCollection.TryGetComponent <AvatarDetailsData>(handle, out var component) && component.Outfit != null) { string displayName = dataEntityCollection.GetComponent <DisplayNameData>(handle).DisplayName; AvatarDetailsHashable data = new AvatarDetailsHashable(component, displayName, context); return(MD5HashUtil.GetHash(data)); } throw new ArgumentException("Data entity handle did not have valid avatar details"); }
private void showOwner(SceneOwnerData ownerData) { ownerHandle = PlayerDataEntityFactory.CreateRemotePlayerEntity(dataEntityCollection, ownerData.Name); ownerDisplay.SetPlayer(ownerHandle); ProfileData component; bool flag = dataEntityCollection.TryGetComponent <ProfileData>(ownerHandle, out component); MembershipData component2; bool flag2 = dataEntityCollection.TryGetComponent <MembershipData>(ownerHandle, out component2); if (!flag || !flag2) { Service.Get <OtherPlayerDetailsRequestBatcher>().RequestOtherPlayerDetails(ownerHandle); } if (flag) { bool isOnline = getIsOnline(ownerHandle); ownerDisplay.SetOnlineStatus(isOnline); renderOwner(ownerDisplay, ownerHandle, ownerData.Name, isOnline); } ownerDisplay.SetMembershipType(getMembershipType(ownerHandle)); }
private static void addDailySpinDataComponent(DataEntityCollection dataEntityCollection, DataEntityHandle handle, LocalPlayerData localPlayerData) { if (localPlayerData.dailySpinData != null) { if (!dataEntityCollection.TryGetComponent(handle, out DailySpinEntityData component)) { component = dataEntityCollection.AddComponent <DailySpinEntityData>(handle); } component.CurrentChestId = localPlayerData.dailySpinData.currentChestId; component.NumChestsReceivedOfCurrentChestId = localPlayerData.dailySpinData.numChestsReceivedOfCurrentChestId; component.NumPunchesOnCurrentChest = localPlayerData.dailySpinData.numPunchesOnCurrentChest; component.TimeOfLastSpinInMilliseconds = localPlayerData.dailySpinData.timeOfLastSpinInMilliseconds; } }
public void RequestImage(DataEntityHandle handle, AvatarAnimationFrame avatarAnimationFrame = null, string context = null) { if (UseCache && string.IsNullOrEmpty(context)) { throw new ArgumentException("If using the cache, the context string must not be null"); } string displayName = dataEntityCollection.GetComponent <DisplayNameData>(handle).DisplayName; if (!pendingRenderRequests.ContainsKey(displayName)) { RenderRequest renderRequest = new RenderRequest(handle); renderRequest.AvatarAnimationFrame = avatarAnimationFrame; renderRequest.Context = context; pendingRenderRequests.Add(displayName, renderRequest); if (!dataEntityCollection.TryGetComponent <AvatarDetailsData>(handle, out var component)) { otherPlayerDetailsRequestBatcher.RequestOtherPlayerDetails(handle); return; } renderRequest.AvatarDetailsData = component; getImage(displayName, renderRequest); } }
public ServerObjectTracker(PropService propService, DataEntityHandle handle, ServerObjectItemData serverObjectItemData) { this.serverObjectItemData = serverObjectItemData; this.propService = propService; this.handle = handle; DataEntityCollection dataEntityCollection = Service.Get <CPDataEntityCollection>(); if (dataEntityCollection.TryGetComponent <ServerObjectPositionData>(handle, out var component)) { spawnObject(component.Position); return; } dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <ServerObjectPositionData> >(onComponentAdded); dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.EntityRemovedEvent>(onItemRemoved); }
public static DataEntityHandle CreateRemotePlayerEntity(DataEntityCollection dataEntityCollection, string displayName, long sessionId) { DataEntityHandle dataEntityHandle = createRemotePlayerEntity(dataEntityCollection, displayName); if (dataEntityCollection.TryGetComponent(dataEntityHandle, out SessionIdData component2)) { component2.SessionId = sessionId; } else { component2 = dataEntityCollection.AddComponent(dataEntityHandle, delegate(SessionIdData component) { component.SessionId = sessionId; }); } return(dataEntityHandle); }
public static DataEntityHandle AddLocalPlayerProfileDataComponents(DataEntityCollection dataEntityCollection, LocalPlayerData data, bool isOnline = false) { DataEntityHandle dataEntityHandle = dataEntityCollection.FindEntityByName("LocalPlayer"); if (dataEntityHandle.IsNull) { return(dataEntityHandle); } if (data == null) { return(dataEntityHandle); } if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out DisplayNameData component2)) { component2 = dataEntityCollection.AddComponent <DisplayNameData>(dataEntityHandle); } component2.DisplayName = data.name; if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out QuestStateData component3)) { component3 = dataEntityCollection.AddComponent <QuestStateData>(dataEntityHandle); } component3.Data = data.quests; if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out AvatarDetailsData component4)) { component4 = dataEntityCollection.AddComponent <AvatarDetailsData>(dataEntityHandle); component4.BodyColor = AvatarService.DefaultBodyColor; component4.Outfit = new DCustomEquipment[0]; } if (data.outfit != null && data.outfit.Count > 0) { component4.Outfit = CustomEquipmentResponseAdaptor.ConvertResponseToOutfit(data.outfit); } if (data.profile != null) { Dictionary <int, AvatarColorDefinition> avatarColors = Service.Get <GameData>().Get <Dictionary <int, AvatarColorDefinition> >(); component4.BodyColor = AvatarBodyColorAdaptor.GetColorFromDefinitions(avatarColors, data.profile.colour); } if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out ProfileData component5)) { component5 = dataEntityCollection.AddComponent <ProfileData>(dataEntityHandle); } component5.PenguinAgeInDays = ((data.profile != null) ? data.profile.daysOld : 0); component5.IsOnline = isOnline; component5.IsMigratedPlayer = (data.migrationData != null && data.migrationData.status.Equals("MIGRATED")); component5.ZoneId = data.zoneId; if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out MembershipData component6)) { component6 = dataEntityCollection.AddComponent <MembershipData>(dataEntityHandle); } component6.IsMember = data.member; component6.MembershipType = (data.member ? MembershipType.Member : MembershipType.None); component6.MembershipExpireDate = data.membershipExpireDate; component6.MembershipTrialAvailable = data.trialAvailable; if (!component6.IsMember && Service.Get <AllAccessService>().IsAllAccessActive()) { component6.IsMember = true; component6.MembershipType = MembershipType.AllAccessEventMember; } logPlayerStatusBI(data); if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out SubscriptionData component7)) { component7 = dataEntityCollection.AddComponent <SubscriptionData>(dataEntityHandle); } component7.SubscriptionVendor = data.subscriptionVendor; component7.SubscriptionProductId = data.subscriptionProductId; component7.SubscriptionPaymentPending = data.subscriptionPaymentPending; component7.SubscriptionRecurring = data.recurring; if (data.migrationData != null && data.migrationData.legacyAccountData != null) { if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out LegacyProfileData component8)) { component8 = dataEntityCollection.AddComponent <LegacyProfileData>(dataEntityHandle); } component8.Username = data.migrationData.legacyAccountData.username; component8.IsMember = data.migrationData.legacyAccountData.member; component8.CreatedDate = data.migrationData.legacyAccountData.createdDate; component8.MigratedDate = data.migrationData.migratedDate; } byte[] array = new byte[data.tutorialData.Count]; for (int i = 0; i < array.Length; i++) { array[i] = (byte)data.tutorialData[i]; } if (!dataEntityCollection.TryGetComponent(dataEntityHandle, out TutorialData component9)) { component9 = dataEntityCollection.AddComponent <TutorialData>(dataEntityHandle); } component9.Data = new BitArray(array); switch (data.id.type) { case PlayerId.PlayerIdType.SESSION_ID: if (!dataEntityCollection.HasComponent <SessionIdData>(dataEntityHandle)) { dataEntityCollection.AddComponent(dataEntityHandle, delegate(SessionIdData component) { component.SessionId = Convert.ToInt64(data.id.id); }); } break; case PlayerId.PlayerIdType.SWID: if (!dataEntityCollection.HasComponent <SwidData>(dataEntityHandle)) { dataEntityCollection.AddComponent <SwidData>(dataEntityHandle).Swid = data.id.id; } break; } setClaimedRewardIds(dataEntityCollection, dataEntityHandle, data.claimedRewardIds); addDailySpinDataComponent(dataEntityCollection, dataEntityHandle, data); return(dataEntityHandle); }