mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Implement tryTakeItem in Storage
This commit is contained in:
parent
491e8dce23
commit
3305b62e00
@ -147,10 +147,12 @@ export class MetaTrashBuilding extends MetaBuilding {
|
|||||||
{
|
{
|
||||||
pos: new Vector(0, 1),
|
pos: new Vector(0, 1),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
|
processor: "Storage",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos: new Vector(1, 1),
|
pos: new Vector(1, 1),
|
||||||
directions: [enumDirection.bottom],
|
directions: [enumDirection.bottom],
|
||||||
|
processor: "Storage",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -48,6 +48,20 @@ export class StorageComponent extends Component {
|
|||||||
this.overlayOpacity = 0;
|
this.overlayOpacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {BaseItem} item
|
||||||
|
* @param {number} slot
|
||||||
|
*/
|
||||||
|
tryTakeItem(item, slot) {
|
||||||
|
if (this.canAcceptItem(item)) {
|
||||||
|
this.takeItem(item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this storage can accept the item
|
* Returns whether this storage can accept the item
|
||||||
* @param {BaseItem} item
|
* @param {BaseItem} item
|
||||||
|
@ -311,18 +311,6 @@ export class ItemEjectorSystem extends GameSystemWithFilter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const storageComp = receiver.components.Storage;
|
|
||||||
if (storageComp) {
|
|
||||||
// It's a storage
|
|
||||||
if (storageComp.canAcceptItem(item)) {
|
|
||||||
storageComp.takeItem(item);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Storage can't have anything else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user