mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-16 03:31:52 +00:00
smash dat bug owo
This commit is contained in:
parent
c8b072c7d9
commit
09186cb647
@ -3,6 +3,7 @@ import { enumDirection, Vector } from "../../core/vector";
|
|||||||
import { ItemAcceptorComponent, enumItemAcceptorItemFilter } from "../components/item_acceptor";
|
import { ItemAcceptorComponent, enumItemAcceptorItemFilter } from "../components/item_acceptor";
|
||||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
import { enumItemProcessorTypes, ItemProcessorComponent } from "../components/item_processor";
|
||||||
|
import { SorterComponent } from "../components/sorter";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { MetaBuilding } from "../meta_building";
|
import { MetaBuilding } from "../meta_building";
|
||||||
import { GameRoot } from "../root";
|
import { GameRoot } from "../root";
|
||||||
@ -51,7 +52,9 @@ export class MetaSorterBuilding extends MetaBuilding {
|
|||||||
processorType: enumItemProcessorTypes.sorter,
|
processorType: enumItemProcessorTypes.sorter,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
entity.addComponent(
|
||||||
|
new SorterComponent({})
|
||||||
|
);
|
||||||
entity.addComponent(
|
entity.addComponent(
|
||||||
new ItemEjectorComponent({
|
new ItemEjectorComponent({
|
||||||
slots: [
|
slots: [
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { gComponentRegistry } from "../core/global_registries";
|
import { gComponentRegistry } from "../core/global_registries";
|
||||||
import { StaticMapEntityComponent } from "./components/static_map_entity";
|
import { StaticMapEntityComponent } from "./components/static_map_entity";
|
||||||
import { BeltComponent } from "./components/belt";
|
import { BeltComponent } from "./components/belt";
|
||||||
|
import { SorterComponent } from "./components/sorter";
|
||||||
import { ItemEjectorComponent } from "./components/item_ejector";
|
import { ItemEjectorComponent } from "./components/item_ejector";
|
||||||
import { ItemAcceptorComponent } from "./components/item_acceptor";
|
import { ItemAcceptorComponent } from "./components/item_acceptor";
|
||||||
import { MinerComponent } from "./components/miner";
|
import { MinerComponent } from "./components/miner";
|
||||||
@ -14,6 +15,7 @@ import { StorageComponent } from "./components/storage";
|
|||||||
export function initComponentRegistry() {
|
export function initComponentRegistry() {
|
||||||
gComponentRegistry.register(StaticMapEntityComponent);
|
gComponentRegistry.register(StaticMapEntityComponent);
|
||||||
gComponentRegistry.register(BeltComponent);
|
gComponentRegistry.register(BeltComponent);
|
||||||
|
gComponentRegistry.register(SorterComponent);
|
||||||
gComponentRegistry.register(ItemEjectorComponent);
|
gComponentRegistry.register(ItemEjectorComponent);
|
||||||
gComponentRegistry.register(ItemAcceptorComponent);
|
gComponentRegistry.register(ItemAcceptorComponent);
|
||||||
gComponentRegistry.register(MinerComponent);
|
gComponentRegistry.register(MinerComponent);
|
||||||
|
|||||||
29
src/js/game/components/sorter.js
Normal file
29
src/js/game/components/sorter.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { Component } from "../component";
|
||||||
|
import { types } from "../../savegame/serialization";
|
||||||
|
import { gItemRegistry } from "../../core/global_registries";
|
||||||
|
import { BaseItem } from "../base_item";
|
||||||
|
import { Vector, enumDirection } from "../../core/vector";
|
||||||
|
import { Math_PI, Math_sin, Math_cos } from "../../core/builtins";
|
||||||
|
import { globalConfig } from "../../core/config";
|
||||||
|
|
||||||
|
export class SorterComponent extends Component {
|
||||||
|
static getId() {
|
||||||
|
return "Sorter";
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSchema() {
|
||||||
|
return {
|
||||||
|
filter: types.string,
|
||||||
|
isfil: types.bool,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
constructor({
|
||||||
|
filter = "CuCuCuXu",
|
||||||
|
isfil = false,
|
||||||
|
}) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.filter = filter;
|
||||||
|
this.isfil = isfil;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
/* typehints:start */
|
/* typehints:start */
|
||||||
import { StaticMapEntityComponent } from "./components/static_map_entity";
|
import { StaticMapEntityComponent } from "./components/static_map_entity";
|
||||||
import { BeltComponent } from "./components/belt";
|
import { BeltComponent } from "./components/belt";
|
||||||
|
import { SorterComponent } from "./components/sorter";
|
||||||
import { ItemEjectorComponent } from "./components/item_ejector";
|
import { ItemEjectorComponent } from "./components/item_ejector";
|
||||||
import { ItemAcceptorComponent } from "./components/item_acceptor";
|
import { ItemAcceptorComponent } from "./components/item_acceptor";
|
||||||
import { MinerComponent } from "./components/miner";
|
import { MinerComponent } from "./components/miner";
|
||||||
@ -29,6 +30,9 @@ export class EntityComponentStorage {
|
|||||||
/** @type {BeltComponent} */
|
/** @type {BeltComponent} */
|
||||||
this.Belt;
|
this.Belt;
|
||||||
|
|
||||||
|
/** @type {SorterComponent} */
|
||||||
|
this.Sorter;
|
||||||
|
|
||||||
/** @type {ItemEjectorComponent} */
|
/** @type {ItemEjectorComponent} */
|
||||||
this.ItemEjector;
|
this.ItemEjector;
|
||||||
|
|
||||||
|
|||||||
@ -123,23 +123,25 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
trackProduction = false;
|
trackProduction = false;
|
||||||
const availableSlots = entity.components.ItemEjector.slots.length - 1;
|
const availableSlots = entity.components.ItemEjector.slots.length - 1;
|
||||||
assert(inputItem instanceof ShapeItem, "Input for sorting is not a shape");
|
assert(inputItem instanceof ShapeItem, "Input for sorting is not a shape");
|
||||||
console.log(inputItem.serialize);
|
if (inputItem.serialize() == entity.components.Sorter.filter && entity.components.Sorter.isfil) {
|
||||||
if (inputItem.serialize() == "CuCuCuCu") {
|
|
||||||
let nextSlot = processorComp.nextOutputSlot++ % availableSlots;
|
let nextSlot = processorComp.nextOutputSlot++ % availableSlots;
|
||||||
for (let i = 0; i < items.length; ++i) {
|
|
||||||
outItems.push({
|
outItems.push({
|
||||||
item: items[i].item,
|
item: inputItem,
|
||||||
requiredSlot: 1,
|
requiredSlot: 1,
|
||||||
});
|
});
|
||||||
}
|
} else if (!entity.components.Sorter.isfil) {
|
||||||
} else {
|
entity.components.Sorter.isfil = true;
|
||||||
for (let i = 0; i < items.length; ++i) {
|
entity.components.Sorter.filter = inputItem.serialize();
|
||||||
outItems.push({
|
outItems.push({
|
||||||
item: items[i].item,
|
item: inputItem,
|
||||||
|
requiredSlot: 1,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
outItems.push({
|
||||||
|
item: inputItem,
|
||||||
requiredSlot: 0,
|
requiredSlot: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user