public static void PlayEntityAnimation(this Entity entity, AnimationDictionary dict, string anim, bool loop = false, bool stayInEndFrame = true, float blend = 8f, bool onlyIfNotPlaying = true)
 {
     dict.LoadAndWait();
     if (entity && (!onlyIfNotPlaying || !IsPlayingAnim(entity, dict, anim)))
     {
         NativeFunction.Natives.PLAY_ENTITY_ANIM(entity, anim, dict.Name, blend, loop, stayInEndFrame, 0, 0f, 0);
     }
 }
Beispiel #2
0
        protected override AnimationSet Read(ContentReader input, AnimationSet existingInstance)
        {
            if (existingInstance == null)
            {
                existingInstance = new AnimationSet();
            }
            AnimationDictionary animations = input.ReadObject <AnimationDictionary>();

            existingInstance.Load(animations);
            return(existingInstance);
        }
        async Task PlayEmote()
        {
            animationDictionary = (_config.Animations.ToArray()[new Random().Next(0, _config.Animations.Count - 1)]);
            while (!HasAnimDictLoaded(animationDictionary.DictionaryName))
            {
                RequestAnimDict(animationDictionary.DictionaryName);
                await Delay(10);
            }

            randomAnimation = animationDictionary.Animations.ToArray()[new Random().Next(0, _config.Animations.Count - 1)];
            Debug.WriteLine($"Playing animation : {randomAnimation.AnimationName}");
            TaskPlayAnim(GetPlayerPed(-1), animationDictionary.DictionaryName, randomAnimation.AnimationName, 2.0F, 2.0F, -1, 1, 0,
                         false, false, false);
        }
Beispiel #4
0
        /// <summary>
        /// Constructs the internal sprites needed for our demo.
        /// </summary>
        public DragMode()
        {
            // Create the fragment marbles
            int rows = 3;
            int cols = 3;
            int sx   = (SpriteDemosMain.Size.Width - cols * 50) / 2;
            int sy   = (SpriteDemosMain.Size.Height - rows * 50) / 2;
            SurfaceCollection   m1    = LoadMarble("marble1");
            SurfaceCollection   m2    = LoadMarble("marble2");
            AnimationCollection anim1 = new AnimationCollection();

            anim1.Add(m1);
            AnimationCollection anim2 = new AnimationCollection();

            anim2.Add(m2);
            AnimationDictionary frames = new AnimationDictionary();

            frames.Add("marble1", anim1);
            frames.Add("marble2", anim2);

            DragSprite dragSprite;

            for (int i = 0; i < cols; i++)
            {
                Thread.Sleep(10);
                for (int j = 0; j < rows; j++)
                {
                    dragSprite = new DragSprite(frames["marble1"],
                                                new Point(sx + i * 50, sy + j * 50)
                                                );
                    dragSprite.Animations.Add("marble1", anim1);
                    dragSprite.Animations.Add("marble2", anim2);
                    dragSprite.Animate = true;
                    if (Randomizer.Next(2) == 1)
                    {
                        dragSprite.AnimateForward = false;
                    }
                    Thread.Sleep(10);
                    Sprites.Add(dragSprite);
                }
            }
        }
