protected bool OnPlayerOutfit(PlayerStateServiceEvents.PlayerOutfitChanged evt)
        {
            DataEntityHandle dataEntityHandle = ((!isLocalPlayer(evt.Outfit.sessionId.Value)) ? dataEntityCollection.FindEntity <SessionIdData, long>(evt.Outfit.sessionId.Value) : dataEntityCollection.LocalPlayerHandle);

            if (!dataEntityHandle.IsNull)
            {
                DCustomEquipment[] outfit = CustomEquipmentResponseAdaptor.ConvertResponseToOutfit(evt.Outfit.parts);
                if (!dataEntityCollection.TryGetComponent <AvatarDetailsData>(dataEntityHandle, out var component))
                {
                    component = dataEntityCollection.AddComponent <AvatarDetailsData>(dataEntityHandle);
                }
                component.Outfit = outfit;
            }
            return(false);
        }
Exemple #2
0
        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 <DisplayNameData>(dataEntityHandle, out var component2))
            {
                component2 = dataEntityCollection.AddComponent <DisplayNameData>(dataEntityHandle);
            }
            component2.DisplayName = data.name;
            if (!dataEntityCollection.TryGetComponent <QuestStateData>(dataEntityHandle, out var component3))
            {
                component3 = dataEntityCollection.AddComponent <QuestStateData>(dataEntityHandle);
            }
            component3.Data = data.quests;
            if (!dataEntityCollection.TryGetComponent <AvatarDetailsData>(dataEntityHandle, out var 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 <ProfileData>(dataEntityHandle, out var 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 <MembershipData>(dataEntityHandle, out var 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 <SubscriptionData>(dataEntityHandle, out var 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 <LegacyProfileData>(dataEntityHandle, out var 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 <TutorialData>(dataEntityHandle, out var 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);
        }
 private void setUpAvatarDetails(AvatarDetailsData avatarDetailsData, OtherPlayerData data)
 {
     DCustomEquipment[] outfit = ((data.outfit == null) ? new DCustomEquipment[0] : CustomEquipmentResponseAdaptor.ConvertResponseToOutfit(data.outfit));
     if (data.profile != null)
     {
         Dictionary <int, AvatarColorDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, AvatarColorDefinition> >();
         if (dictionary.TryGetValue(data.profile.colour, out var value) && value != null)
         {
             if (ColorUtility.TryParseHtmlString("#" + value.Color, out var color))
             {
                 avatarDetailsData.Init(outfit, color);
                 return;
             }
             Log.LogErrorFormatted(this, "Could not parse a color from color string {0}", value.Color);
             avatarDetailsData.Init(outfit);
         }
         else
         {
             Log.LogErrorFormatted(this, "Avatar color definitions did not contain a value for color id {0}", data.profile.colour);
             avatarDetailsData.Init(outfit);
         }
     }
     else
     {
         avatarDetailsData.Init(outfit);
     }
 }