Inheritance: MonoBehaviour
Example #1
0
 public override void Chain(Trampoline t, Input input, OnChainResult result)
 {
     Left.Chain(t, input, resLeft =>
     {
         if (resLeft is ISuccess)
         {
             Right.Chain(t, resLeft.Remainder, resRight =>
             {
                 if (resRight is ISuccess)
                 {
                     var sucLeft = resLeft as ISuccess;
                     var sucRight = resRight as ISuccess;
                     result(Result.Success(resRight.Remainder, Combinator(sucLeft.Value, sucRight.Value)));
                 }
                 else
                 {
                     result(resRight);
                 }
             });
         }
         else
         {
             result(resLeft);
         }
     });
 }
Example #2
0
 void TurnOffPowerUp()
 {
     RenderSettings.skybox.SetVector("ScrollSpeed", new Vector4(0, 0, 0, 0));
     if (powerUpType == 1)
     {
         foreach (GameObject a in trampolines)
         {
             Texture temp = a.GetComponentInChildren <Trampoline>().GetComponent <SkinnedMeshRenderer>().material.mainTexture;
             a.GetComponentInChildren <Trampoline>().GetComponent <SkinnedMeshRenderer>().material             = defaultShroomMaterial;
             a.GetComponentInChildren <Trampoline>().GetComponent <SkinnedMeshRenderer>().material.mainTexture = temp;
         }
     }
     else if (powerUpType == 2)//pass through bottoms of mushrooms
     {
         foreach (GameObject a in trampolines)
         {
             Trampoline tramp = a.GetComponentInChildren <Trampoline>();
             tramp.GetComponent <SkinnedMeshRenderer>().enabled = true;
             tramp.bottom.enabled = true;
             tramp.bottomMesh.gameObject.SetActive(true);
             tramp.cloud.SetActive(false);
         }
     }
     else if (powerUpType == 3)//safety net mushroom
     {
         if (safetyNetMushroom != null)
         {
             Destroy(safetyNetMushroom);
         }
     }
 }
Example #3
0
    void Awake()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        Tr = transform;

        Trampoline LocalTrampoline = (Trampoline)Instantiate(TrampolinePrefab);

        LocalTrampoline.Init(Tr, Width - 2);

        LocalTrampoline.Strength = Strength;

        Vector3 CubePos = new Vector3(-Width * 0.5f + 0.5f, 1.0f, 0.0f);

        InitHardBlock(CubePos);

        CubePos.y--;

        for (int X = 0; X < Width; X++)
        {
            InitHardBlock(CubePos);
            CubePos.x++;
        }

        CubePos.x--;

        CubePos.y++;

        InitHardBlock(CubePos);
    }
            public IDisposable Schedule(TimeSpan dueTime, Action action)
            {
                if (action == null)
                {
                    throw new ArgumentNullException("action");
                }

                var dt = Time + Scheduler.Normalize(dueTime);

                var si = new ScheduledItem(action, dt);

                var queue = GetQueue();

                if (queue == null)
                {
                    queue = new SchedulerQueue(4);
                    queue.Enqueue(si);

                    CurrentThreadScheduler.SetQueue(queue);

                    try {
                        Trampoline.Run(queue);
                    } finally {
                        CurrentThreadScheduler.SetQueue(null);
                    }
                }
                else
                {
                    queue.Enqueue(si);
                }

                return(si.Cancellation);
            }
Example #5
0
        /// <summary>
        /// Schedules an action to be executed after dueTime.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">State passed to the action to be executed.</param>
        /// <param name="action">Action to be executed.</param>
        /// <param name="dueTime">Relative time after which to execute the action.</param>
        /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
        public override IDisposable Schedule <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var dt = Time + Scheduler.Normalize(dueTime);

            var si = new ScheduledItem <TimeSpan, TState>(this, state, action, dt);

            var queue = GetQueue();

            if (queue == null)
            {
                queue = new SchedulerQueue <TimeSpan>(4);
                queue.Enqueue(si);

                CurrentThreadScheduler.SetQueue(queue);
                try
                {
                    Trampoline.Run(queue);
                }
                finally
                {
                    CurrentThreadScheduler.SetQueue(null);
                }
            }
            else
            {
                queue.Enqueue(si);
            }

            return(Disposable.Create(si.Cancel));
        }
Example #6
0
    CollisionInfo GetFirstTrampolineColl()
    {
        CollisionInfo firstColl = new CollisionInfo(new Vec2(), null, 2, 0);

        //line segment collision
        for (int i = 0; i < _levelinfo._tramps.Count; i++)
        {
            if (_levelinfo._tramps[i] is Trampoline)
            {
                Trampoline tramp = _levelinfo._tramps[i] as Trampoline;
                //calc vars
                Vec2 normal = (tramp.end - tramp.start).Normal();

                Vec2 differenceVector = tramp.start - position;

                float ballDistance = differenceVector.Dot(normal.Normalized());

                float ToI = GetLineToI(tramp, normal);
                //test result
                if (ToI <= 1 && ToI < firstColl.timeOfImpact)
                {
                    Vec2 PoI = GetLinePoI(ToI);
                    if (IsValidPoI(PoI, tramp))
                    {
                        firstColl = new CollisionInfo(normal, tramp, ToI, ballDistance);
                    }
                }
            }
        }
        if (firstColl.timeOfImpact != 2)
        {
            return(firstColl);
        }
        return(null);
    }
        static public void HandleEquippedItem()
        {
            var handleEquippedItem = (delegate * unmanaged[Cdecl] < Actor *, TESBoundObject *, ExtraDataList *, System.Byte, void >) & HandleEquippedItem;

            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.WeaponCharge.Enchant, handleEquippedItem);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.WeaponCharge.Equip, handleEquippedItem);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.WeaponCharge.Recharge, handleEquippedItem);
