Esempio n. 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (AllList.SelectedItem == null)
            {
                return;
            }
            string name = (string)AllList.SelectedItem;

            var fwav = new FWAV();

            fwav.Name           = name;
            fwav.ChunkParent    = SourceIff;
            fwav.ChunkProcessed = true;

            Content.Content.Get().Changes.BlockingResMod(new ResAction(() =>
            {
                ushort resultID = 0;
                for (ushort i = 1; i < ushort.MaxValue; i++)
                {
                    if (!FWAVTable.Any(x => x.ChunkID == i))
                    {
                        resultID = i;
                        break;
                    }
                }
                fwav.ChunkID    = resultID;
                fwav.ChunkLabel = "";

                SourceIff.AddChunk(fwav);
                fwav.AddedByPatch = true;
                fwav.RuntimeInfo  = ChunkRuntimeState.Modified;
            }, fwav));
            RefreshAnimTable();
        }
Esempio n. 2
0
        public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
        {
            if (!VM.UseWorld)
            {
                return(VMPrimitiveExitCode.GOTO_TRUE);
            }

            var  operand = (VMPlaySoundOperand)args;
            FWAV fwav    = context.ScopeResource.Get <FWAV>(operand.EventID);

            if (fwav == null)
            {
                fwav = context.VM.Context.Globals.Resource.Get <FWAV>(operand.EventID);
            }

            var owner = (operand.StackObjAsSource) ? context.StackObject : context.Caller;

            if (fwav != null && owner.SoundThreads.FirstOrDefault(x => x.Name == fwav.Name) == null)
            {
                var thread = HITVM.Get().PlaySoundEvent(fwav.Name);
                if (thread != null)
                {
                    if (owner == null)
                    {
                        return(VMPrimitiveExitCode.GOTO_TRUE);
                    }
                    if (!thread.AlreadyOwns(owner.ObjectID))
                    {
                        thread.AddOwner(owner.ObjectID);
                    }

                    if (owner is VMAvatar && thread is HITThread)
                    {
                        ((VMAvatar)owner).SubmitHITVars((HITThread)thread);
                    }

                    var entry = new VMSoundEntry()
                    {
                        Sound = thread,
                        Pan   = !operand.NoPan,
                        Zoom  = !operand.NoZoom,
                        Loop  = operand.Loop,
                        Name  = fwav.Name
                    };
                    owner.SoundThreads.Add(entry);
                    if (owner.Thread != null)
                    {
                        owner.TickSounds();
                    }
                }
            }

            return(VMPrimitiveExitCode.GOTO_TRUE);
        }
Esempio n. 3
0
        public override VMPrimitiveExitCode Execute(VMStackFrame context)
        {
            var  operand = context.GetCurrentOperand <VMPlaySoundOperand>();
            FWAV fwav    = context.CodeOwner.Get <FWAV>(operand.EventID);

            if (fwav == null)
            {
                fwav = context.VM.Context.Globals.Resource.Get <FWAV>(operand.EventID);
            }

            if (fwav != null)
            {
                var thread = HITVM.Get().PlaySoundEvent(fwav.Name);
                if (thread != null)
                {
                    var owner = (operand.StackObjAsSource)?context.StackObject:context.Caller;

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

                    var entry = new VMSoundEntry()
                    {
                        Thread = thread,
                        Pan    = !operand.NoPan,
                        Zoom   = !operand.NoZoom,
                        Loop   = operand.Loop,
                        Name   = fwav.Name
                    };
                    owner.SoundThreads.Add(entry);
                    owner.TickSounds();
                }
            }

            return(VMPrimitiveExitCode.GOTO_TRUE);
        }
Esempio n. 4
0
        public override VMPrimitiveExitCode Execute(VMStackFrame context, VMPrimitiveOperand args)
        {
            if (!VM.UseWorld)
            {
                return(VMPrimitiveExitCode.GOTO_TRUE);
            }

            var  operand = (VMPlaySoundOperand)args;
            FWAV fwav    = context.ScopeResource.Get <FWAV>(operand.EventID);

            if (fwav == null)
            {
                fwav = context.VM.Context.Globals.Resource.Get <FWAV>(operand.EventID);
            }

            var owner = (operand.StackObjAsSource) ? context.StackObject : context.Caller;

            if (owner == null)
            {
                return(VMPrimitiveExitCode.GOTO_TRUE);
            }
            var lastThread = owner.SoundThreads.FirstOrDefault(x => x?.Name == fwav?.Name);

            if ((lastThread?.Sound as HITThread)?.Interruptable == true)
            {
                lastThread = null;
            }
            if (fwav != null && lastThread == null)
            {
                var thread = HITVM.Get.PlaySoundEvent(fwav.Name);
                if (thread != null)
                {
                    if (owner == null)
                    {
                        return(VMPrimitiveExitCode.GOTO_TRUE);
                    }
                    if (!thread.AlreadyOwns(owner.ObjectID))
                    {
                        thread.AddOwner(owner.ObjectID);
                    }

                    var entry = new VMSoundEntry()
                    {
                        Sound = thread,
                        Pan   = !operand.NoPan,
                        Zoom  = !operand.NoZoom,
                        Loop  = operand.Loop || fwav.Name == "piano_play",
                        Name  = fwav.Name
                    };

                    if (thread is HITThread)
                    {
                        if (!((HITThread)thread).LoopDefined || fwav.Name == "piano_play")
                        {
                            ((HITThread)thread).Loop       = entry.Loop;
                            ((HITThread)thread).HasSetLoop = fwav.Name == "piano_play";
                        }
                        owner.SubmitHITVars((HITThread)thread);
                    }

                    owner.SoundThreads.Add(entry);
                    context.VM.SoundEntities.Add(owner);
                    if (owner.Thread != null)
                    {
                        owner.TickSounds();
                    }
                }
            }

            return(VMPrimitiveExitCode.GOTO_TRUE);
        }