public virtual void TryStoreThing(Thing element) { if (StoredThing != null) { if (StoredThing.CanStackWith(element)) { //Verse.ThingUtility.TryAsborbStackNumToTake <- That's not a typo, that's an actual method. Seriously. Good thing it's fixed in A17, eh? (LudeonLeaks, 2017) var num = Mathf.Min(element.stackCount, Mathf.Min(limit, StoredThing.def.stackLimit) - StoredThing.stackCount); if (num > 0) { var t = element.SplitOff(num); StoredThing.TryAbsorbStack(t, true); } } } else { var num = Mathf.Min(element.stackCount, limit); if (num == element.stackCount) { element.Position = Position; } else if (num > 0) { var t = element.SplitOff(num); GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct); } } }
public virtual void TryStoreThing(Thing element) { if (StoredThing != null) { if (StoredThing.CanStackWith(element)) { var num = Mathf.Min(element.stackCount, (StoredThing.def.stackLimit - StoredThing.stackCount)); if (OutputSettings.useMax) { num = Mathf.Min(element.stackCount, Mathf.Min((StoredThing.def.stackLimit - StoredThing.stackCount), (OutputSettings.max - StoredThing.stackCount))); } if (num > 0) { var t = element.SplitOff(num); StoredThing.TryAbsorbStack(t, true); } } } else { var num = element.stackCount; if (OutputSettings.useMax) { num = Mathf.Min(element.stackCount, OutputSettings.max); } else if (num > 0) { // if this is the entire stack, we just get the stack. Important for belts to do it this way: var t = element.SplitOff(num); GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct); } } }
public override void Tick() { base.Tick(); if (GetComp <CompPowerTrader>().PowerOn&& Find.TickManager.TicksGame % 35 == 0) { foreach (var element in ThingsToSelect) { if (element.def.category == ThingCategory.Item && settings.AllowedToAccept(element)) { TryStoreThing(element); break; } } if (StoredThing != null) { if (settings.AllowedToAccept(StoredThing)) { StoredThing.SetForbidden(true, false); } else { StoredThing.SetForbidden(false, false); } } } }
public override void Tick() { base.Tick(); if (GetComp <CompPowerTrader>().PowerOn&& Find.TickManager.TicksGame % 35 == 0) { foreach (var element in ThingsToSelect) { bool withinLimits = true; if (OutputSettings.useMin) { withinLimits = (element.stackCount >= OutputSettings.min); } if (element.def.category == ThingCategory.Item && settings.AllowedToAccept(element) && withinLimits) { TryStoreThing(element); break; } } if (StoredThing != null) { if (settings.AllowedToAccept(StoredThing)) { bool forbidItem = true; if (OutputSettings.useMin || OutputSettings.useMax) { if (OutputSettings.useMin && StoredThing.stackCount < OutputSettings.min) { forbidItem = false; } else if (OutputSettings.useMax && StoredThing.stackCount > OutputSettings.max) { forbidItem = false; } } if (forbidItem) { StoredThing.SetForbidden(true, false); return; } } StoredThing.SetForbidden(false, false); } } }
public virtual void TryStoreThing(Thing element) { if (StoredThing != null) { if (StoredThing.CanStackWith(element)) { var num = Mathf.Min(element.stackCount, (StoredThing.def.stackLimit - StoredThing.stackCount)); if (OutputSettings.useMax) { num = Mathf.Min(element.stackCount, Mathf.Min((StoredThing.def.stackLimit - StoredThing.stackCount), (OutputSettings.max - StoredThing.stackCount))); } if (num > 0) { var t = element.SplitOff(num); StoredThing.TryAbsorbStack(t, true); } } } else { var num = element.stackCount; if (OutputSettings.useMax) { num = Mathf.Min(element.stackCount, OutputSettings.max); } if (num == element.stackCount) { element.Position = Position; } else if (num > 0) { var t = element.SplitOff(num); GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct); } } }