Example #8
0
            public IDisposable Schedule(TimeSpan dueTime, Action action)
            {
                if (action == null)
                {
                    throw new ArgumentNullException("action");
                }
                TimeSpan       dueTime2      = Time + Normalize(dueTime);
                ScheduledItem  scheduledItem = new ScheduledItem(action, dueTime2);
                SchedulerQueue queue         = GetQueue();

                if (queue == null)
                {
                    queue = new SchedulerQueue(4);
                    queue.Enqueue(scheduledItem);
                    SetQueue(queue);
                    try
                    {
                        Trampoline.Run(queue);
                    }
                    finally
                    {
                        SetQueue(null);
                    }
                }
                else
                {
                    queue.Enqueue(scheduledItem);
                }
                return(scheduledItem.Cancellation);
            }
        static public void GetActorValuePercentage()
        {
            var getActorValuePercentage = (delegate * unmanaged[Cdecl] < Actor *, System.Int32, System.Single >) & GetActorValuePercentage;

            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.ActorValuePercentage.ActorValueCondition, getActorValuePercentage);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.ActorValuePercentage.ActorValueEnemyHealth, getActorValuePercentage);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.ActorValuePercentage.ActorValuePapyrus, getActorValuePercentage);
Example #10
0
    void AddTrampoline(Vec2 start, Vec2 end, float rotation)
    {
        Trampoline trampoline = new Trampoline(end, start, rotation, "trampoline.png");

        AddChild(trampoline);
        _tramps.Add(trampoline);
    }
Example #11
0
        static public void ApplySpell()
        {
            var applySpell = (delegate * unmanaged[Cdecl] < Actor *, SpellItem *, Actor *, void >) & ApplySpell;

            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Patches.ApplySpellPerkEntryPoints.CastSpells.ApplyBashingSpell, applySpell);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Patches.ApplySpellPerkEntryPoints.CastSpells.ApplyCombatHitSpell, applySpell);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Patches.ApplySpellPerkEntryPoints.CastSpells.ApplyCombatHitSpellArrowProjectile, applySpell);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Patches.ApplySpellPerkEntryPoints.CastSpells.ApplyReanimateSpell, applySpell);
            Trampoline.WriteRelativeCall(ScrambledBugs.Offsets.Patches.ApplySpellPerkEntryPoints.CastSpells.ApplyWeaponSwingSpell, applySpell);
        public void TrampolineRecursion_CreatesThreeStackFrameForTrampolineExecuteAndTrampolineBounceAndTrampolineResult(int recursions)
        {
            var stackTrace         = new StackTrace();
            var startingFrameCount = stackTrace.FrameCount;

            var endingFrameCount   = Trampoline.Execute(() => TrampolineRecursive(recursions)).frameCount;
            var amountOfFramesUsed = endingFrameCount - startingFrameCount;

            amountOfFramesUsed.Should().Be(3);
        }
        private List <string> RecursiveSearch(string rootDirectory)
        {
            var directoriesToScan = new Stack <string>();

            directoriesToScan.Push(rootDirectory);
            var files = new List <string>();

            Trampoline.Start(Iteration, files, directoriesToScan);
            return(files);
        }
        public void TestTrampolineRecursion()
        {
            var factorial = Trampoline.Start(Iteration, 1, 2);

            Assert.AreEqual(2, factorial);

            factorial = Trampoline.Start(Iteration, 1, 3);
            Assert.AreEqual(6, factorial);

            factorial = Trampoline.Start(Iteration, 1, 4);
            Assert.AreNotEqual(23, factorial);
        }
Example #15
0
        public static int Sum(Stack <int> intStack)
        {
            var recursiveTailSum = Trampoline.MakeTrampoline((int acc, Stack <int> ints) =>
            {
                var topInt = ints.Pop();
                var total  = topInt + acc;

                return(ints.Any()
                    ? Trampoline.Recurse <int, Stack <int>, int>(total, ints)
                    : Trampoline.ReturnResult <int, Stack <int>, int>(total));
            });

            return(recursiveTailSum(0, intStack));
        }
Example #16
0
        // -----------------------------------------------------------------------------------
        static void Send(GameEvent e, DelegateSet delegateSet)
        // -----------------------------------------------------------------------------------
        {
            if (delegateSet == null)
            {
                return; // no one listening for this event, so ignore it
            }
            delegateSet.Queue.Enqueue(e);

            if (delegateSet.Queue.Count == 1)
            {
                Trampoline.Start(ProcessQueue, delegateSet);
            }
        }
        private Bounce <(int numberExecuted, int frameCount)> TrampolineRecursive(int numberOfRecursions, int numberExecuted = 0)
        {
            var stackTrace = new StackTrace();

            numberExecuted++;

            if (numberExecuted == numberOfRecursions)
            {
                return(Trampoline.Result((numberExecuted, stackTrace.FrameCount)));
            }
            else
            {
                return(Trampoline.Bounce(() => TrampolineRecursive(numberOfRecursions, numberExecuted)));
            }
        }
Example #18
0
    public void Setup(Jumper jumper, Trampoline trampoline)
    {
        this.jumper     = jumper;
        this.trampoline = trampoline;

        if (!initialized)
        {
            this.JumpPower  = trampoline.SpringForceRate;
            this.BoostPower = jumper.BoostRate;
            this.BoostTime  = jumper.BoostTimeMax;
            initialized     = true;
            RefreshLabels();
        }
        else
        {
            ApplyParam();
        }
    }
