mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Add chainable splitter system mock
This commit is contained in:
parent
d11388812a
commit
eaa46ec914
@ -13,6 +13,7 @@ import { HubSystem } from "./systems/hub";
|
||||
import { StaticMapEntitySystem } from "./systems/static_map_entity";
|
||||
import { ItemAcceptorSystem } from "./systems/item_acceptor";
|
||||
import { StorageSystem } from "./systems/storage";
|
||||
import { ChainableSplitterSystem } from "./systems/chainable_splitter";
|
||||
import { EnergyGeneratorSystem } from "./systems/energy_generator";
|
||||
import { WiredPinsSystem } from "./systems/wired_pins";
|
||||
|
||||
@ -58,6 +59,9 @@ export class GameSystemManager {
|
||||
/** @type {StorageSystem} */
|
||||
storage: null,
|
||||
|
||||
/** @type {ChainableSplitterSystem} */
|
||||
chainableSplitter: null,
|
||||
|
||||
/** @type {EnergyGeneratorSystem} */
|
||||
energyGenerator: null,
|
||||
|
||||
@ -90,6 +94,8 @@ export class GameSystemManager {
|
||||
|
||||
add("storage", StorageSystem);
|
||||
|
||||
add("chainableSplitter", ChainableSplitterSystem);
|
||||
|
||||
add("itemProcessor", ItemProcessorSystem);
|
||||
|
||||
add("itemEjector", ItemEjectorSystem);
|
||||
|
||||
33
src/js/game/systems/chainable_splitter.js
Normal file
33
src/js/game/systems/chainable_splitter.js
Normal file
@ -0,0 +1,33 @@
|
||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||
import { ChainableSplitterComponent } from "../components/chainable_splitter";
|
||||
import { Entity } from "../entity";
|
||||
import { DrawParameters } from "../../core/draw_parameters";
|
||||
import { formatBigNumber, lerp } from "../../core/utils";
|
||||
import { Loader } from "../../core/loader";
|
||||
import { enumLayer } from "../root";
|
||||
|
||||
export class ChainableSplitterSystem extends GameSystemWithFilter {
|
||||
constructor(root) {
|
||||
super(root, [ChainableSplitterComponent]);
|
||||
}
|
||||
|
||||
update() {
|
||||
for (let i = 0; i < this.allEntities.length; ++i) {
|
||||
const entity = this.allEntities[i];
|
||||
const splitterComp = entity.components.ChainableSplitter;
|
||||
|
||||
if (splitterComp.inputItem === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const ejectorComp = entity.components.ItemEjector;
|
||||
|
||||
const nextSlot = ejectorComp.getFirstFreeSlot(enumLayer.regular);
|
||||
if (nextSlot !== null) {
|
||||
if (ejectorComp.tryEject(nextSlot, splitterComp.inputItem)) {
|
||||
splitterComp.inputItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user