Beispiel #5
0
        static Player()
        {
            animDict_Run = new AnimationDictionary <FourDirectionAnimation>();
            animDict_Run[FourDirectionAnimation.Front] = new Animation("Sprites/mc/mc_run_front", 100, 8, 14, 38);
            animDict_Run[FourDirectionAnimation.Back]  = new Animation("Sprites/mc/mc_run_back", 100, 8, 14, 38);
            animDict_Run[FourDirectionAnimation.Left]  = new Animation("Sprites/mc/mc_run_left", 100, 8, 20, 36);
            animDict_Run[FourDirectionAnimation.Right] = new Animation("Sprites/mc/mc_run_right", 100, 8, 20, 36);

            animDict_Idle = new AnimationDictionary <FourDirectionAnimation>();
            animDict_Idle[FourDirectionAnimation.Front] = new Animation("Sprites/mc/mc_idle_front", 100, 10, 14, 38);
            animDict_Idle[FourDirectionAnimation.Back]  = new Animation("Sprites/mc/mc_idle_back", 100, 10, 14, 38);
            animDict_Idle[FourDirectionAnimation.Left]  = new Animation("Sprites/mc/mc_idle_left", 100, 10, 12, 32);
            animDict_Idle[FourDirectionAnimation.Right] = new Animation("Sprites/mc/mc_idle_right", 100, 10, 12, 32);

            animDict_RunStop = new AnimationDictionary <FourDirectionAnimation>();
            animDict_RunStop[FourDirectionAnimation.Front] = new Animation("Sprites/mc/mc_stop_run_front", 100, 2, 14, 38);
            animDict_RunStop[FourDirectionAnimation.Back]  = new Animation("Sprites/mc/mc_stop_run_back", 100, 2, 14, 38);
            animDict_RunStop[FourDirectionAnimation.Left]  = new Animation("Sprites/mc/mc_stop_run_left", 100, 2, 12, 31);
            animDict_RunStop[FourDirectionAnimation.Right] = new Animation("Sprites/mc/mc_stop_run_right", 100, 2, 12, 31);
        }
