@ -32,8 +32,7 @@ const MAX_QUEUED_CHARGES = 2;
* Type of a processor implementation
* @ typedef { {
* entity : Entity ,
* items : Array < { item : BaseItem , sourceSlot : number } > ,
* itemsBySlot : Object < number , BaseItem > ,
* items : Array < BaseItem ? > ,
* outItems : Array < ProducedItem >
* } } ProcessorImplementationPayload
* /
@ -189,7 +188,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
// DEFAULT
// By default, we can start processing once all inputs are there
case null : {
return processorComp . input Slots. length >= processorComp . inputsPerCharge ;
return processorComp . input Count >= processorComp . inputsPerCharge ;
}
// QUAD PAINTER
@ -197,18 +196,12 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
case enumItemProcessorRequirements . painterQuad : {
const pinsComp = entity . components . WiredPins ;
/** @type {Object.<number, { item: BaseItem, sourceSlot: number }>} */
const itemsBySlot = { } ;
for ( let i = 0 ; i < processorComp . inputSlots . length ; ++ i ) {
itemsBySlot [ processorComp . inputSlots [ i ] . sourceSlot ] = processorComp . inputSlots [ i ] ;
}
// First slot is the shape, so if it's not there we can't do anything
if ( ! itemsBy Slot[ 0 ] ) {
if ( ! processorComp . inputSlots [ 0 ] ) {
return false ;
}
const shapeItem = /** @type {ShapeItem} */ ( itemsBySlot[ 0 ] . item ) ;
const shapeItem = /** @type {ShapeItem} */ ( processorComp . inputSlots [ 0 ] ) ;
const slotStatus = [ ] ;
// Check which slots are enabled
@ -233,7 +226,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
// Check if all colors of the enabled slots are there
for ( let i = 0 ; i < slotStatus . length ; ++ i ) {
if ( slotStatus [ i ] && ! itemsBy Slot[ 1 + i ] ) {
if ( slotStatus [ i ] && ! processorComp. inpu tSlots [ 1 + i ] ) {
// A slot which is enabled wasn't enabled. Make sure if there is anything on the quadrant,
// it is not possible to paint, but if there is nothing we can ignore it
for ( let j = 0 ; j < 4 ; ++ j ) {
@ -262,13 +255,6 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
// First, take items
const items = processorComp . inputSlots ;
processorComp . inputSlots = [ ] ;
/** @type {Object<string, BaseItem>} */
const itemsBySlot = { } ;
for ( let i = 0 ; i < items . length ; ++ i ) {
itemsBySlot [ items [ i ] . sourceSlot ] = items [ i ] . item ;
}
/** @type {Array<ProducedItem>} */
const outItems = [ ] ;
@ -281,7 +267,6 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
handler ( {
entity ,
items ,
itemsBySlot ,
outItems ,
} ) ;
@ -304,6 +289,9 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
items : outItems ,
remainingTime : timeToProcess ,
} ) ;
processorComp . inputSlots . length = 0 ;
processorComp . inputCount = 0 ;
}
/ * *
@ -320,8 +308,9 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
const nextSlot = processorComp . nextOutputSlot ++ % availableSlots ;
for ( let i = 0 ; i < payload . items . length ; ++ i ) {
if ( ! payload . items [ i ] ) continue ;
payload . outItems . push ( {
item : payload . items [ i ] .item ,
item : payload . items [ i ] ,
preferredSlot : ( nextSlot + i ) % availableSlots ,
doNotTrack : true ,
} ) ;
@ -333,7 +322,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _CUTTER ( payload ) {
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] .item );
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] );
assert ( inputItem instanceof ShapeItem , "Input for cut is not a shape" ) ;
const inputDefinition = inputItem . definition ;
@ -354,7 +343,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _CUTTER _QUAD ( payload ) {
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] .item );
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] );
assert ( inputItem instanceof ShapeItem , "Input for cut is not a shape" ) ;
const inputDefinition = inputItem . definition ;
@ -375,7 +364,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _ROTATER ( payload ) {
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] .item );
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] );
assert ( inputItem instanceof ShapeItem , "Input for rotation is not a shape" ) ;
const inputDefinition = inputItem . definition ;
@ -389,7 +378,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _ROTATER _CCW ( payload ) {
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] .item );
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] );
assert ( inputItem instanceof ShapeItem , "Input for rotation is not a shape" ) ;
const inputDefinition = inputItem . definition ;
@ -403,7 +392,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _ROTATER _180 ( payload ) {
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] .item );
const inputItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] );
assert ( inputItem instanceof ShapeItem , "Input for rotation is not a shape" ) ;
const inputDefinition = inputItem . definition ;
@ -417,8 +406,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _STACKER ( payload ) {
const lowerItem = /** @type {ShapeItem} */ ( payload . items BySlot [ 0 ] ) ;
const upperItem = /** @type {ShapeItem} */ ( payload . items BySlot [ 1 ] ) ;
const lowerItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] ) ;
const upperItem = /** @type {ShapeItem} */ ( payload . items [ 1 ] ) ;
assert ( lowerItem instanceof ShapeItem , "Input for lower stack is not a shape" ) ;
assert ( upperItem instanceof ShapeItem , "Input for upper stack is not a shape" ) ;
@ -444,8 +433,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* /
process _MIXER ( payload ) {
// Find both colors and combine them
const item1 = /** @type {ColorItem} */ ( payload . items [ 0 ] .item );
const item2 = /** @type {ColorItem} */ ( payload . items [ 1 ] .item );
const item1 = /** @type {ColorItem} */ ( payload . items [ 0 ] );
const item2 = /** @type {ColorItem} */ ( payload . items [ 1 ] );
assert ( item1 instanceof ColorItem , "Input for color mixer is not a color" ) ;
assert ( item2 instanceof ColorItem , "Input for color mixer is not a color" ) ;
@ -467,8 +456,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _PAINTER ( payload ) {
const shapeItem = /** @type {ShapeItem} */ ( payload . items BySlot [ 0 ] ) ;
const colorItem = /** @type {ColorItem} */ ( payload . items BySlot [ 1 ] ) ;
const shapeItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] ) ;
const colorItem = /** @type {ColorItem} */ ( payload . items [ 1 ] ) ;
const colorizedDefinition = this . root . shapeDefinitionMgr . shapeActionPaintWith (
shapeItem . definition ,
@ -484,9 +473,9 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _PAINTER _DOUBLE ( payload ) {
const shapeItem1 = /** @type {ShapeItem} */ ( payload . items BySlot [ 0 ] ) ;
const shapeItem2 = /** @type {ShapeItem} */ ( payload . items BySlot [ 1 ] ) ;
const colorItem = /** @type {ColorItem} */ ( payload . items BySlot [ 2 ] ) ;
const shapeItem1 = /** @type {ShapeItem} */ ( payload . items [ 0 ] ) ;
const shapeItem2 = /** @type {ShapeItem} */ ( payload . items [ 1 ] ) ;
const colorItem = /** @type {ColorItem} */ ( payload . items [ 2 ] ) ;
assert ( shapeItem1 instanceof ShapeItem , "Input for painter is not a shape" ) ;
assert ( shapeItem2 instanceof ShapeItem , "Input for painter is not a shape" ) ;
@ -514,14 +503,14 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* @ param { ProcessorImplementationPayload } payload
* /
process _PAINTER _QUAD ( payload ) {
const shapeItem = /** @type {ShapeItem} */ ( payload . items BySlot [ 0 ] ) ;
const shapeItem = /** @type {ShapeItem} */ ( payload . items [ 0 ] ) ;
assert ( shapeItem instanceof ShapeItem , "Input for painter is not a shape" ) ;
/** @type {Array<enumColors>} */
const colors = [ null , null , null , null ] ;
for ( let i = 0 ; i < 4 ; ++ i ) {
if ( payload . items BySlot [ i + 1 ] ) {
colors [ i ] = /** @type {ColorItem} */ ( payload . items BySlot [ i + 1 ] ) . color ;
if ( payload . items [ i + 1 ] ) {
colors [ i ] = /** @type {ColorItem} */ ( payload . items [ i + 1 ] ) . color ;
}
}
@ -540,7 +529,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* /
process _READER ( payload ) {
// Pass through the item
const item = payload . items BySlot [ 0 ] ;
const item = payload . items [ 0 ] ;
payload . outItems . push ( {
item ,
doNotTrack : true ,
@ -560,7 +549,8 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
assert ( hubComponent , "Hub item processor has no hub component" ) ;
for ( let i = 0 ; i < payload . items . length ; ++ i ) {
const item = /** @type {ShapeItem} */ ( payload . items [ i ] . item ) ;
if ( ! payload . items [ i ] ) continue ;
const item = /** @type {ShapeItem} */ ( payload . items [ i ] ) ;
this . root . hubGoals . handleDefinitionDelivered ( item . definition ) ;
}
}
@ -570,7 +560,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
* /
process _GOAL ( payload ) {
const goalComp = payload . entity . components . GoalAcceptor ;
const item = payload . items [ 0 ] .item ;
const item = payload . items [ 0 ] ;
const now = this . root . time . now ( ) ;
if ( goalComp . item && ! item . equals ( goalComp . item ) ) {
@ -584,7 +574,7 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
if ( this . root . gameMode . getIsEditor ( ) ) {
// while playing in editor, assign the item
goalComp . item = payload . items [ 0 ] .item ;
goalComp . item = payload . items [ 0 ] ;
}
goalComp . lastDelivery = {