Example #19
0
        public void LoadContentAndCreateScenes(GraphicsDeviceManager graphics, ContentManager Content)
        {
            // Scene number 0
            Scene scene0 = new Scene();

            BackGround building = new BackGround();

            building.AddTexture(Content.Load <Texture2D>("protoBuilding.png"));
            building.position = new Vector2(480 / 2, 480);
            scene0.AddGameObject(building);

            FireMan fireMan;

            fireMan = new FireMan(graphics);
            fireMan.AddAnimation(new Animation(Content.Load <Texture2D>("FiremanFlyRightAnimation.png"), new Vector2(100, 100), 5));
            fireMan.AddAnimation(new Animation(Content.Load <Texture2D>("FiremanFlyLeftAnimation.png"), new Vector2(100, 100), 5));

            //fireMan.AddAnimation(new Animation(Content.Load<Texture2D>("MarkRight.png"), new Vector2(100, 100), 5));
            //fireMan.AddAnimation(new Animation(Content.Load<Texture2D>("MarkLeft.png"), new Vector2(100, 100), 5));

            fireMan.AddTexture(Content.Load <Texture2D>("FiremanAttackRight.png"));
            fireMan.AddTexture(Content.Load <Texture2D>("FiremanAttackLeft.png"));

            //fireMan.AddTexture(Content.Load<Texture2D>("MarkRightAttack.png"));
            //fireMan.AddTexture(Content.Load<Texture2D>("MarkLeftAttack.png"));

            WaterParticlesController particleController = new WaterParticlesController(40);

            particleController.AddTexture(Content.Load <Texture2D>("Drop.png"));
            fireMan.AddParticleController(particleController);
            scene0.AddGameObject(fireMan);

            Trampoline trampoline;

            trampoline = new Trampoline(graphics);
            trampoline.AddAnimation(new Animation(Content.Load <Texture2D>("TwoWithTrampolineAnimation.png"), new Vector2(150, 100), 10));
            trampoline.AddTexture(Content.Load <Texture2D>("TwoWithTrampoline1.png"));
            fireMan.trampoline = trampoline;
            scene0.AddGameObject(trampoline);


            this.AddScene(scene0);
            currentSceneNumber = 0;
        }
Example #20
0
        static public void ApplyCombatHitSpell()
        {
            var position = Trampoline.Reserve((7 + 4 + 4 + 2) + System.Runtime.CompilerServices.Unsafe.SizeOf <AbsoluteJump>() + 1);

            Trampoline.Write += (System.Object sender, System.EventArgs arguments) =>
            {
                var assembly = new UnmanagedArray <System.Byte>();

                assembly.Add(new System.Byte[7] {
                    0x44, 0x8B, 0x97, 0xCC, 0x01, 0x00, 0x00
                });                                                                                                                                                                                                                                                             // mov r10d, [rdi+1CC]
                assembly.Add(new System.Byte[4] {
                    0x41, 0xC1, 0xEA, 0x08
                });                                                                                                                                                                                                                                                                             // shr r10d, 8 (ProjectileFlags.Is3DLoaded)
                assembly.Add(new System.Byte[4] {
                    0x41, 0xF6, 0xC2, 0x01
                });                                                                                                                                                                                                                                                                             // test r10b, 1
                assembly.Add(new System.Byte[2] {
                    0x74, (System.Byte)System.Runtime.CompilerServices.Unsafe.SizeOf <AbsoluteJump>()
                });                                                                                                                                                                             // je E

                assembly.Add(Assembly.AbsoluteJump(Memory.ReadRelativeCall(ScrambledBugs.Offsets.Fixes.ApplySpellPerkEntryPoints.Arrows.ApplyCombatHitSpellArrowProjectile)));                  // call BGSEntryPointPerkEntry.HandleEntryPoints

                assembly.Add(new System.Byte[1] {
                    Assembly.Ret
                });                                                                                                                                                                                                                                                                                             // ret

                Memory.SafeWrite <System.Byte>(Trampoline.Address + position, assembly);
                Memory.WriteRelativeCall(ScrambledBugs.Offsets.Fixes.ApplySpellPerkEntryPoints.Arrows.ApplyCombatHitSpellArrowProjectile, (Trampoline.Address + position).ToPointer());

                // arrowProjectile != null

                /*
                 * ArrowProjectile* arrowProjectile; // rdi
                 *
                 * if ((arrowProjectile->Flags() & ProjectileFlags.Is3DLoaded) == ProjectileFlags.Is3DLoaded)
                 * {
                 *      goto Function;
                 * }
                 *
                 * return;
                 */
            };
        }