Beispiel #6
0
        /// <summary>
        /// Constructs the internal sprites needed for our demo.
        /// </summary>
        public DragMode()
        {
            // Create the fragment marbles
            int rows = 3;
            int cols = 3;
            int sx = (SpriteDemosMain.Size.Width - cols * 50) / 2;
            int sy = (SpriteDemosMain.Size.Height - rows * 50) / 2;
            SurfaceCollection m1 = LoadMarble("marble1");
            SurfaceCollection m2 = LoadMarble("marble2");
            AnimationCollection anim1 = new AnimationCollection();
            anim1.Add(m1);
            AnimationCollection anim2 = new AnimationCollection();
            anim2.Add(m2);
            AnimationDictionary frames = new AnimationDictionary();
            frames.Add("marble1", anim1);
            frames.Add("marble2", anim2);

            DragSprite dragSprite;
            for (int i = 0; i < cols; i++)
            {
                Thread.Sleep(10);
                for (int j = 0; j < rows; j++)
                {
                    dragSprite = new DragSprite(frames["marble1"],
                        new Point(sx + i * 50, sy + j * 50)
                        );
                    dragSprite.Animations.Add("marble1", anim1);
                    dragSprite.Animations.Add("marble2", anim2);
                    dragSprite.Animate = true;
                    if (Randomizer.Next(2) == 1)
                    {
                        dragSprite.AnimateForward = false;
                    }
                    Thread.Sleep(10);
                    Sprites.Add(dragSprite);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Begins or continues playback of an animation.
        /// </summary>
        public void PlayAnimation(string name)
        {
            if (AnimationDictionary.ContainsKey(name) == false)
            {
                return;
            }

            AnimationData animData = AnimationDictionary[name];

            // If this animation is already running, do not restart it.
            if (animData.Column == FrameColumn && FrameCount == animData.Frames)
            {
                return;
            }

            if (animData.Priority < CurrentAnimation.Priority)
            {
                return;
            }

            // Fire completion callbacks
            stoppingAnimation();

            // Start the new animation.
            _currentAnimation = animData;
            FrameColumn       = animData.Column;
            FrameCount        = animData.Frames;
            FrameTime         = animData.Duration / FrameCount;
            bIsLooping        = animData.IsLooping;
            FrameIndex        = 0;

            time = 0;

            _isFirstCall   = false;
            _callbackFired = false;
            _isStopped     = false;
        }
Beispiel #8
0
        public static void Command_SynchronizedSceneTest()
        {
            if (BenchThreadActivated)
            {
                return;
            }
            GameFiber.StartNew(delegate
            {
                BenchThreadActivated        = true;
                SynchronizedScene syncScene = null;
                List <uint> benchHash       = new List <uint>()
                {
                    0x6ba514ac, //prop_bench_01a
                    0x7977b051, //prop_bench_01b
                    0xb78a2c75, //prop_bench_01c
                    0xda867f80, //prop_bench_02
                    0xc0a6cbcd, //prop_bench_03
                    0xd2786f70, //prop_bench_04
                    0x9ec80810, //prop_bench_05
                    0xb17ead7d, //prop_bench_06
                    0xfbbe41fb, //prop_bench_07
                    0xe7ed1a59, //prop_bench_08
                    0xfa11bea2, //prop_bench_09
                    0x1a117fd1, //prop_bench_10
                    0x4cece57b, //prop_bench_11
                    0xfbca504f, //prop_fib_3b_bench
                    0x723e2ae0, //prop_ld_bench01
                    0x0ff3a92b, //prop_wait_bench_01
                    0x5515a05a, //v_res_fh_benchlong
                    0x883cb2e8, //v_res_fh_benchshort
                    0xbac3f7a8, //v_ind_rc_bench
                    0x90aa8a87, //hei_heist_stn_benchshort
                };
                Rage.Object bench           = null;
                int benchStatus             = 0;
                Vector3 benchInitialPos     = Vector3.Zero;
                Vector3 sitPos              = Vector3.Zero;
                Rage.Task closeTask         = null;
                string sitStr               = Game.GetLocalizedString("MPTV_WALK"); //Press ~INPUT_CONTEXT~ to sit down.
                string standUpStr           = Game.GetLocalizedString("MPOFSEAT_PCEXIT");
                string[] benchIdles         = { "idle_a", "idle_b", "idle_c" };
                AnimationDictionary seating = Game.LocalPlayer.Character.IsMale ? "anim@amb@office@seating@male@var_a@base@" : "anim@amb@office@seating@female@var_d@base@";
                seating.LoadAndWait();
                while (true)
                {
                    GameFiber.Yield();
                    if (Game.LocalPlayer.Character.IsInAnyVehicle(false) || Game.LocalPlayer.Character.IsDead || Game.IsPaused || Game.Console.IsOpen || Game.IsScreenFadingOut)
                    {
                        continue;
                    }
                    switch (benchStatus)
                    {
                    case 0:
                        Entity[] objs = World.GetEntities(Game.LocalPlayer.Character.Position, 2f, GetEntitiesFlags.ConsiderAllObjects).ToArray();
                        bench         = (Rage.Object)objs.Where(x => x && benchHash.Contains(x.Model.Hash)).OrderBy(x => Vector3.DistanceSquared(x.Position, Game.LocalPlayer.Character)).FirstOrDefault();
                        if (!bench)
                        {
                            break;
                        }
                        Game.DisplayHelp(sitStr, 100);
                        if (Game.IsControlPressed(2, GameControl.Context))
                        {
                            benchStatus = 1;
                        }
                        break;

                    case 1:
                        sitPos          = bench.Position + bench.RightVector * 0.85f;
                        benchInitialPos = sitPos + bench.ForwardVector * -1;
                        closeTask       = Game.LocalPlayer.Character.Tasks.FollowNavigationMeshToPosition(benchInitialPos, bench.Heading - 180, 1f, 10000);
                        benchStatus     = 2;
                        break;

                    case 2:
                        if (closeTask.Status == TaskStatus.InProgress)
                        {
                            break;
                        }
                        syncScene = new SynchronizedScene(sitPos, bench.Rotation);
                        synchronizedScenes.Add(syncScene);
                        syncScene.TaskToPed(Game.LocalPlayer.Character, seating, "enter", 13);
                        benchStatus = 3;
                        break;

                    case 3:
                        if (syncScene.Phase != 1f)
                        {
                            break;
                        }
                        syncScene = new SynchronizedScene(sitPos, bench.Rotation);
                        synchronizedScenes.Add(syncScene);
                        syncScene.TaskToPed(Game.LocalPlayer.Character, seating, "base", 13, playbackRate: 1148846080);
                        benchStatus = 4;
                        break;

                    case 4:
                        Game.DisplayHelp(standUpStr, 100);
                        if (Game.IsControlPressed(2, GameControl.ScriptRRight))
                        {
                            benchStatus = 5;
                        }
                        if (syncScene.Phase != 1f)
                        {
                            break;
                        }
                        syncScene = new SynchronizedScene(sitPos, bench.Rotation);
                        synchronizedScenes.Add(syncScene);
                        syncScene.TaskToPed(Game.LocalPlayer.Character, seating, benchIdles.GetRandomElement(), 13, playbackRate: 1148846080);
                        benchStatus = 3;
                        break;

                    case 5:
                        syncScene = new SynchronizedScene(sitPos, bench.Rotation);
                        synchronizedScenes.Add(syncScene);
                        syncScene.TaskToPed(Game.LocalPlayer.Character, seating, "exit", 13, playbackRate: 1000f);
                        benchStatus = 6;
                        break;

                    case 6:
                        if (syncScene.Phase != 1f)
                        {
                            break;
                        }
                        Game.LocalPlayer.Character.Tasks.Clear();
                        synchronizedScenes.ForEach(x =>
                        {
                            if (x.IsValid())
                            {
                                x.Delete();
                            }
                        });
                        synchronizedScenes = new List <SynchronizedScene>();
                        benchStatus        = 0;
                        break;
                    }
                }
            });
        }
Beispiel #9
0
        public void CreateScenario(int scenario)
        {
            GameFiber.StartNew(delegate
            {
                Logger.LogTrivial(this.GetType().Name, "Scenario: " + scenario);

                if (scenario == 1)     // SHOOT
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Shoot");
                    ped.Inventory.GiveNewWeapon(weaponAssets.GetRandomElement(true), 9999, true);

                    Vector3 posToShoot = ped.Position + (ped.ForwardVector * MathHelper.GetRandomSingle(1.5f, 8.0f)) + (ped.UpVector * MathHelper.GetRandomSingle(8.0f, 20.0f)) + (ped.RightVector * MathHelper.GetRandomSingle(-15.0f, 15.0f));
                    NativeFunction.CallByName <uint>("TASK_SHOOT_AT_COORD", ped, posToShoot.X, posToShoot.Y, posToShoot.Z, -1, (uint)Rage.FiringPattern.BurstFire);
                }
                else if (scenario == 2)     // PROTEST
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Protest");
                    ped.Tasks.PlayAnimation("special_ped@griff@monologue_1@monologue_1e", "iamnotaracist_4", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object("prop_cs_protest_sign_01", Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        //GameFiber.StartNew(delegate
                        //{
                        //    while (!hasEnded && ped.Exists() && ped.IsAlive && !Functions.IsPedArrested(ped))
                        //    {
                        //        if (Vector3.Distance(Game.LocalPlayer.Character.Position, ped.Position) < 17.5f)
                        //        {
                        //            if (new Random().Next(0, 151) < 20)
                        //            {
                        //                string[] protestSpeeches = { "GENERIC_CURSE_MED", "GENERIC_CURSE_HIGH", "GENERIC_FUCK_YOU" };
                        //                ped.PlayAmbientSpeech(null, protestSpeeches[new Random().Next(protestSpeeches.Length)], 0, SpeechModifier.Force);
                        //            }
                        //            GameFiber.Sleep(2500);
                        //        }
                        //        GameFiber.Yield();
                        //    }
                        //});
                        GameFiber.Sleep(125);
                        while (ped.IsPlayingAnimation("special_ped@griff@monologue_1@monologue_1e", "iamnotaracist_4") && ped.IsPersistent)
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 3)        // DRUNK NUDE GUY
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Drunk nude guy");
                    ped.SetMovementAnimationSet("move_m@drunk@verydrunk");
                    ped.Tasks.Wander();
                }
                else if (scenario == 4)     // GUITARRIST
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Guitarrist");

                    ped.Tasks.PlayAnimation("amb@world_human_musician@guitar@male@base", "base", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(guitarModels.GetRandomElement(true), Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("amb@world_human_musician@guitar@male@base", "base") && ped.IsPersistent)
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 5)         // TOPLESS GIRL
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Topless girl");
                    ped.Tasks.PlayAnimation("amb@world_human_prostitute@hooker@base", "base", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                }
                else if (scenario == 6)     // SUNBATHE
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Sunbathe");

                    AnimationDictionary maleAnimDict   = sunbatheMale.GetRandomElement(true);
                    AnimationDictionary femaleAnimDict = sunbatheFemale.GetRandomElement(true);

                    if (ped.IsMale)
                    {
                        ped.Tasks.PlayAnimation(maleAnimDict, "base", 2.0f, AnimationFlags.Loop);
                    }
                    else if (ped.IsFemale)
                    {
                        ped.Tasks.PlayAnimation(femaleAnimDict, "base", 2.0f, AnimationFlags.Loop);
                    }

                    ped.BlockPermanentEvents = true;

                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        if (ped.IsMale)
                        {
                            while (ped.IsPlayingAnimation(maleAnimDict, "base") && ped.IsPersistent)
                            {
                                GameFiber.Yield();
                            }
                            if (!hasEnded && ped.Exists())
                            {
                                ped.BlockPermanentEvents = false;
                            }
                        }
                        else if (ped.IsFemale)
                        {
                            while (ped.IsPlayingAnimation(femaleAnimDict, "base") && ped.IsPersistent)
                            {
                                GameFiber.Yield();
                            }
                            if (!hasEnded && ped.Exists())
                            {
                                ped.BlockPermanentEvents = false;
                            }
                        }
                    });
                }
                else if (scenario == 7)        // FREAK OUT GUY
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Freak out guy");

                    string animName = monkeyFreakOutAnimNames.GetRandomElement();
                    ped.Tasks.PlayAnimation("missfbi5ig_30monkeys", animName, 5.0f, AnimationFlags.Loop);
                    ped.BlockPermanentEvents = true;
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("missfbi5ig_30monkeys", animName) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
                else if (scenario == 8)      // EPSILON
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Epsilon");

                    ped.Tasks.PlayAnimation("rcmepsilonism3", "ep_3_rcm_marnie_meditating", 2.0f, AnimationFlags.Loop);
                    ped.BlockPermanentEvents = true;
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (!hasEnded)
                        {
                            if (ped.Exists())
                            {
                                if (Vector3.Distance(Game.LocalPlayer.Character.Position, ped.Position) < 6.0f)
                                {
                                    if (ped.IsMale)
                                    {
                                        ped.PlayAmbientSpeech(epsilonVoicesMale.GetRandomElement(), "KIFFLOM_GREET", 0, SpeechModifier.Force);
                                    }
                                    else
                                    {
                                        ped.PlayAmbientSpeech(epsilonVoicesFemale.GetRandomElement(), "KIFFLOM_GREET", 0, SpeechModifier.Force);
                                    }
                                    break;
                                }
                            }
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
                else if (scenario == 9)     // BONGOS
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Bongos");

                    ped.Tasks.PlayAnimation("amb@world_human_musician@bongos@male@idle_a", "idle_a", 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(bongosModel, Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.LeftPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation("amb@world_human_musician@bongos@male@idle_a", "idle_a") && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 10)     // BEGGER
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Begger");
                    string[] idles  = { "idle_a", "idle_b", "idle_c" };
                    string idleUsed = idles.GetRandomElement();
                    ped.Tasks.PlayAnimation("amb@world_human_bum_freeway@male@idle_a", idleUsed, 5.0f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
                    ped.Tasks.Wander();
                    pedObj = new Rage.Object(beggersSignModels.GetRandomElement(), Vector3.Zero);
                    pedObj.AttachToEntity(ped, ped.GetBoneIndex(PedBoneId.RightPhHand), Vector3.Zero, Rotator.Zero);
                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(125);
                        while (ped.IsPlayingAnimation("amb@world_human_bum_freeway@male@idle_a", idleUsed) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Detach();
                        }
                        if (!hasEnded && pedObj.Exists())
                        {
                            pedObj.Dismiss();
                        }
                    });
                }
                else if (scenario == 11)    // NUDE GIRL CHEERING
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Topless girl cheering");
                    char[] letters = { 'a', 'b', 'c', 'd' };
                    ped.Tasks.PlayAnimation("amb@world_human_cheering@female_" + letters.GetRandomElement(), "base", 5.0f, AnimationFlags.Loop);
                }
                else if (scenario == 12)     // Pushups
                {
                    Logger.LogDebug(this.GetType().Name, "Scenario: Pushups");

                    Tuple <AnimationDictionary, string>[] anims  = { new Tuple <AnimationDictionary, string>("amb@world_human_push_ups@male@idle_a", "idle_d"), new Tuple <AnimationDictionary, string>("amb@world_human_push_ups@male@base", "base") };
                    Tuple <AnimationDictionary, string> animUsed = anims.GetRandomElement();

                    ped.Tasks.PlayAnimation(animUsed.Item1, animUsed.Item2, 2.0f, AnimationFlags.Loop);

                    ped.BlockPermanentEvents = true;

                    GameFiber.StartNew(delegate
                    {
                        GameFiber.Sleep(500);
                        while (ped.IsPlayingAnimation(animUsed.Item1, animUsed.Item2) && ped.IsPersistent && ped.Exists())
                        {
                            GameFiber.Yield();
                        }
                        if (!hasEnded && ped.Exists())
                        {
                            ped.BlockPermanentEvents = false;
                        }
                    });
                }
            });
        }
