Example #1
0
        public static bool Prefix(MovementComponent __instance, Vector2 dir, ref float delta_time)
        {
            if (!__instance.wgo.is_player || __instance.player_controlled_by_script || __instance.wgo.is_dead)
            {
                return(true);
            }
            Config.Options opts = Config.GetOptions();

            float speed = __instance.wgo.data.GetParam("speed", 0.0f);

            if (speed > 0)
            {
                speed = 3.3f + __instance.wgo.data.GetParam("speed_buff", 0.0f);
                float energydt        = delta_time * opts.EnergyForSprint;
                bool  isSprintPressed = opts.SprintToggle ? opts.SprintKey.IsToggled() : Input.GetKey(opts.SprintKey.Key);

                if (isSprintPressed && (MainGame.me.player.energy >= energydt))
                {
                    __instance.SetSpeed(speed * opts.SprintSpeed);
                    if (energydt > 0)
                    {
                        MainGame.me.player.energy -= energydt;
                    }
                }
                else
                {
                    __instance.SetSpeed(speed * opts.DefaultSpeed);
                }
            }
            return(true);
        }
Example #2
0
        public static bool Prefix(TechPointsSpawner __instance, ref int r, ref int g, ref int b)
        {
            Config.Options opts = Config.GetOptions();

            r = opts.GetOrbCount(r, 0);
            g = opts.GetOrbCount(g, 1);
            b = opts.GetOrbCount(b, 2);

            return(true);
        }
Example #3
0
 public static bool Prefix(PlayerComponent __instance, ref float need_energy)
 {
     if (need_energy != 0)
     {
         Config.Options opts = Config.GetOptions();
         float          mult = need_energy > 0 ? opts.EnergyDrainMult : opts.EnergyReplenMult;
         need_energy *= mult;
     }
     return(true);
 }
        static bool Prefix(EnvironmentEngine __instance)
        {
            if (MainGame.game_starting || MainGame.paused || !MainGame.game_started || __instance.IsTimeStopped())
            {
                return(true);
            }
            Config.Options opts = Config.GetOptions();
            float          mult = Time.timeScale == 10f ? opts.SleepTimeMult : opts.TimeMult;

            if (mult != 1)
            {
                float accountableDelta = Time.deltaTime / 225f;                 // since this._cur_time += deltaTime / 225f
                float adjDelta         = accountableDelta * mult - accountableDelta;
                EnvironmentEngine.SetTime(__instance.time_of_day.time_of_day + adjDelta);
            }
            if (opts.ConfigReloadKey.IsPressed())
            {
                Config.GetOptions(true);
                EffectBubblesManager.ShowImmediately(MainGame.me.player.pos3, "NKN configuration reloaded");
            }
            else if (opts.AddMoneyKey.IsPressed())
            {
                MainGame.me.player.data.money += 100;
                EffectBubblesManager.ShowImmediately(MainGame.me.player.pos3, "1 gold coin granted");
            }
            else if (opts.ResetPrayKey.IsPressed())
            {
                MainGame.me.player.SetParam("prayed_this_week", 0f);
                EffectBubblesManager.ShowImmediately(MainGame.me.player.pos3, "Weekly pray count reset");
            }
            else if (opts.TimeScaleSwitchKey.IsPressed())
            {
                if (opts.TimeScaleSwitchKey.State == 0)
                {
                    opts.TimeMult /= 10;
                }
                else
                {
                    opts.TimeMult *= 10;
                }
                EffectBubblesManager.ShowImmediately(MainGame.me.player.pos3, "Timescale is set to " + opts.TimeMult);
            }
            else if (opts.AllowSaveEverywhere)
            {
                if (opts.SaveGameKey.IsPressed())
                {
                    PlatformSpecific.SaveGame(MainGame.me.save_slot, MainGame.me.save, (PlatformSpecific.OnSaveCompleteDelegate)(slot => {
                        EffectBubblesManager.ShowImmediately(MainGame.me.player.pos3, "Saved succesfully");
                    }));
                }
            }
            return(true);
        }
        public static void Postfix(PlayerComponent __instance)
        {
            Config.Options opts = Config.GetOptions();

            if (opts.HealthRegen)
            {
                WorldGameObject player = MainGame.me.player;
                float           curhp  = player.hp;
                if (curhp > 0 && curhp < 100 && (opts.HealIfTired || player.energy > 10))
                {
                    curhp    += opts.HealthRegenPerSecond * Time.deltaTime;
                    player.hp = curhp < 100 ? curhp : 100;
                }
            }
        }
 public static bool Prefix(WorldGameObject __instance, ref float value)
 {
     if (__instance.is_player)
     {
         float oldVal = __instance.energy;
         float delta  = oldVal - value;
         if (delta < 0)
         {
             Config.Options opts = Config.GetOptions();
             delta *= delta > 0 ? opts.EnergyDrainMult : opts.EnergyReplenMult;
             value  = oldVal - delta;
         }
     }
     return(true);
 }
        static bool Prefix(EnvironmentEngine __instance)
        {
            if (MainGame.game_starting || MainGame.paused || !MainGame.game_started || __instance.IsTimeStopped())
            {
                return(true);
            }
            Config.Options opts = Config.GetOptions();
            float          mult = Time.timeScale == 10f ? opts.SleepTimeMult : opts.TimeMult;

            if (mult != 1)
            {
                float accountableDelta = Time.deltaTime / 225f;                 // since this._cur_time += deltaTime / 225f
                float adjDelta         = accountableDelta * mult - accountableDelta;
                EnvironmentEngine.SetTime(__instance.time_of_day.time_of_day + adjDelta);
            }
            return(true);
        }
Example #8
0
        public static void Postfix(PlayerComponent __instance)
        {
            Config.Options opts = Config.GetOptions();

            if (opts.HealthRegen)
            {
                WorldGameObject player = MainGame.me.player;
                float           curhp  = player.hp;
                if (curhp > 0 && curhp < 100 && (opts.HealIfTired || player.energy > 10))
                {
                    curhp    += opts.HealthRegenPerSecond * Time.deltaTime;
                    player.hp = curhp < 100 ? curhp : 100;
                }

                /*if (player.energy != opts.SavedEnergy) {
                 *      float mult = player.energy > opts.SavedEnergy ? opts.EnergyReplenMult : opts.EnergyDrainMult;
                 *      float newenergy = opts.SavedEnergy - (opts.SavedEnergy - player.energy) * mult;
                 *      player.energy = newenergy;
                 *      opts.SavedEnergy = newenergy;
                 * }*/
            }
        }
        static bool Prefix(HPActionComponent __instance, ref float value)
        {
            Config.Options opts = Config.GetOptions();
            if (opts.GlobalDmgMult != 1)
            {
                value *= opts.GlobalDmgMult;
            }
            if (value > 0.0 && __instance.wgo.is_player && (opts.DmgMult != 1.0))
            {
                if (opts.DmgMult <= 0)
                {
                    value = 0;
                }
                else
                {
                    WorldGameObject player = __instance.wgo;

                    float armor = 0;

                    Item equippedItem = player.GetEquippedItem(ItemDefinition.EquipmentType.HeadArmor);
                    if (equippedItem != null)
                    {
                        armor += equippedItem.definition.armor;
                    }
                    equippedItem = player.GetEquippedItem(ItemDefinition.EquipmentType.BodyArmor);
                    if (equippedItem != null)
                    {
                        armor += equippedItem.definition.armor;
                    }
                    armor += player.GetParam("add_armor", 0.0f);

                    value = (value - armor) * opts.DmgMult + armor;
                }
            }
            return(true);
        }