Example #21
0
        static public void CanPowerAttack()
        {
            Trampoline.WriteRelativeCallBranch
            (
                ScrambledBugs.Offsets.Patches.PowerAttackStamina.GetStaminaCostActor,
                PowerAttackStamina.CanPowerAttack(Memory.ReadRelativeCall(ScrambledBugs.Offsets.Patches.PowerAttackStamina.GetStaminaCostActor))
            );

            var assemblyActor = new UnmanagedArray <System.Byte>();

            assemblyActor.Add(new System.Byte[2] {
                0x84, 0xC0
            });                                                                 // test al, al
            assemblyActor.Add(new System.Byte[1] {
                Assembly.Nop
            });                                                                 // nop
            assemblyActor.Add(new System.Byte[2] {
                0x74, 0x6E
            });                                                                 // jz 6E

            Memory.SafeWrite <System.Byte>(ScrambledBugs.Offsets.Patches.PowerAttackStamina.HasStaminaCostActor, assemblyActor);



            Trampoline.WriteRelativeCallBranch
            (
                ScrambledBugs.Offsets.Patches.PowerAttackStamina.GetStaminaCostPlayerCharacter,
                PowerAttackStamina.CanPowerAttack(Memory.ReadRelativeCall(ScrambledBugs.Offsets.Patches.PowerAttackStamina.GetStaminaCostPlayerCharacter))
            );

            var assemblyPlayerCharacter = new UnmanagedArray <System.Byte>();

            assemblyPlayerCharacter.Add(new System.Byte[2] {
                0x84, 0xC0
            });                                                                                 // test al, al
            assemblyPlayerCharacter.Add(new System.Byte[1] {
                Assembly.Nop
            });                                                                                 // nop
            assemblyPlayerCharacter.Add(new System.Byte[2] {
                0x75, 0x34
            });                                                                                 // jnz 34

            Memory.SafeWrite <System.Byte>(ScrambledBugs.Offsets.Patches.PowerAttackStamina.HasStaminaCostPlayerCharacter, assemblyPlayerCharacter);
        }
        static public void IsPlayerOrTeammate()
        {
            var assembly = new UnmanagedArray <System.Byte>();

            assembly.Add(Memory.ReadArray <System.Byte>(ScrambledBugs.Offsets.Patches.TeammateDifficulty.IsPlayer, System.Runtime.CompilerServices.Unsafe.SizeOf <RelativeCall>()));            // mov edx, 18
            assembly.Add(new System.Byte[2] {
                0x74, 6 + 3 + 2 + 2
            });                                                                                                                                                                                                                                                                                                 // je B

            assembly.Add(new System.Byte[6] {
                0x8B, 0x81, 0xE0, 0x00, 0x00, 0x00
            });                                                                                                                                                                                                                                                                                 // mov eax, [rcx+E0]
            assembly.Add(new System.Byte[3] {
                0xC1, 0xE8, 0x1A
            });                                                                                                                                                                                                                                                                                                 // shr eax, 1A
            assembly.Add(new System.Byte[2] {
                0xF6, 0xD0
            });                                                                                                                                                                                                                                                                                                         // not al
            assembly.Add(new System.Byte[2] {
                0xA8, 0x01
            });                                                                                                                                                                                                                                                                                                         // test al, 1

            assembly.Add(new System.Byte[1] {
                Assembly.Ret
            });                                                                                                                                                                                                                                                                                                         // ret

            Trampoline.WriteRelativeCallBranch(ScrambledBugs.Offsets.Patches.TeammateDifficulty.IsPlayer, assembly);

            // rax
            // eflags

            // actor != null

            /*
             * Actor* actor; // rcx
             *
             * return
             *      (actor == player)
             ||
             ||     ((actor->BoolBits() & ActorBoolBits.PlayerTeammate) == ActorBoolBits.PlayerTeammate);
             */
        }
Example #23
0
    private void OnCollisionEnter(Collision collision)
    {
        Trampoline collidedTramp = collision.gameObject.GetComponentInParent <Trampoline> ();

        if (collidedTramp)
        {
            print("hit tramp!");
            if (oldTramp)
            {
                // Player is bouncing again!
                bounces++;
                if (bounces > oldTramp.jumpSpeeds.Length) //jumpSpeeds.Length)
                {
                    bounces = oldTramp.jumpSpeeds.Length; // jumpSpeeds.Length;
                }
            }
            else
            {
                bounces  = 1;
                oldTramp = collidedTramp;
            }

            rfpc.OverrideJump(oldTramp.jumpSpeeds[bounces - 1], jumpDrag);
            rfpc.trampolining = true;

            rfpc.movementSettings.ForwardSpeed  = airSpeed;
            rfpc.movementSettings.BackwardSpeed = airSpeed;
            rfpc.movementSettings.StrafeSpeed   = airSpeed;
        }
        else
        {
            rfpc.movementSettings.ForwardSpeed  = 6f;
            rfpc.movementSettings.BackwardSpeed = 3f;
            rfpc.movementSettings.StrafeSpeed   = 3f;

            rfpc.trampolining = false;
            bounces           = 0;
            oldTramp          = null;
        }
    }
Example #24
0
 void SetUpPowerUp()
 {
     RenderSettings.skybox.SetVector("ScrollSpeed", new Vector4(0, 0.3f, 0, 0));
     if (powerUpType == 1)
     {
         powerUpTypeText.text = "Quadruple Points!";
         foreach (GameObject a in trampolines)
         {
             Texture temp = a.GetComponentInChildren <Trampoline>().GetComponent <SkinnedMeshRenderer>().material.mainTexture;
             a.GetComponentInChildren <Trampoline>().GetComponent <SkinnedMeshRenderer>().material             = mulitplierUpShroomMaterial;
             a.GetComponentInChildren <Trampoline>().GetComponent <SkinnedMeshRenderer>().material.mainTexture = temp;
         }
     }
     else if (powerUpType == 2)
     {
         powerUpTypeText.text = "Pass Through!";
         foreach (GameObject a in trampolines)
         {
             Trampoline tramp = a.GetComponentInChildren <Trampoline>();
             tramp.GetComponent <SkinnedMeshRenderer>().enabled = false;
             tramp.bottom.enabled = false;
             tramp.bottomMesh.gameObject.SetActive(false);
             tramp.cloud.SetActive(true);
         }
     }
     else if (powerUpType == 3)
     {
         powerUpTypeText.text = "Safety Net Mushroom!";
         GameObject t = Instantiate(trampGo, new Vector3(0, mainCamera.transform.position.y - 6, 0), transform.rotation);
         t.GetComponentInChildren <Renderer>().material.mainTexture = redShroom;
         Trampoline tramp = t.GetComponentInChildren <Trampoline>();
         tramp.pointValue       = 0;
         tramp.bouncinessY      = 250;
         tramp.dieOnTouch       = false;
         t.transform.localScale = new Vector3(3, 3, 3);
         safetyNetMushroom      = t;
     }
 }
