Further fixes of how passthrough items are handled
* When evaluating a plan, only give the pass-through treatment to items if the step they're part of was actually executed * When marking a step "complete", ignore passthrough items
This commit is contained in:
@@ -46,16 +46,21 @@ module.exports = class CraftingPlan
|
||||
recipe = step.recipe
|
||||
|
||||
for stack in step.recipe.output
|
||||
continue if recipe.isPassThroughFor stack.itemSlug
|
||||
qualifiedSlug = @_modPack.qualifySlug stack.itemSlug
|
||||
|
||||
if recipe.isPassThroughFor stack.itemSlug
|
||||
while @_need.quantityOf(qualifiedSlug) > 0
|
||||
@_executeStep step
|
||||
|
||||
if step.multiplier > 0
|
||||
for stack in step.recipe.output
|
||||
qualifiedSlug = @_modPack.qualifySlug stack.itemSlug
|
||||
continue unless recipe.isPassThroughFor stack.itemSlug
|
||||
continue if @_made.hasAtLeast qualifiedSlug, 1
|
||||
continue if @_need.hasAtLeast qualifiedSlug, 1
|
||||
continue if @_tools.hasAtLeast qualifiedSlug, 1
|
||||
@_need.add qualifiedSlug, 1
|
||||
@_tools.add qualifiedSlug, 1
|
||||
else
|
||||
while @_need.quantityOf(qualifiedSlug) > 0
|
||||
@_executeStep step
|
||||
|
||||
@_made.addInventory @_want
|
||||
@_made.addInventory @_tools
|
||||
|
||||
@@ -31,6 +31,7 @@ module.exports = class CraftingStep
|
||||
|
||||
completeInto: (targetInventory)->
|
||||
for stack in @_recipe.output
|
||||
continue if @_recipe.isPassThroughFor stack.itemSlug
|
||||
quantity = @_recipe.getQuantityProduced stack.itemSlug
|
||||
targetInventory.add stack.itemSlug, quantity * @_multiplier
|
||||
|
||||
|
||||
@@ -40,10 +40,9 @@ module.exports = class Craftsman extends BaseModel
|
||||
@_modPack = modPack
|
||||
|
||||
reset = _.debounce (=> @reset()), 100
|
||||
reevaluatePlans = _.debounce (=> @reevaluatePlans()), 100
|
||||
|
||||
@_have = new Inventory modPack:@_modPack
|
||||
@_have.on c.event.change, reevaluatePlans
|
||||
@_have.on c.event.change, reset
|
||||
|
||||
@_want = new Inventory modPack:@_modPack
|
||||
@_want.on c.event.change, reset
|
||||
@@ -55,14 +54,6 @@ module.exports = class Craftsman extends BaseModel
|
||||
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
reevaluatePlans: ->
|
||||
@_plans = null
|
||||
@_planEvaluator = null
|
||||
@stage = @STAGE.WAITING
|
||||
@stageCount = 0
|
||||
|
||||
@_scheduleNextWork()
|
||||
|
||||
reset: ->
|
||||
@_graphBuilder = null
|
||||
@_planBuilder = null
|
||||
|
||||
Reference in New Issue
Block a user