1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Refactor item acceptor system for huge performance improvement

This commit is contained in:
tobspr
2020-06-14 14:37:13 +02:00
parent e95b055e10
commit cda24ceb04
4 changed files with 100 additions and 35 deletions

View File

@@ -20,6 +20,14 @@ export const enumItemAcceptorItemFilter = {
* filter?: enumItemAcceptorItemFilter
* }} ItemAcceptorSlot */
/**
* Contains information about a slot plus its location
* @typedef {{
* slot: ItemAcceptorSlot,
* index: number,
* acceptedDirection: enumDirection
* }} ItemAcceptorLocatedSlot */
export class ItemAcceptorComponent extends Component {
static getId() {
return "ItemAcceptor";
@@ -164,11 +172,7 @@ export class ItemAcceptorComponent extends Component {
* Tries to find a slot which accepts the current item
* @param {Vector} targetLocalTile
* @param {enumDirection} fromLocalDirection
* @returns {{
* slot: ItemAcceptorSlot,
* index: number,
* acceptedDirection: enumDirection
* }|null}
* @returns {ItemAcceptorLocatedSlot|null}
*/
findMatchingSlot(targetLocalTile, fromLocalDirection) {
// We need to invert our direction since the acceptor specifies *from* which direction