Exemplo n.º 1
0
        public virtual bool TryAbsorbStack(Thing other, bool respectStackLimit)
        {
            if (!CanStackWith(other))
            {
                return(false);
            }
            int num = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit);

            if (def.useHitPoints)
            {
                HitPoints = Mathf.CeilToInt((float)(HitPoints * stackCount + other.HitPoints * num) / (float)(stackCount + num));
            }
            stackCount       += num;
            other.stackCount -= num;
            StealAIDebugDrawer.Notify_ThingChanged(this);
            if (Spawned)
            {
                Map.listerMergeables.Notify_ThingStackChanged(this);
            }
            if (other.stackCount <= 0)
            {
                other.Destroy();
                return(true);
            }
            return(false);
        }
        public override bool TryAbsorbStack(Thing other, bool respectStackLimit)
        {
            if (!this.CanStackWith(other))
            {
                return(false);
            }
            int count = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit);

            if (this.comps != null)
            {
                for (int i = 0; i < this.comps.Count; i++)
                {
                    this.comps[i].PreAbsorbStack(other, count);
                }
            }
            return(base.TryAbsorbStack(other, respectStackLimit));
        }
Exemplo n.º 3
0
        public virtual bool TryAbsorbStack(Thing other, bool respectStackLimit)
        {
            if (!this.CanStackWith(other))
            {
                return(false);
            }
            int num = ThingUtility.TryAbsorbStackNumToTake(this, other, respectStackLimit);

            if (this.def.useHitPoints)
            {
                this.HitPoints = Mathf.CeilToInt((float)(this.HitPoints * this.stackCount + other.HitPoints * num) / (float)(this.stackCount + num));
            }
            this.stackCount  += num;
            other.stackCount -= num;
            StealAIDebugDrawer.Notify_ThingChanged(this);
            if (other.stackCount <= 0)
            {
                other.Destroy(DestroyMode.Vanish);
                return(true);
            }
            return(false);
        }