Ejemplo n.º 1
0
            public static bool Prefix(PlayerCharacterStats __instance)
            {
                var self = __instance;

                // get private fields
                var m_character = self.GetComponent <Character>();

                var m_generalBurdenPenaltyActive = (bool)At.GetField(self, "m_generalBurdenPenaltyActive");
                var m_pouchBurdenPenaltyActive   = (bool)At.GetField(self, "m_pouchBurdenPenaltyActive");
                var m_backBurdenPenaltyActive    = (bool)At.GetField(self, "m_backBurdenPenaltyActive");

                var m_movementSpeed       = (Stat)At.GetField(self, "m_movementSpeed");
                var m_staminaRegen        = (Stat)At.GetField(self, "m_staminaRegen");
                var m_staminaUseModifiers = (Stat)At.GetField(self, "m_staminaUseModifiers");

                // get config
                var nolimits        = NO_CONTAINER_LIMIT.Value;
                var removeAllBurden = DISABLE_ALL_BURDENS.Value || m_character.Cheats.NotAffectedByWeightPenalties;

                float totalWeight = removeAllBurden ? 0f : m_character.Inventory.TotalWeight;

                // update general burden
                if (totalWeight > 30f)
                {
                    At.SetField(self, "m_generalBurdenPenaltyActive", true);

                    float weightRatio = totalWeight / 30f;

                    float m_generalBurdenRatio = (float)At.GetField(self, "m_generalBurdenRatio");

                    if (weightRatio != m_generalBurdenRatio)
                    {
                        At.SetField(self, "m_generalBurdenRatio", weightRatio);

                        m_movementSpeed.AddMultiplierStack("Burden", weightRatio * -0.02f);
                        m_staminaRegen.AddMultiplierStack("Burden", weightRatio * -0.05f);
                        m_staminaUseModifiers.AddMultiplierStack("Burden_Dodge", weightRatio * 0.05f, TagSourceManager.Dodge);
                        m_staminaUseModifiers.AddMultiplierStack("Burden_Sprint", weightRatio * 0.05f, TagSourceManager.Sprint);
                    }
                }
                else if (m_generalBurdenPenaltyActive)
                {
                    At.SetField(self, "m_generalBurdenRatio", 1f);
                    At.SetField(self, "m_generalBurdenPenaltyActive", false);

                    m_movementSpeed.RemoveMultiplierStack("Burden");
                    m_staminaRegen.RemoveMultiplierStack("Burden");
                    m_staminaUseModifiers.RemoveMultiplierStack("Burden_Dodge");
                    m_staminaUseModifiers.RemoveMultiplierStack("Burden_Sprint");
                }

                // update pouch burden
                float pouchWeightCapacityRatio = (removeAllBurden || nolimits)
                                                    ? -1f
                                                    : m_character.Inventory.PouchWeightCapacityRatio;

                float m_pouchBurdenRatio = (float)At.GetField(self, "m_pouchBurdenRatio");

                if (pouchWeightCapacityRatio != m_pouchBurdenRatio)
                {
                    At.SetField(self, "m_pouchBurdenRatio", pouchWeightCapacityRatio);
                    m_pouchBurdenRatio = pouchWeightCapacityRatio;

                    var m_pouchBurdenThreshold = (StatThreshold)At.GetField(self, "m_pouchBurdenThreshold");

                    if (m_pouchBurdenThreshold)
                    {
                        m_pouchBurdenThreshold.UpdateThresholds(Mathf.Clamp01(pouchWeightCapacityRatio - 1f), 1f, true);
                    }

                    if (m_pouchBurdenRatio > 1f)
                    {
                        At.SetField(self, "m_pouchBurdenPenaltyActive", true);

                        var   m_pouchBurdenPenaltyCurve = (AnimationCurve)At.GetField(self, "m_pouchBurdenPenaltyCurve");
                        float value = m_pouchBurdenPenaltyCurve.Evaluate(m_pouchBurdenRatio - 1f);

                        m_movementSpeed.AddMultiplierStack("PouchBurden", value);

                        if (m_character.CharacterUI)
                        {
                            m_character.CharacterUI.ShowInfoNotification(LocalizationManager.Instance.GetLoc("Notification_Inventory_PouchOverweight"));
                        }
                    }
                    else if (m_pouchBurdenPenaltyActive)
                    {
                        At.SetField(self, "m_pouchBurdenPenaltyActive", false);
                        m_movementSpeed.RemoveMultiplierStack("PouchBurden");
                    }
                }

                // update bag burden
                float bagWeightCapacityRatio = (removeAllBurden || nolimits)
                                                ? -1f
                                                : m_character.Inventory.BagWeightCapacityRatio;

                float m_bagBurdenRatio = (float)At.GetField(self, "m_bagBurdenRatio");

                if (bagWeightCapacityRatio != m_bagBurdenRatio)
                {
                    m_bagBurdenRatio = bagWeightCapacityRatio;

                    At.SetField(self, "m_bagBurdenRatio", bagWeightCapacityRatio);

                    var m_bagBurdenThreshold = (StatThreshold)At.GetField(self, "m_bagBurdenThreshold");

                    if (m_bagBurdenThreshold)
                    {
                        m_bagBurdenThreshold.UpdateThresholds(Mathf.Clamp01(bagWeightCapacityRatio - 1f), 1f, true);
                    }

                    if (m_bagBurdenRatio > 1f)
                    {
                        At.SetField(self, "m_backBurdenPenaltyActive", true);

                        var m_bagBurdenPenaltyCurve = (AnimationCurve)At.GetField(self, "m_bagBurdenPenaltyCurve");

                        float value2 = m_bagBurdenPenaltyCurve.Evaluate(m_bagBurdenRatio - 1f);
                        m_movementSpeed.AddMultiplierStack("BagBurden", value2);

                        if (m_character.CharacterUI)
                        {
                            m_character.CharacterUI.ShowInfoNotification(LocalizationManager.Instance.GetLoc("Notification_Inventory_BagOverweight"));
                        }
                    }
                    else if (m_backBurdenPenaltyActive)
                    {
                        At.SetField(self, "m_backBurdenPenaltyActive", false);
                        m_movementSpeed.RemoveMultiplierStack("BagBurden");
                    }
                }

                //Instance.UpdatePlayer(m_character);

                return(false);
            }