From 64b2cea19f29f0d99a9b94564b6c7303e35596de Mon Sep 17 00:00:00 2001 From: Exund Date: Sat, 12 Sep 2020 00:50:24 +0200 Subject: [PATCH] Internal test mod update --- src/js/GeoZ/mod_processor.js | 3 +- src/js/GeoZ/mods/test/test.mod.js | 58 +++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/js/GeoZ/mod_processor.js b/src/js/GeoZ/mod_processor.js index 5173122a..b337a173 100644 --- a/src/js/GeoZ/mod_processor.js +++ b/src/js/GeoZ/mod_processor.js @@ -35,8 +35,7 @@ export class ModProcessor { * @returns {Boolean} */ static canProcess(entity) { - abstract; - return false; + return true; } /** diff --git a/src/js/GeoZ/mods/test/test.mod.js b/src/js/GeoZ/mods/test/test.mod.js index 3ee41242..6d70e3a9 100644 --- a/src/js/GeoZ/mods/test/test.mod.js +++ b/src/js/GeoZ/mods/test/test.mod.js @@ -1,6 +1,12 @@ import * as GeoZ from "../../main"; -import { Vector } from "../../../core/vector"; +import { Vector, enumDirection } from "../../../core/vector"; import { Entity } from "../../../game/entity"; +import { ModProcessor, ProcessorParameters } from "../../mod_processor"; +import { ShapeItem } from "../../../game/items/shape_item"; +import { ShapeDefinition } from "../../../game/shape_definition"; +import { ItemProcessorComponent } from "../../../game/components/item_processor"; +import { ItemEjectorComponent } from "../../../game/components/item_ejector"; +import { ItemAcceptorComponent } from "../../../game/components/item_acceptor"; class MetaTestBuilding extends GeoZ.MetaModBuilding { static getId() { @@ -55,13 +61,61 @@ class MetaTestBuilding extends GeoZ.MetaModBuilding { }; } - setupEntityComponents() {} + /** + * Creates the entity at the given location + * @param {Entity} entity + */ + setupEntityComponents(entity) { + entity.addComponent( + new ItemProcessorComponent({ + inputsPerCharge: 1, + processorType: SquareConverter.getType(), + }) + ); + + entity.addComponent( + new ItemEjectorComponent({ + slots: [{ pos: new Vector(0, 0), direction: enumDirection.top }], + }) + ); + entity.addComponent( + new ItemAcceptorComponent({ + slots: [ + { + pos: new Vector(0, 0), + directions: [enumDirection.bottom], + filter: "shape", + }, + ], + }) + ); + } +} + +class SquareConverter extends ModProcessor { + /** + * @returns {Number} + */ + static getBaseSpeed() { + return 0.5; + } + + /** + * Process ther current item + * @param {ProcessorParameters} param0 + * @returns {Boolean} Whether to track the production towards the analytics + */ + static process({ outItems }) { + outItems.push({ item: new ShapeItem(ShapeDefinition.fromShortKey("SuSuSuSu")) }); + return true; + } } /**@type {GeoZ.Mod}*/ const test = { name: "test", buildings: [MetaTestBuilding], + processors: [SquareConverter], shapes: [ { id: "leaf",