Example #1
0
        public void AddToRecentLog(Participant userA, Participant userB)
        {
            // HACK: This whole function is a bit of a hack. But it works for now :P
            string name = UserSocialLogName.Value.Format(userA.Id);

            SaveLoad.Load(name, out string log);
            if (log == null)
            {
                string json = JsonUtility.ToJson(new SerializedSocial()
                {
                    Recent = new Participant[0], Friends = new Participant[0]
                });
                SaveLoad.Save(json, name);
                AddToRecentLog(userA, userB);
                return;
            }

            SerializedSocial serializedSocial = JsonUtility.FromJson <SerializedSocial>(log);

            List <Participant> newRecent = new List <Participant>(serializedSocial.Recent);

            newRecent.Insert(0, userB);
            serializedSocial.Recent = newRecent.ToArray();

            string updatedLog = JsonUtility.ToJson(serializedSocial);

            SaveLoad.Save(updatedLog, name);
        }
        public void OnSocialAcquired(string serializedSocial)
        {
            SerializedSocial social = JsonUtility.FromJson <SerializedSocial>(serializedSocial);

            Spawn(FriendsContainer, social.Friends);
            Spawn(RecentContainer, social.Recent);
        }