Example #25
0
    // Spawn Trampline or something else
    private void TrampolineSpawn(int PositionWidth)
    {
        if ((LevelSelected == Levels.WithTrampo || LevelSelected == Levels.SpawnWithTrampline) && LastLenghtPos == 20) // Events When function need work
        {
            foreach (GameObject Trampoline in OS.Trampolines)                                                          // Trampline Spawn
            {
                if (!Trampoline.active)
                {
                    int     TramplineSpawnPos = row - (WidthRandSave + PositionWidth);
                    Vector3 GetPosition       = PlatformScript.PositionMesh[LastLenghtPos, TramplineSpawnPos];


                    Trampoline.transform.SetParent(PlatformScript.gameObject.transform);
                    Trampoline.transform.localPosition = GetPosition;
                    Trampoline.transform.position      = new Vector3(Trampoline.transform.position.x, 0, Trampoline.transform.position.z);
                    Trampoline.SetActive(true);
                    WidthRandSave = -1;

                    LastLenghtPos++;
                    SpawnThree++;

                    break;
                }
            }
        }
        else if (LevelSelected == Levels.WithTrampo && LastLenghtPos != 20)
        {
            int     TramplineSpawnPos = row - (WidthRandSave + PositionWidth);
            Vector3 GetPosition       = PlatformScript.PositionMesh[LastLenghtPos, TramplineSpawnPos];

            GameObject obj = OS.SpawnObjWithTrampo();


            obj.transform.localPosition = GetPosition;
            obj.transform.position      = new Vector3(obj.transform.position.x, 3, obj.transform.position.z);
        }
    }
Example #26
0
            public void Enqueue(TaskChain item)
            {
                var q = GetQueue();

                if (q == null)
                {
                    q = new Queue <TaskChain>(5);
                    q.Enqueue(item);
                    SetQueue(q);

                    try
                    {
                        Trampoline.Run(q);
                    }
                    finally
                    {
                        SetQueue(null);
                    }
                }
                else
                {
                    q.Enqueue(item);
                }
            }
        static public void GetMaximumWardPower()
        {
            var assembly = new UnmanagedArray <System.Byte>();

            assembly.Add(new System.Byte[1] {
                0x51
            });                                                                                                                                                                                                                                                 // push rcx
            assembly.Add(new System.Byte[4] {
                0x48, 0x83, 0xEC, 0x40
            });                                                                                                                                                                                                                         // sub rsp, 40
            assembly.Add(new System.Byte[2] {
                0x48, 0xB8
            }); assembly.Add(Eggstensions.Offsets.FindMaxMagnitudeVisitor.VirtualFunctionTable);                                                                        // mov rax
            assembly.Add(new System.Byte[5] {
                0x48, 0x89, 0x44, 0x24, 0x20
            });                                                                                                                                                                                                                         // mov [rsp+20], rax
            assembly.Add(new System.Byte[2] {
                0x31, 0xC0
            });                                                                                                                                                                                                                                         // xor eax, eax
            assembly.Add(new System.Byte[5] {
                0x48, 0x89, 0x44, 0x24, 0x28
            });                                                                                                                                                                                                                         // mov [rsp+28], rax
            assembly.Add(new System.Byte[5] {
                0xB8, 0xFF, 0xFF, 0xFF, 0xFF
            });                                                                                                                                                                                                                         // mov eax, -1
            assembly.Add(new System.Byte[4] {
                0xF3, 0x0F, 0x2A, 0xC0
            });                                                                                                                                                                                                                         // cvtsi2ss xmm0, eax
            assembly.Add(new System.Byte[6] {
                0xF3, 0x0F, 0x11, 0x44, 0x24, 0x30
            });                                                                                                                                                                                                                 // movss [rsp+30], xmm0
            assembly.Add(new System.Byte[5] {
                0x48, 0x8D, 0x54, 0x24, 0x20
            });                                                                                                                                                                                                                         // lea rdx, [rsp+20]
            assembly.Add(new System.Byte[7] {
                0x48, 0x81, 0xC1, 0x98, 0x00, 0x00, 0x00
            });                                                                                                                                                                                 // add rcx, 98
            assembly.Add(Assembly.AbsoluteCall(Eggstensions.Offsets.MagicTarget.VisitActiveEffects.ToPointer()));                                                                               // call MagicTarget.VisitActiveEffects

            assembly.Add(new System.Byte[6] {
                0xF3, 0x0F, 0x10, 0x4C, 0x24, 0x30
            });                                                                                                                                                                                                                 // movss xmm1, [rsp+30]
            assembly.Add(new System.Byte[5] {
                0x48, 0x8B, 0x4C, 0x24, 0x40
            });                                                                                                                                                                                         // mov rcx, [rsp+40]
            assembly.Add(Assembly.AbsoluteCall(Eggstensions.Offsets.Actor.SetMaximumWardPower.ToPointer()));                                                                                            // call Actor.SetMaximumWardPower

            assembly.Add(new System.Byte[5] {
                0x48, 0x8B, 0x4C, 0x24, 0x40
            });                                                                                                                                                 // mov rcx, [rsp+40]
            assembly.Add(Assembly.AbsoluteCall(Memory.ReadRelativeCall(ScrambledBugs.Offsets.Patches.AccumulatingMagnitude.GetMaximumWardPower)));              // call Actor.GetMaximumWardPower

            assembly.Add(new System.Byte[4] {
                0x48, 0x83, 0xC4, 0x48
            });                                                                                                                                                                                                                         // add rsp, 48
            assembly.Add(new System.Byte[1] {
                Assembly.Ret
            });                                                                                                                                                                                                                                         // ret

            Trampoline.WriteRelativeCallBranch(ScrambledBugs.Offsets.Patches.AccumulatingMagnitude.GetMaximumWardPower, assembly);

            /*
             * Actor* actor; // rcx
             *
             * var findMaxMagnitudeVisitor						= new FindMaxMagnitudeVisitor();
             *(System.IntPtr*)&findMaxMagnitudeVisitor		= Eggstensions.Offsets.FindMaxMagnitudeVisitor.VirtualFunctionTable;
             * findMaxMagnitudeVisitor.FinishedActiveEffect	= null;
             * findMaxMagnitudeVisitor.MaximumMagnitude		= -1.0F;
             *
             * actor->MagicTarget()->VisitActiveEffects(&findMaxMagnitudeVisitor);
             * actor->SetMaximumWardPower(findMaxMagnitudeVisitor.MaximumMagnitude);
             *
             * return actor->GetMaximumWardPower();
             */
        }
