Esempio n. 1
0
        public UserRadioContent(String collection, String filename)
        {
            m_Name        = "CSLMusic" + "/" + collection + "/" + Path.GetFileNameWithoutExtension(filename);
            m_DisplayName = Path.GetFileNameWithoutExtension(filename);
            m_FileName    = filename;
            m_Collection  = collection;

            String basename = Path.GetFileNameWithoutExtension(filename);

            if (basename.EndsWith("#blurb"))
            {
                m_ContentType = RadioContentInfo.ContentType.Blurb;
                m_DisplayName = m_DisplayName.Substring(0, m_DisplayName.Length - "#blurb".Length);
            }
            else if (basename.EndsWith("#talk"))
            {
                m_ContentType = RadioContentInfo.ContentType.Talk;
                m_DisplayName = m_DisplayName.Substring(0, m_DisplayName.Length - "#talk".Length);
            }
            else if (basename.EndsWith("#commercial"))
            {
                m_ContentType = RadioContentInfo.ContentType.Commercial;
                m_DisplayName = m_DisplayName.Substring(0, m_DisplayName.Length - "#commercial".Length);
            }
            else if (basename.EndsWith("#broadcast"))
            {
                m_ContentType = RadioContentInfo.ContentType.Broadcast;
                m_DisplayName = m_DisplayName.Substring(0, m_DisplayName.Length - "#broadcast".Length);
            }
            else
            {
                m_ContentType = RadioContentInfo.ContentType.Music;
            }
        }
Esempio n. 2
0
        private void LoadVanillaSongs(RadioContentInfo.ContentType type)
        {
            String path = Path.Combine(Path.Combine(DataLocation.gameContentPath, "Radio"), type.ToString());

            // The content determination algorithm will always return "Music". Set it manually.
            foreach (var content in LoadSongsFromCollection("Vanilla Legacy " + type.ToString(), type.ToString() + ": ", path)) //!! Breaks adding custom songs to vanilla content if changed!
            {
                content.m_isVanilla   = true;
                content.m_ContentType = type;
            }
        }
        /// <summary>
        /// Allows restriction of content to specific songs
        /// </summary>
        /// <returns>The collect radio content info.</returns>
        /// <param name="type">Type.</param>
        /// <param name="channel">Channel.</param>
        public FastList<ushort> CustomCollectRadioContentInfo(RadioContentInfo.ContentType type, RadioChannelInfo channel)
        {
            var mgr = Singleton<AudioManager>.instance;
            //Debug.Log("[CSLMusic][Internal] Rebuilding the radio content of channel " + channel.GetLocalizedTitle());

            // CO makes some things public and other things private. This is completely insane.
            var m_tempRadioContentBuffer = ReflectionHelper.GetPrivateField<FastList<ushort>>(mgr, "m_tempRadioContentBuffer"); // This variable is being worked on
            var m_radioContentTable = ReflectionHelper.GetPrivateField<FastList<ushort>[]>(mgr, "m_radioContentTable");

            m_tempRadioContentBuffer.Clear(); 

            if (m_radioContentTable == null)
            {
                // Let's all sing the "Expensive Song!" ♬Expensive, Expensive♬ ♩OMG it's so expensive♩ (Rest of lyrics didn't load, yet)
				ReflectionHelper.InvokePrivateVoidMethod(mgr, "RefreshRadioContentTable");
                m_radioContentTable = ReflectionHelper.GetPrivateField<FastList<ushort>[]>(mgr, "m_radioContentTable");
            }

            // Get the allowed radio content
            HashSet<RadioContentInfo> disallowed_content = null;
            if(channel != null)
            {
                RadioContentWatcher.DisallowedContent.TryGetValue(channel, out disallowed_content);
            }

            //Debug.Log("[update]" + channel.GetLocalizedTitle() + " | " + allowed_content);
            /*if(allowed_content == null || allowed_content.Count == 0)
            {
                Debug.Log(channel.GetLocalizedTitle() + ": All content enabled!");
            }*/

            int prefabDataIndex = channel.m_prefabDataIndex;
            if (prefabDataIndex != -1)
            {
                int num = (int)(prefabDataIndex * 5 + type);
                if (num < m_radioContentTable.Length)
                {
                    FastList<ushort> fastList = m_radioContentTable[num];
                    if (fastList != null)
                    {
                        for (int i = 0; i < fastList.m_size; i++)
                        {
                            ushort num2 = fastList.m_buffer[i];
                            RadioContentInfo prefab = PrefabCollection<RadioContentInfo>.GetPrefab((uint)num2);

                            if (prefab != null && Singleton<UnlockManager>.instance.Unlocked(prefab.m_UnlockMilestone))
                            {
                                // Filter only content info that should be kept
                                if( disallowed_content == null || disallowed_content.Count ==  0 || !disallowed_content.Contains(prefab))
                                {
									prefab.m_cooldown = 1000000;
									m_tempRadioContentBuffer.Add(num2);
                                }
                            }
                        }
                    }
                }
            }

            for (int j = 0; j < mgr.m_radioContents.m_size; j++)
            {
                RadioContentData.Flags flags = mgr.m_radioContents.m_buffer[j].m_flags;
                if ((flags & RadioContentData.Flags.Created) != RadioContentData.Flags.None)
                {
                    RadioContentInfo info = mgr.m_radioContents.m_buffer[j].Info;
                    if (info != null)
                    {
                        info.m_cooldown = Mathf.Min(info.m_cooldown, (int)mgr.m_radioContents.m_buffer[j].m_cooldown);
                    }
                }
            }

            return m_tempRadioContentBuffer;

        }