Exemplo n.º 1
0
        private static void Postfix(Thing thing, ref int __result)
        {
            if (!Limits.HasStackLimit(thing))
            {
                return;
            }

            var t = thing.stackCount - Limits.CalculateStackLimit(thing);

            if (t < 0)
            {
                t = 0;
            }

            __result = Mathf.Min(t, __result);
        }
 private static void Postfix(Thing t, ref bool __result)
 {
     if (__result)
     {
         __result = !Limits.HasStackLimit(t) && t.stackCount != Limits.CalculateStackLimit(t);
     }
     //if (t.IsForbidden(Faction.OfPlayer))
     //{
     //    __result = false;
     //}
     //else if (!Limits.HasStackLimit(t))
     //{
     //    __result = false;
     //}
     //else if (t.stackCount == Limits.CalculateStackLimit(t))
     //{
     //    __result = false;
     //}
     //else
     //    __result = true;
     //return false;
 }
Exemplo n.º 3
0
        public static bool Prefix(Thing __instance, Thing other, bool respectStackLimit, ref bool __result)
        {
            Mod.Debug("Thing.TryAbsorbStack begin");
            if (!Limits.HasStackLimit(__instance))
            {
                return(true);
            }

            if (!__instance.CanStackWith(other))
            {
                __result = false;
                return(false);
            }

            int num;

            if (respectStackLimit)
            {
                var t = Limits.CalculateStackLimit(__instance) - __instance.stackCount;
                if (t < 0)
                {
                    t = 0;
                }

                num = Mathf.Min(other.stackCount, t);
            }
            else
            {
                num = other.stackCount;
            }

            if (num <= 0)
            {
                __result = false;
                return(false);
            }

            if (__instance.def.useHitPoints)
            {
                __instance.HitPoints =
                    Mathf.CeilToInt(((__instance.HitPoints * __instance.stackCount) + (other.HitPoints * num)) /
                                    (float)(__instance.stackCount + num));
            }

            __instance.stackCount += num;
            other.stackCount      -= num;
            StealAIDebugDrawer.Notify_ThingChanged(__instance);
            if (__instance.Spawned)
            {
                __instance.Map.listerMergeables.Notify_ThingStackChanged(__instance);
            }

            if (other.stackCount <= 0)
            {
                other.Destroy();
                __result = true;
            }
            else
            {
                __result = false;
            }

            return(false);
        }