Example #28
0
        public override IEnumerable<IResult> Apply(Input input)
        {
            var t = new Trampoline();

            var successes = new HashSet<ISuccess>();
            var failures = new HashSet<IFailure>();

            bool recognized = false;

            Func<IEnumerable<IResult>> parse = null;
            parse = () =>
            {
                if (t.HasNext)
                {
                    t.Step();

                    if (successes.Count == 0)
                    {
                        return parse();
                    }
                    else
                    {
                        var results = successes.ToList<IResult>();
                        successes.Clear();
                        results.AddRange(parse());
                        return results;
                    }
                }
                else
                {
                    if (recognized)
                    {
                        return successes.ToList<IResult>();
                    }
                    else
                    {
                        return failures.ToList<IResult>();
                    }
                }
            };

            Chain(t, input, result =>
            {
                if (result is ISuccess)
                {
                    Misc.Trace("Top-Level Success: {0}", result);
                    if (result.Remainder.EOF)
                    {
                        Misc.Trace("Tail Accepted: {0}", result);
                        recognized = true;
                        successes.Add(result as ISuccess);
                    }
                    else
                    {
                        Misc.Trace("Tail Rejected: {0}", result);
                        failures.Add(Result.Failure(result.Remainder, FailureType.UnexpectedTrailingChars));
                    }
                }
                else
                {
                    Misc.Trace("Top-Level Failure: {0}", result);
                    failures.Add(result as IFailure);
                }
            });

            return parse();
        }
Example #29
0
        public override void Chain(Trampoline t, Input input, OnChainResult result)
        {
            if (IsLL1())
            {
                if (input.EOF)
                {
                    result(Result.Failure(input, FailureType.UnexpectedEndOfStream));
                }
                else
                {
                    var predict = Predict();
                    Parser parser;
                    if (predict.TryGetValue(input.Current, out parser))
                    {
                        parser.Chain(t, input, result);
                    }
                    else
                    {
                        result(Result.Failure(input, FailureType.UnexpectedChars));
                    }
                }
            }
            else
            {
                var thunk = new ThunkParser(this, (tr, i, onResult) =>
                {
                    var results = new HashSet<IResult>();

                    var predicted = false;
                    var gather = Gather();
                    foreach (var p in gather)
                    {
                        if ((!i.EOF || p.First() == Misc.UniversalCharSet)
                            || (i.EOF || p.First().Contains(i.Current)))
                        {
                            predicted = true;
                            tr.Add(p, i, r =>
                            {
                                if (!results.Contains(r))
                                {
                                    Misc.Trace("Reduced: {0} *=> {1}", this, r);
                                    onResult(r);
                                    results.Add(r);
                                }
                            });
                        }
                    }

                    if (!predicted)
                    {
                        if (i.EOF)
                        {
                            onResult(Result.Failure(i, FailureType.UnexpectedEndOfStream));
                        }
                        else
                        {
                            onResult(Result.Failure(i, FailureType.UnexpectedChars));
                        }
                    }
                });

                t.Add(thunk, input, result);
            }
        }
Example #30
0
 public override void Chain(Trampoline t, Input input, OnChainResult result)
 {
     ChainDelegate(t, input, result);
 }
Example #31
0
        /// <summary>
        /// Schedules an action to be executed after dueTime.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">State passed to the action to be executed.</param>
        /// <param name="action">Action to be executed.</param>
        /// <param name="dueTime">Relative time after which to execute the action.</param>
        /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is <c>null</c>.</exception>
        public override IDisposable Schedule <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var queue = default(SchedulerQueue <TimeSpan>);

            // There is no timed task and no task is currently running
            if (!running)
            {
                running = true;

                if (dueTime > TimeSpan.Zero)
                {
                    ConcurrencyAbstractionLayer.Current.Sleep(dueTime);
                }

                // execute directly without queueing
                IDisposable d;
                try
                {
                    d = action(this, state);
                }
                catch
                {
                    SetQueue(null);
                    running = false;
                    throw;
                }

                // did recursive tasks arrive?
                queue = GetQueue();

                // yes, run those in the queue as well
                if (queue != null)
                {
                    try
                    {
                        Trampoline.Run(queue);
                    }
                    finally
                    {
                        SetQueue(null);
                        running = false;
                    }
                }
                else
                {
                    running = false;
                }

                return(d);
            }

            queue = GetQueue();

            // if there is a task running or there is a queue
            if (queue == null)
            {
                queue = new SchedulerQueue <TimeSpan>(4);
                SetQueue(queue);
            }

            var dt = Time + Scheduler.Normalize(dueTime);

            // queue up more work
            var si = new ScheduledItem <TimeSpan, TState>(this, state, action, dt);

            queue.Enqueue(si);
            return(si);
        }
Example #32
0
 public override void Chain(Trampoline t, Input input, OnChainResult result)
 {
     result(Parse(input));
 }