Beispiel #10
0
 internal void Load(AnimationDictionary animations)
 {
     animations_ = animations;
 }
 public static void SetAnimTime(this Entity entity, AnimationDictionary dict, string anim, float time)
 {
     NativeFunction.Natives.SET_ENTITY_ANIM_CURRENT_TIME(entity, dict.Name, anim, time);
 }
Beispiel #12
0
 public static float GetEntityAnimCurrentTime(Entity entity, AnimationDictionary animDict, string animName)
 {
     animDict.LoadAndWait();
     return(NativeFunction.CallByName <float>("GET_ENTITY_ANIM_CURRENT_TIME", entity, animDict.Name, animName));
 }
Beispiel #13
0
 public static void PlayEntityAnim(Entity entity, AnimationDictionary animDict, string animName, bool loop, AnimationFlags flags = AnimationFlags.None)
 {
     animDict.LoadAndWait();
     NativeFunction.CallByName <uint>("PLAY_ENTITY_ANIM", entity, animName, animDict.Name, 1000f, loop, 1, 0, 0f, (uint)flags);
 }
Beispiel #14
0
 public static void SetEntityAnimSpeed(Entity entity, AnimationDictionary animDict, string animName, float speedMultiplier)
 {
     animDict.LoadAndWait();
     NativeFunction.CallByName <uint>("SET_ENTITY_ANIM_SPEED", entity, animDict.Name, animName, speedMultiplier);
 }
 public static bool HasFinishedAnim(this Entity entity, AnimationDictionary dict, string anim)
 {
     return(NativeFunction.Natives.HAS_ENTITY_ANIM_FINISHED <bool>(entity, dict.Name, anim, 3));
 }
