SetTrack() 공개 메소드

public SetTrack ( uint value ) : void
value uint
리턴 void
예제 #1
0
파일: HITVM.cs 프로젝트: Daribon/FreeSO
        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;
        }
예제 #2
0
        public HITSound PlaySoundEvent(string evt)
        {
            evt = evt.ToLowerInvariant();
            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();
            var evts    = content.Audio.Events;

            if (evts.ContainsKey(evt))
            {
                var evtent = evts[evt];

                //objects call the wrong event for piano playing
                //there is literally no file or evidence that this is not hard code mapped to PlayPiano in TSO, so it's hardcoded here.
                //the track and HSM associated with the piano_play event, however, are correct. it's just the subroutine that is renamed.
                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 (content.TS1)
                {
                    TrackID = evtent.TrackID;
                    var track = content.Audio.GetTrack(TrackID, 0, evtent.ResGroup);
                    if (track != null && track.SubroutineID != 0)
                    {
                        SubroutinePointer = track.SubroutineID;
                    }
                }
                else
                {
                    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 != null && entPoints.ContainsKey(evtent.TrackID))
                        {
                            SubroutinePointer = entPoints[evtent.TrackID];
                        }
                    }
                }

                if (evtent.EventType == HITEvents.kTurnOnTV)
                {
                    var thread = new HITTVOn(evtent.TrackID, this);
                    thread.VolGroup = HITVolumeGroup.FX;
                    Sounds.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, this);
                    thread.PC          = SubroutinePointer;
                    thread.LoopPointer = (int)thread.PC;
                    if (TrackID != 0)
                    {
                        thread.SetTrack(TrackID, evtent.TrackID);
                    }
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return(thread);
                }
                else if (TrackID != 0 && content.Audio.GetTrack(TrackID, 0, evtent.ResGroup) != null)
                {
                    var thread = new HITThread(TrackID, this, evtent.ResGroup);
                    Sounds.Add(thread);
                    ActiveEvents.Add(evt, thread);
                    return(thread);
                }
            }

            return(null);
        }
예제 #3
0
        public HITSound PlaySoundEvent(string evt)
        {
            evt = evt.ToLowerInvariant();
            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 (evtent.EventType == HITEvents.kSetMusicMode)
                {
                    var thread = new HITTVOn(evtent.TrackID, true);
                    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, 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);
        }