Example #33
0
    void SpawnTrampolines()
    {
        if (trampolines.Count < MaxNumberOfTrampolines)
        {
            int spawnX = 0;
            if (lastSideSpawned == 1)
            {
                spawnX = GetRandom();
            }
            else if (lastSideSpawned == 2)
            {
                spawnX = Random.Range(2, -1);
            }
            else
            {
                spawnX = Random.Range(-2, 1);
            }
            Vector3 spawnPos = new Vector3(spawnX, Random.Range(lastSpawnHeightTramp + 4, lastSpawnHeightTramp + 6), 0);
            lastSpawnHeightTramp = spawnPos.y;
            float rotation = 0;
            float randSize = 1;
            if (spawnX >= -1 && spawnX <= 1)
            {
                lastSideSpawned = 1;
                rotation        = Random.Range(-40, 40);
                randSize        = Random.Range(0.6f, 0.8f);
            }
            else if (spawnX < -1)
            {
                lastSideSpawned = 2;
                rotation        = Random.Range(-15, -40);
                randSize        = Random.Range(0.7f, 1.2f);
            }
            else
            {
                lastSideSpawned = 3;
                rotation        = Random.Range(15, 40);
                randSize        = Random.Range(0.7f, 1.2f);
            }
            Vector3    spawnRot = new Vector3(0, 0, rotation);
            GameObject t        = Instantiate(trampGo, spawnPos, Quaternion.Euler(spawnRot));


            t.transform.localScale = new Vector3(randSize, randSize, randSize);
            int        trampType = Random.Range(0, 3);
            Trampoline tramp     = t.GetComponentInChildren <Trampoline>();

            if (powerUpType == 1)
            {
                tramp.renderer.material = mulitplierUpShroomMaterial;
            }
            else if (powerUpType == 2)
            {
                tramp.GetComponent <SkinnedMeshRenderer>().enabled = false;
                tramp.bottom.enabled = false;
                tramp.bottomMesh.gameObject.SetActive(false);
                tramp.cloud.SetActive(true);
            }
            if (trampType == 1)
            {
                tramp.renderer.material.mainTexture = blueShroom;
                tramp.pointValue  = 10;
                tramp.bouncinessY = 200;
            }
            else if (trampType == 2)
            {
                tramp.pointValue = 20;
                tramp.renderer.material.mainTexture = greenShroom;
                tramp.bouncinessY = 225;
            }
            else
            {
                tramp.pointValue = 30;
                tramp.renderer.material.mainTexture = yellowShroom;
                tramp.bouncinessY = 250;
            }

            trampolines.Add(t);
        }
    }
Example #34
0
        static public void Initialize()
        {
            try
            {
                var settings = System.Text.Json.JsonSerializer.Deserialize <ScrambledBugs.JsonSettings>
                               (
                    System.IO.File.ReadAllText(System.IO.Path.Combine(Main.ExecutingAssemblyDirectoryName, $"{Main.ExecutingAssemblyName}.json")),
                    new System.Text.Json.JsonSerializerOptions()
                {
                    AllowTrailingCommas         = true,
                    PropertyNameCaseInsensitive = true,
                    ReadCommentHandling         = System.Text.Json.JsonCommentHandling.Skip
                }
                               );

                Log.Information($"Initializing...\n{System.Text.Json.JsonSerializer.Serialize<ScrambledBugs.JsonSettings>(settings, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase, WriteIndented = true })}");

                // Fixes
                if (settings?.Fixes?.ActorValuePercentage ?? false)
                {
                    settings.Fixes.ActorValuePercentage = ScrambledBugs.Fixes.ActorValuePercentage.Fix();
                }

                if (settings?.Fixes?.HarvestedFlags ?? false)
                {
                    settings.Fixes.HarvestedFlags = ScrambledBugs.Fixes.HarvestedFlags.Fix();
                }

                if (settings?.Fixes?.HitEffectRaceCondition ?? false)
                {
                    settings.Fixes.HitEffectRaceCondition = ScrambledBugs.Fixes.HitEffectRaceCondition.Fix();
                }

                if (settings?.Fixes?.MagicEffectConditions ?? false)
                {
                    settings.Fixes.MagicEffectConditions = ScrambledBugs.Fixes.MagicEffectConditions.Fix();
                }

                if (settings?.Fixes?.MagicEffectFlags ?? false)
                {
                    settings.Fixes.MagicEffectFlags = ScrambledBugs.Fixes.MagicEffectFlags.Fix();
                }

                if (settings?.Fixes?.ModArmorWeightPerkEntryPoint ?? false)
                {
                    settings.Fixes.ModArmorWeightPerkEntryPoint = ScrambledBugs.Fixes.ModArmorWeightPerkEntryPoint.Fix();
                }

                if ((settings?.Fixes?.QuickShot ?? false) && (settings?.Fixes?.QuickShotPlaybackSpeed.HasValue ?? false))
                {
                    settings.Fixes.QuickShot = ScrambledBugs.Fixes.QuickShot.Fix(settings.Fixes.QuickShotPlaybackSpeed.Value);
                }

                if (settings?.Fixes?.SpeedMultUpdates ?? false)
                {
                    settings.Fixes.SpeedMultUpdates = ScrambledBugs.Fixes.SpeedMultUpdates.Fix();
                }

                if (settings?.Fixes?.TerrainDecals ?? false)
                {
                    settings.Fixes.TerrainDecals = ScrambledBugs.Fixes.TerrainDecals.Fix();
                }

                if (settings?.Fixes?.TrainingMenuText ?? false)
                {
                    settings.Fixes.TrainingMenuText = ScrambledBugs.Fixes.TrainingMenuText.Fix();
                }

                if (settings?.Fixes?.WeaponCharge ?? false)
                {
                    settings.Fixes.WeaponCharge = ScrambledBugs.Fixes.WeaponCharge.Fix();
                }

                // Patches
                if (settings?.Patches?.AccumulatingMagnitude ?? false)
                {
                    settings.Patches.AccumulatingMagnitude = ScrambledBugs.Patches.AccumulatingMagnitude.Patch();
                }

                if (settings?.Patches?.AlreadyCaughtPickpocketing ?? false)
                {
                    settings.Patches.AlreadyCaughtPickpocketing = ScrambledBugs.Patches.AlreadyCaughtPickpocketing.Patch();
                }

                if (settings?.Patches?.ApplySpellPerkEntryPoints?.MultipleSpells ?? false)
                {
                    settings.Patches.ApplySpellPerkEntryPoints.MultipleSpells = ScrambledBugs.Patches.ApplySpellPerkEntryPoints.MultipleSpells.Patch(settings?.Patches?.ApplySpellPerkEntryPoints?.CastSpells ?? false);
                }
                else if (settings?.Patches?.ApplySpellPerkEntryPoints?.CastSpells ?? false)
                {
                    settings.Patches.ApplySpellPerkEntryPoints.CastSpells = ScrambledBugs.Patches.ApplySpellPerkEntryPoints.CastSpells.Patch();
                }

                if (settings?.Patches?.AttachHitEffectArt ?? false)
                {
                    settings.Patches.AttachHitEffectArt = ScrambledBugs.Patches.AttachHitEffectArt.Patch();
                }

                if (settings?.Patches?.EquipBestAmmo ?? false)
                {
                    settings.Patches.EquipBestAmmo = ScrambledBugs.Patches.EquipBestAmmo.Patch();
                }

                if (settings?.Patches?.LeveledCharacters ?? false)
                {
                    settings.Patches.LeveledCharacters = ScrambledBugs.Patches.LeveledCharacters.Patch();
                }

                if (settings?.Patches?.LockpickingExperience ?? false)
                {
                    settings.Patches.LockpickingExperience = ScrambledBugs.Patches.LockpickingExperience.Patch();
                }

                if (settings?.Patches?.MultipleHitEffects ?? false)
                {
                    settings.Patches.MultipleHitEffects = ScrambledBugs.Patches.MultipleHitEffects.Patch();
                }

                if (settings?.Patches?.PausedGameHitEffects ?? false)
                {
                    settings.Patches.PausedGameHitEffects = ScrambledBugs.Patches.PausedGameHitEffects.Patch();
                }

                if (settings?.Patches?.PowerAttackStamina ?? false)
                {
                    settings.Patches.PowerAttackStamina = ScrambledBugs.Patches.PowerAttackStamina.Patch();
                }

                if (settings?.Patches?.ReflectDamage ?? false)
                {
                    settings.Patches.ReflectDamage = ScrambledBugs.Patches.ReflectDamage.Patch();
                }

                if (settings?.Patches?.TeammateDifficulty ?? false)
                {
                    settings.Patches.TeammateDifficulty = ScrambledBugs.Patches.TeammateDifficulty.Patch();
                }

                if (settings?.Patches?.UnderfilledSoulGems ?? false)
                {
                    settings.Patches.UnderfilledSoulGems = ScrambledBugs.Patches.UnderfilledSoulGems.Patch();
                }

                // Fixes
                if (settings?.Fixes?.ApplySpellPerkEntryPoints?.Arrows ?? false)
                {
                    settings.Fixes.ApplySpellPerkEntryPoints.Arrows = ScrambledBugs.Fixes.ApplySpellPerkEntryPoints.Arrows.Fix();
                }

                Trampoline.Commit();

                Log.Information($"Initialized.\n{System.Text.Json.JsonSerializer.Serialize<ScrambledBugs.JsonSettings>(settings, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase, WriteIndented = true })}");
            }
            catch (System.Exception exception)             // System.IO.FileNotFoundException, System.Text.Json.JsonException
            {
                Log.Information($"{exception}");

                throw;
            }
        }