Beispiel #16
0
 static WalkingEnemy()
 {
     animDict_Walk = new AnimationDictionary <WalkAnimation>();
     animDict_Walk[WalkAnimation.Left]  = new Animation("Sprites/enemy/redTitan/redtitan_walk_left", 100, 10, 30, 30);
     animDict_Walk[WalkAnimation.Right] = new Animation("Sprites/enemy/redTitan/redtitan_walk_right", 100, 10, 30, 30);
 }
Beispiel #17
0
        /// <summary>
        /// Causes this ped to start performing the specified <see cref="SynchronizedScene"/>
        /// </summary>
        /// <param name="ped">The target ped</param>
        /// <param name="duration">in second</param>
        /// <param name="flag">can be 0 or 16</param>
        /// <returns></returns>
        public static Rage.Task StartSynchronizedScene(this Ped ped, SynchronizedScene synchronizedScene, AnimationDictionary animDictionary, string animationName, float speed, float speedMultiplier, int duration, int flag, float playbackRate)
        {
            animDictionary.LoadAndWait();
            uint handle = synchronizedScene.Handle;

            NativeWrappers.TaskSynchronizedScene(ped, handle, animDictionary, animationName, speed, speedMultiplier, duration, flag, playbackRate, 0);
            return(Rage.Task.GetTask(ped, "TASK_SYNCHRONIZED_SCENE"));
        }
 public static float GetAnimDuration(AnimationDictionary dict, string anim)
 {
     return(NativeFunction.Natives.GET_ANIM_DURATION <float>(dict.Name, anim));
 }
 public static float GetAnimTime(this Entity entity, AnimationDictionary dict, string anim)
 {
     return(NativeFunction.Natives.GET_ENTITY_ANIM_CURRENT_TIME <float>(entity, dict.Name, anim));
 }
