public override void TransformValue(StatRequest req, ref float val)
        {
            if (req.Thing is Pawn pawn)
            {
                if (Compatibility_GiddyUp.GetMount(pawn) != null)
                {
                    return;
                }
                val = Mathf.Clamp(Mathf.RoundToInt(val * _modifier), 0.1f, 100f);

                if (!MassUtility.CanEverCarryAnything(pawn) || _carrymodifier <= 0f)
                {
                    return;
                }

                var pawnMass    = pawn.GetStatValue(StatDefOf.Mass);
                var ignoredMass = pawnMass * (pawn.RaceProps.packAnimal ? 0.5f : 0.2f);

                // add our own modifiers
                var mass = MassUtility.GearAndInventoryMass(pawn);

                if (Compatibility_GiddyUp.GetRider(pawn) is Pawn rider)
                {
                    mass += rider.GetStatValue(StatDefOf.Mass, true);
                    var riderCarriedThing = rider.carryTracker.CarriedThing;
                    if (riderCarriedThing != null)
                    {
                        mass += riderCarriedThing.stackCount * riderCarriedThing.GetStatValue(StatDefOf.Mass, true);
                        if (riderCarriedThing.def.category == ThingCategory.Pawn)
                        {
                            // undo carry pawn modifier
                            val *= 1.666f;
                        }
                    }
                }


                var capacity = pawn.GetStatValue(StatDefOf.CarryingCapacity, true);

                var pawnCarriedThing = pawn.carryTracker.CarriedThing;
                if (pawnCarriedThing != null)
                {
                    mass += pawnCarriedThing.stackCount * pawnCarriedThing.GetStatValue(StatDefOf.Mass, true);
                    if (pawnCarriedThing.def.category == ThingCategory.Pawn)
                    {
                        // undo carry pawn modifier
                        val *= 1.666f;
                    }
                }

                var encumbrance = Mathf.Max(mass - ignoredMass, 0f) / capacity;

                var modifier = 1 / (1 + (encumbrance * _carrymodifier));

                val *= modifier;
            }
        }
        //[HarmonyPostfix]
        public static void TicksPerMove(bool diagonal, Pawn __instance, ref int __result)
        {
            if (_carrymodifier == 0f)
            {
                return;
            }
            if (!MassUtility.CanEverCarryAnything(__instance))
            {
                __result = Mathf.Clamp(Mathf.RoundToInt(__result / _modifier), 1, 450);
                return;
            }
            var c           = (float)__result;
            var pawnMass    = __instance.GetStatValue(StatDefOf.Mass);
            var ignoredMass = pawnMass * (__instance.RaceProps.packAnimal ? 0.5f : 0.2f);

            if (Compatibility_GiddyUp.GetMount(__instance) is Pawn mount)
            {
                __result = diagonal ? mount.TicksPerMoveDiagonal : mount.TicksPerMoveCardinal;
                return;
            }

            // add our own modifiers
            var mass = ignoredMass - MassUtility.GearAndInventoryMass(__instance);

            if (Compatibility_GiddyUp.GetRider(__instance) is Pawn rider)
            {
                mass += MassUtility.GearAndInventoryMass(rider);

                mass += rider.GetStatValue(StatDefOf.Mass, true);
                var riderCarriedThing = rider.carryTracker.CarriedThing;
                if (riderCarriedThing != null)
                {
                    mass += riderCarriedThing.stackCount * riderCarriedThing.GetStatValue(StatDefOf.Mass);
                    if (riderCarriedThing is Pawn p)
                    {
                        mass += MassUtility.GearAndInventoryMass(p);

                        // undo carry pawn modifier
                        c /= 1.666f;
                    }
                }
            }


            var capacity = MassUtility.Capacity(__instance, null);

            var pawnCarriedThing = __instance.carryTracker.CarriedThing;

            if (pawnCarriedThing != null)
            {
                mass += pawnCarriedThing.stackCount * pawnCarriedThing.GetStatValue(StatDefOf.Mass);
                if (pawnCarriedThing is Pawn p)
                {
                    mass += MassUtility.GearAndInventoryMass(p);

                    // undo carry pawn modifier
                    c /= 1.666f;
                }
            }

            var encumbrance = Mathf.Clamp(mass / capacity, 0f, 1f);

            var modifier = 1 + (encumbrance * _carrymodifier);

            c *= modifier;

            __result = Mathf.Clamp(Mathf.RoundToInt(c / _modifier), 1, 450);
        }
        public override string ExplanationPart(StatRequest req)
        {
            if (_modifier <= 0f)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            if (req.Thing is Pawn pawn)
            {
                if (Compatibility_GiddyUp.GetMount(pawn) != null)
                {
                    return(string.Empty);
                }

                sb.AppendLine($"Global speed factor: x{_modifier.ToStringByStyle(ToStringStyle.FloatMaxOne)}");

                if (!MassUtility.CanEverCarryAnything(pawn) || _carrymodifier <= 0f)
                {
                    return(sb.ToString());
                }

                var pawnMass    = pawn.GetStatValue(StatDefOf.Mass);
                var ignoredMass = pawnMass * (pawn.RaceProps.packAnimal ? 0.5f : 0.2f);
                // add our own modifiers
                var mass = MassUtility.GearAndInventoryMass(pawn);

                if (Compatibility_GiddyUp.GetRider(pawn) is Pawn rider)
                {
                    sb.AppendLine($"Mounted by {rider}, adding {rider.GetStatValue(StatDefOf.Mass, true)} to carried mass.");

                    mass += rider.GetStatValue(StatDefOf.Mass, true);
                    var riderCarriedThing = rider.carryTracker.CarriedThing;
                    if (riderCarriedThing != null)
                    {
                        mass += riderCarriedThing.stackCount * riderCarriedThing.GetStatValue(StatDefOf.Mass, true);
                        if (riderCarriedThing.def.category == ThingCategory.Pawn)
                        {
                            // undo carry pawn modifier
                            sb.AppendLine($"Carrying {riderCarriedThing}: Undoing hardcoded carrying penalty: x1.6)");
                        }
                    }
                }


                var capacity = pawn.GetStatValue(StatDefOf.CarryingCapacity, true);

                var pawnCarriedThing = pawn.carryTracker.CarriedThing;
                if (pawnCarriedThing != null)
                {
                    mass += pawnCarriedThing.stackCount * pawnCarriedThing.GetStatValue(StatDefOf.Mass, true);
                    if (pawnCarriedThing.def.category == ThingCategory.Pawn)
                    {
                        // undo carry pawn modifier
                        sb.AppendLine($"Carrying {pawnCarriedThing}: Undoing hardcoded carrying penalty: x1.6)");
                    }
                }


                var encumbrance = Mathf.Max(mass - ignoredMass, 0f) / capacity;

                var modifier = 1 / (1 + (encumbrance * _carrymodifier));

                sb.AppendLine($"Carrying {(int)mass} ({(int)ignoredMass} free) with capacity {(int)capacity} (encumbrance {encumbrance.ToStringByStyle(ToStringStyle.FloatMaxTwo)}) and global factor {_carrymodifier}: x{modifier.ToStringByStyle(ToStringStyle.PercentOne)}");
            }
            return(sb.ToString());
        }