A special HITThread replacement to handle the kTurnOnTV event. Used by radio, TV, and (in the original game) the UI music. Also supports streaming MP3 audio.
Inheritance: HITSound
Exemple #1
0
        public HITSound PlaySoundEvent(string evt)
        {
            evt = evt.ToLower();
            if (ActiveEvents.ContainsKey(evt))
            {
                if (ActiveEvents[evt].Dead) ActiveEvents.Remove(evt); //if the last event is dead, remove and make a new one
                else return ActiveEvents[evt]; //an event of this type is already alive - here, take it.
            }

            var content = FSO.Content.Content.Get();
            if (Events.ContainsKey(evt))
            {
                var evtent = Events[evt];

                if (evt.Equals("piano_play", StringComparison.InvariantCultureIgnoreCase))
                {
                    evt = "playpiano";
                    if (ActiveEvents.ContainsKey(evt))
                    {
                        if (ActiveEvents[evt].Dead) ActiveEvents.Remove(evt); //if the last event is dead, remove and make a new one
                        else return ActiveEvents[evt]; //an event of this type is already alive - here, take it.
                    }
                }

                uint TrackID = 0;
                uint SubroutinePointer = 0;
                if (evtent.ResGroup.hsm != null)
                {
                    var c = evtent.ResGroup.hsm.Constants;
                    if (c.ContainsKey(evt)) SubroutinePointer = (uint)c[evt];
                    var trackIdName = "guid_tkd_" + evt;
                    if (c.ContainsKey(trackIdName)) TrackID = (uint)c[trackIdName];
                    else TrackID = evtent.TrackID;
                }
                else
                { //no hsm, fallback to eent and event track ids (tsov2)
                    var entPoints = evtent.ResGroup.hit.EntryPointByTrackID;
                    TrackID = evtent.TrackID;
                    if (entPoints.ContainsKey(evtent.TrackID)) SubroutinePointer = entPoints[evtent.TrackID];
                }

                if (evtent.EventType == HITEvents.kTurnOnTV)
                {
                    var thread = new HITTVOn(evtent.TrackID);
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return thread;
                }
                else if (SubroutinePointer != 0)
                {
                    var thread = new HITThread(evtent.ResGroup.hit, this);
                    thread.PC = SubroutinePointer;
                    if (TrackID != 0) thread.SetTrack(TrackID, evtent.TrackID);

                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return thread;
                }
                else if (TrackID != 0 && content.Audio.TracksById.ContainsKey(TrackID))
                {
                    var thread = new HITThread(TrackID);
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return thread;
                }
            }

            return null;
        }
Exemple #2
0
        public void Tick()
        {
            for (int i = 0; i < Sounds.Count; i++)
            {
                if (!Sounds[i].Tick()) Sounds.RemoveAt(i--);
            }

            if (NextMusic != null)
            {
                if (MusicEvent == null || MusicEvent.Dead)
                {
                    MusicEvent = NextMusic;
                    Sounds.Add(NextMusic);
                    NextMusic = null;
                }
            }

            for (int i = 0; i < FSCPlayers.Count; i++)
            {
                FSCPlayers[i].Tick(1/60f);
            }
        }