Example #35
0
    //Создание случайной платформы
    Platform RandomPlatform(Platform previous)
    {
        float x = Random.Range(-2.0f, 2.0f);
        // Высчитывается позиция по оси Y так, чтобы новая платформа не была слишком близко к предыдущей в случае одинаковой позиции по X
        float    y = CalculateY(previous.PosX, previous.PosY, x);
        Platform result;
        int      random = Random.Range(0, 100);

        // Низкая сложность
        if (chalksCount < 100)
        {
            // Обычная платформа
            if (random < 30)
            {
                result = new Simple(x, y);
            }
            // Батут
            else if (random >= 30 && random <= 45)
            {
                result = new Trampoline(x, y);
            }
            // Движущаяся платформа
            else if (random >= 45 && random <= 70)
            {
                result = new MovingPlatform(x, y);
            }
            // Исчезающая платформа
            else if (random > 70 && random <= 90)
            {
                result = new Fake(x, y);
            }
            // Другое
            else
            {
                result = new Simple(x, y);
            }
        }
        // Средняя сложность
        else if (chalksCount >= 100 && chalksCount <= 300)
        {
            // Обычная платформа
            if (random < 20)
            {
                result = new Simple(x, y);
            }
            // Батут
            else if (random >= 20 && random <= 45)
            {
                result = new Trampoline(x, y);
            }
            // Движущаяся платформа
            else if (random >= 45 && random <= 80)
            {
                result = new MovingPlatform(x, y);
            }
            // Исчезающая платформа
            else if (random > 80 && random <= 95)
            {
                result = new Fake(x, y);
            }
            //Другое
            else
            {
                result = new Simple(x, y);
            }
        }
        // Высокая сложность
        else
        {
            // Обычная платформа
            if (random < 10)
            {
                result = new Simple(x, y);
            }
            // Батут
            else if (random >= 10 && random <= 40)
            {
                result = new Trampoline(x, y);
            }
            // Движущаяся платформа
            else if (random >= 40 && random <= 80)
            {
                result = new MovingPlatform(x, y);
            }
            // Исчезающая платформа
            else if (random > 80 && random <= 95)
            {
                result = new Fake(x, y);
            }
            // Другое
            else
            {
                result = new Simple(x, y);
            }
        }

        return(result);
    }