コード例 #1
0
        /// <summary>
        /// Kill an actor's vocals, given a constant ID.
        /// </summary>
        public static HITResult SeqGroupKill(HITThread thread)
        {
            var src = thread.ReadByte();

            if (src == (byte)HITPerson.Instance)
            {
                thread.KillVocals();
            }
            else
            {
                //TODO: Implement system for keeping track of which object created a thread
                //      and kill that thread's sounds (src == ObjectID).
            }

            return(HITResult.CONTINUE);
        }
コード例 #2
0
        /// <summary>
        /// Kill an actor's vocals, given a constant ID.
        /// </summary>
        public static HITResult SeqGroupKill(HITThread thread)
        {
            var src = thread.ReadByte();

            if (src == (byte)HITPerson.Instance)
                thread.KillVocals();
            else
            {
                //TODO: Implement system for keeping track of which object created a thread
                //      and kill that thread's sounds (src == ObjectID).
            }

            return HITResult.CONTINUE;
        }
コード例 #3
0
ファイル: HITVM.cs プロジェクト: simscolony/FreeSims
        public HITSound PlaySoundEvent(string evt)
        {
            evt = evt.ToLower();
            HITThread InterruptBlocker = null;  //the thread we have to wait for to finish before we begin.


            if (ActiveEvents.ContainsKey(evt))
            {
                var aevt = ActiveEvents[evt];

                if (aevt.Dead)
                {
                    ActiveEvents.Remove(evt);            //if the last event is dead, remove and make a new one
                }
                else
                {
                    if ((aevt as HITThread)?.InterruptBlocker != null)
                    {
                        //we can stop this thread - steal its waiter
                        (aevt as HITThread).Dead = true;
                        InterruptBlocker         = (aevt as HITThread).InterruptBlocker;
                    }
                    else if ((aevt as HITThread)?.Interruptable == true)
                    {
                        InterruptBlocker = (aevt as HITThread);
                    }
                    else
                    {
                        return(aevt); //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, this);
                    thread.VolGroup = HITVolumeGroup.FX;
                    Threads.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return(thread);
                }
                else if (evtent.EventType == HITEvents.kSetMusicMode)
                {
                    var thread = new HITTVOn(evtent.TrackID, this, true);
                    thread.VolGroup = HITVolumeGroup.MUSIC;
                    ActiveEvents.Add(evt, thread);
                    if (NextMusic != null)
                    {
                        NextMusic.Kill();
                    }
                    if (MusicEvent != null)
                    {
                        MusicEvent.Fade();
                    }
                    NextMusic = thread;
                    return(thread);
                }
                else if (SubroutinePointer != 0)
                {
                    var thread = new HITThread(evtent.ResGroup.hit, this);
                    thread.PC = SubroutinePointer;
                    if (TrackID != 0)
                    {
                        thread.SetTrack(TrackID);
                    }

                    Threads.Add(thread);
                    if (!ActiveEvents.ContainsKey(evt))
                    {
                        ActiveEvents.Add(evt, thread);
                    }

                    if (InterruptBlocker != null)
                    {
                        InterruptBlocker.Interrupt(thread);
                        InterruptBlocker.KillVocals();
                    }

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

                    if (InterruptBlocker != null)
                    {
                        InterruptBlocker.Interrupt(thread);
                        InterruptBlocker.KillVocals();
                    }

                    return(thread);
                }
            }

            return(null);
        }