Example #1
0
        public static void Execute(PhysicsObj obj, AnimationHook animHook)
        {
            switch (animHook.HookType)
            {
            case AnimationHookType.AnimationDone:
                obj.Hook_AnimDone();
                break;

                /*case AnimationHookType.Ethereal:
                 *  if (animHook is EtherealHook hook)
                 *      obj.set_ethereal(Convert.ToBoolean(hook.Ethereal), false);
                 *  break;*/
            }
        }
Example #2
0
        public TreeNode BuildTree()
        {
            var treeView = new TreeNode($"{_playScript.Id:X8}");

            var scripts = new TreeNode("Scripts:");

            for (var i = 0; i < _playScript.ScriptData.Count; i++)
            {
                var scriptData = new PhysicsScriptData(_playScript.ScriptData[i]);

                var scriptNode = new TreeNode($"HookType: {scriptData._scriptData.Hook.HookType}, StartTime: {scriptData._scriptData.StartTime}");

                var animationHook = AnimationHook.Create(scriptData._scriptData.Hook);

                scriptNode.Items.AddRange(animationHook.BuildTree());

                scripts.Items.Add(scriptNode);
            }
            treeView.Items.AddRange(scripts.Items);
            return(treeView);
        }
Example #3
0
        public static void Execute(PhysicsObj obj, AnimationHook animHook)
        {
            switch (animHook.HookType)
            {
            case AnimationHookType.AnimationDone:
                obj.Hook_AnimDone();
                break;

            /*case AnimationHookType.Ethereal:
             *  if (animHook is EtherealHook hook)
             *      obj.set_ethereal(Convert.ToBoolean(hook.Ethereal), false);
             *  break;*/

            case AnimationHookType.CreateParticle:
                if (animHook is CreateParticleHook hook)
                {
                    obj.create_particle_emitter(hook.EmitterInfoId, (int)hook.PartIndex, new AFrame(hook.Offset), (int)hook.EmitterId);
                }
                break;
            }
        }
Example #4
0
 public AnimHook(AnimationHook animHook)
 {
     HookType  = (PhysicsHookType)animHook.HookType;
     Direction = animHook.Direction;
 }
Example #5
0
        public void update_internal(float timeElapsed, AnimSequenceNode currAnim, float frameNum, AFrame frame)
        {
            var framerate = currAnim.Framerate;
            var frametime = framerate * timeElapsed;

            var lastFrame = (int)Math.Floor(frameNum);

            // ref?
            frameNum += frametime;
            var frameTimeElapsed = 0.0f;
            var animDone         = false;

            if (frametime > 0.0f)
            {
                if (currAnim.get_high_frame() < Math.Floor(frameNum))
                {
                    var frameOffset = frameNum - currAnim.get_high_frame() - 1.0f;
                    if (frameOffset < 0.0f)
                    {
                        frameOffset = 0.0f;
                    }

                    if (Math.Abs(framerate) > PhysicsGlobals.EPSILON)
                    {
                        frameTimeElapsed = frameOffset / framerate;
                    }

                    frameNum = currAnim.get_high_frame();
                    animDone = true;
                }
                while (Math.Floor(frameNum) > lastFrame)
                {
                    if (frame != null)
                    {
                        if (currAnim.Anim.PosFrames != null)
                        {
                            frame = AFrame.Combine(frame, currAnim.get_pos_frame(lastFrame));
                        }

                        if (Math.Abs(framerate) > PhysicsGlobals.EPSILON)
                        {
                            apply_physics(frame, 1.0f / framerate, timeElapsed);
                        }
                    }

                    execute_hooks(currAnim.get_part_frame(lastFrame), AnimationHookDir.Forward);
                    lastFrame++;
                }
            }
            else if (frametime < 0.0f)
            {
                if (currAnim.get_low_frame() > Math.Floor(frameNum))
                {
                    var frameOffset = frameNum - currAnim.get_low_frame();
                    if (frameOffset > 0.0f)
                    {
                        frameOffset = 0.0f;
                    }

                    if (Math.Abs(framerate) > PhysicsGlobals.EPSILON)
                    {
                        frameTimeElapsed = frameOffset / framerate;
                    }

                    frameNum = currAnim.get_low_frame();
                    animDone = true;
                }
                while (Math.Floor(frameNum) < lastFrame)
                {
                    if (frame != null)
                    {
                        if (currAnim.Anim.PosFrames != null)
                        {
                            frame = AFrame.Combine(frame, currAnim.get_pos_frame(lastFrame));
                        }

                        if (Math.Abs(framerate) > PhysicsGlobals.EPSILON)
                        {
                            apply_physics(frame, 1.0f / framerate, timeElapsed);
                        }
                    }

                    execute_hooks(currAnim.get_part_frame(lastFrame), AnimationHookDir.Backward);
                    lastFrame--;
                }
            }
            else
            {
                if (frame != null && Math.Abs(timeElapsed) > PhysicsGlobals.EPSILON)
                {
                    apply_physics(frame, timeElapsed, timeElapsed);
                }
            }

            if (!animDone)
            {
                return;
            }

            if (HookObj != null)
            {
                var node = AnimList.First;
                if (!node.Equals(FirstCyclic))
                {
                    var animHook = new AnimationHook();
                    HookObj.add_anim_hook(animHook);
                }
            }
            advance_to_next_animation(timeElapsed, currAnim, frameNum, frame);
            timeElapsed = frameTimeElapsed;

            // loop to next anim
            update_internal(timeElapsed, currAnim, frameNum, frame);
        }
Example #6
0
 public AnimDoneHook(AnimationHook animHook)
     : base(animHook)
 {
 }