Beispiel #20
0
 /// <summary>
 /// Returns a value indicating if this Rage.Entity instance is playing the chosen animation
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="animationDictionary">Animation dictionary in which the animation is</param>
 /// <param name="animationName">Animation name</param>
 /// <returns>a value indicating if this Rage.Entity instance is playing the chosen animation</returns>
 public static bool IsPlayingAnimation(this Entity entity, AnimationDictionary animationDictionary, string animationName)
 {
     return(NativeFunction.CallByName <bool>("IS_ENTITY_PLAYING_ANIM", entity, (string)animationDictionary, animationName, 3));
 }
 public static void StopEntityAnim(this Entity entity, AnimationDictionary dict, string anim)
 {
     NativeFunction.Natives.STOP_ENTITY_ANIM(entity, anim, dict.Name, 0f);
 }
Beispiel #22
0
 public static void StopEntityAnim(Entity entity, AnimationDictionary animDict, string animName)
 {
     animDict.LoadAndWait();
     NativeFunction.CallByName <uint>("STOP_ENTITY_ANIM", entity, animName, animDict.Name, -1000f);
 }
 public static bool IsPlayingAnim(this Entity entity, AnimationDictionary dict, string anim)
 {
     return(NativeFunction.Natives.IS_ENTITY_PLAYING_ANIM <bool>(entity, dict.Name, anim, 3));
 }
Beispiel #24
0
 public static bool IsEntityPlayingAnim(Entity entity, AnimationDictionary animDict, string animName)
 {
     animDict.LoadAndWait();
     return(NativeFunction.CallByName <bool>("IS_ENTITY_PLAYING_ANIM", entity, animDict.Name, animName, 3));
 }
Beispiel #25
0
 public AnimationSet(AnimationDictionary animations)
 {
     animations_ = animations;
 }
Beispiel #26
0
 public static void SetEntityAnimCurrentTime(Entity entity, AnimationDictionary animDict, string animName, float value)
 {
     animDict.LoadAndWait();
     NativeFunction.CallByName <uint>("SET_ENTITY_ANIM_CURRENT_TIME", entity, animDict.Name, animName, value);
 }
 public static void SetAnimSpeed(this Entity entity, AnimationDictionary dict, string anim, float speed)
 {
     NativeFunction.Natives.SET_ENTITY_ANIM_SPEED(entity, dict.Name, anim, speed);
 }