private void HandleTimePropsEvent(TimePropertyListItem tp)
        {
            VMAvatar avatar = this;
            var      evt    = tp.Properties["xevt"];

            if (evt != null)
            {
                var eventValue = short.Parse(evt);
                avatar.CurrentAnimationState.EventQueue.Add(eventValue);
                avatar.CurrentAnimationState.EventsRun++;
            }
            var rhevt = tp.Properties["righthand"];

            if (rhevt != null)
            {
                var eventValue = short.Parse(rhevt);
                avatar.Avatar.RightHandGesture = (SimHandGesture)eventValue;
            }
            var lhevt = tp.Properties["lefthand"];

            if (lhevt != null)
            {
                var eventValue = short.Parse(lhevt);
                avatar.Avatar.LeftHandGesture = (SimHandGesture)eventValue;
            }

            var soundevt = tp.Properties["sound"];
            var owner    = this;

            if (UseWorld && soundevt != null && owner.SoundThreads.FirstOrDefault(x => x.Name == soundevt) == null)
            {
                var thread = TSO.HIT.HITVM.Get().PlaySoundEvent(soundevt);
                if (thread != null)
                {
                    if (thread is HITThread)
                    {
                        SubmitHITVars((HITThread)thread);
                    }

                    if (!thread.AlreadyOwns(owner.ObjectID))
                    {
                        thread.AddOwner(owner.ObjectID);
                    }

                    var entry = new VMSoundEntry()
                    {
                        Sound = thread,

                        Pan  = true,
                        Zoom = true,
                    };
                    owner.SoundThreads.Add(entry);
                    owner.TickSounds();
                }
            }
        }
Beispiel #2
0
        public void TickSounds()
        {
            if (!UseWorld)
            {
                return;
            }
            if (SoundThreads.Count > 0 && Thread != null)
            {
                var scrPos     = WorldUI.LastScreenPos;
                var worldSpace = Thread.Context.World.State.WorldSpace;
                scrPos -= new Vector2(worldSpace.WorldPxWidth / 2,worldSpace.WorldPxHeight / 2);
                for (int i = 0; i < SoundThreads.Count; i++)
                {
                    if (SoundThreads[i].Sound.Dead)
                    {
                        var old = SoundThreads[i];
                        SoundThreads.RemoveAt(i--);
                        if (old.Loop)
                        {
                            var thread = HITVM.Get().PlaySoundEvent(old.Name);
                            if (thread != null)
                            {
                                var owner = this;
                                if (!thread.AlreadyOwns(owner.ObjectID))
                                {
                                    thread.AddOwner(owner.ObjectID);
                                }

                                var entry = new VMSoundEntry()
                                {
                                    Sound = thread,
                                    Pan   = old.Pan,
                                    Zoom  = old.Zoom,
                                    Loop  = old.Loop,
                                    Name  = old.Name
                                };
                                owner.SoundThreads.Add(entry);
                            }
                        }
                        continue;
                    }

                    float pan    = (SoundThreads[i].Pan) ? Math.Max(-1.0f,Math.Min(1.0f,scrPos.X / worldSpace.WorldPxWidth)) : 0;
                    float volume = (SoundThreads[i].Pan) ? 1 - (float)Math.Max(0,Math.Min(1,Math.Sqrt(scrPos.X * scrPos.X + scrPos.Y * scrPos.Y) / worldSpace.WorldPxWidth)) : 1;

                    if (SoundThreads[i].Zoom)
                    {
                        volume /= 4 - WorldUI.LastZoomLevel;
                    }

                    SoundThreads[i].Sound.SetVolume(volume,pan);
                }
            }
        }
Beispiel #3
0
        private void HandleTimePropsEvent(TimePropertyListItem tp)
        {
            VMAvatar avatar = this;
            var evt = tp.Properties["xevt"];
            if (evt != null)
            {
                var eventValue = short.Parse(evt);
                avatar.CurrentAnimationState.EventCode = eventValue;
                avatar.CurrentAnimationState.EventFired = true;
            }
            var rhevt = tp.Properties["righthand"];
            if (rhevt != null)
            {
                var eventValue = short.Parse(rhevt);
                avatar.Avatar.RightHandGesture = (SimHandGesture)eventValue;
            }
            var lhevt = tp.Properties["lefthand"];
            if (lhevt != null)
            {
                var eventValue = short.Parse(lhevt);
                avatar.Avatar.LeftHandGesture = (SimHandGesture)eventValue;
            }

            var soundevt = tp.Properties["sound"];
            if (UseWorld && soundevt != null)
            {
                var thread = FSO.HIT.HITVM.Get().PlaySoundEvent(soundevt);
                if (thread != null)
                {
                    var owner = this;
                    if (thread is HITThread) SubmitHITVars((HITThread)thread);

                    if (!thread.AlreadyOwns(owner.ObjectID)) thread.AddOwner(owner.ObjectID);

                    var entry = new VMSoundEntry()
                    {
                        Sound = thread,
                        Pan = true,
                        Zoom = true,
                    };
                    owner.SoundThreads.Add(entry);
                    owner.TickSounds();
                }
            }
        }
Beispiel #4
0
        public void TickSounds()
        {
            if (!UseWorld) return;
            if (SoundThreads.Count > 0)
            {
                var scrPos = (WorldUI is ObjectComponent) ? ((ObjectComponent)WorldUI).LastScreenPos : ((AvatarComponent)WorldUI).LastScreenPos;
                var worldSpace = Thread.Context.World.State.WorldSpace;
                scrPos -= new Vector2(worldSpace.WorldPxWidth/2, worldSpace.WorldPxHeight/2);
                for (int i = 0; i < SoundThreads.Count; i++)
                {
                    if (SoundThreads[i].Sound.Dead)
                    {
                        var old = SoundThreads[i];
                        SoundThreads.RemoveAt(i--);
                        if (old.Loop)
                        {
                            var thread = HITVM.Get().PlaySoundEvent(old.Name);
                            if (thread != null)
                            {
                                var owner = this;
                                if (!thread.AlreadyOwns(owner.ObjectID)) thread.AddOwner(owner.ObjectID);

                                var entry = new VMSoundEntry()
                                {
                                    Sound = thread,
                                    Pan = old.Pan,
                                    Zoom = old.Zoom,
                                    Loop = old.Loop,
                                    Name = old.Name
                                };
                                owner.SoundThreads.Add(entry);
                            }
                        }
                        continue;
                    }

                    float pan = (SoundThreads[i].Pan) ? Math.Max(-1.0f, Math.Min(1.0f, scrPos.X / worldSpace.WorldPxWidth)) : 0;
                    float volume = (SoundThreads[i].Pan) ? 1 - (float)Math.Max(0, Math.Min(1, Math.Sqrt(scrPos.X * scrPos.X + scrPos.Y * scrPos.Y) / worldSpace.WorldPxWidth)) : 1;

                    if (SoundThreads[i].Zoom) volume /= 4 - ((WorldUI is ObjectComponent) ? ((ObjectComponent)WorldUI).LastZoomLevel : ((AvatarComponent)WorldUI).LastZoomLevel);

                    SoundThreads[i].Sound.SetVolume(volume, pan);

                }
            }
        }