2021-06-24 16:39:50 +00:00
|
|
|
import { globalConfig } from "../../core/config";
|
2020-08-13 18:30:43 +00:00
|
|
|
import { BaseItem } from "../base_item";
|
2020-08-29 07:35:14 +00:00
|
|
|
import { enumColorMixingResults, enumColors } from "../colors";
|
|
|
|
import {
|
|
|
|
enumItemProcessorRequirements,
|
|
|
|
enumItemProcessorTypes,
|
|
|
|
ItemProcessorComponent,
|
|
|
|
} from "../components/item_processor";
|
2020-05-09 14:45:23 +00:00
|
|
|
import { Entity } from "../entity";
|
|
|
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
import { isTruthyItem } from "../items/boolean_item";
|
2020-08-14 11:09:10 +00:00
|
|
|
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
|
2020-05-17 08:07:20 +00:00
|
|
|
import { ShapeItem } from "../items/shape_item";
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-08-30 13:31:53 +00:00
|
|
|
/**
|
|
|
|
* We need to allow queuing charges, otherwise the throughput will stall
|
|
|
|
*/
|
|
|
|
const MAX_QUEUED_CHARGES = 2;
|
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* Whole data for a produced item
|
|
|
|
*
|
|
|
|
* @typedef {{
|
|
|
|
* item: BaseItem,
|
|
|
|
* preferredSlot?: number,
|
|
|
|
* requiredSlot?: number,
|
|
|
|
* doNotTrack?: boolean
|
|
|
|
* }} ProducedItem
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of a processor implementation
|
|
|
|
* @typedef {{
|
|
|
|
* entity: Entity,
|
2021-08-04 10:49:01 +00:00
|
|
|
* items: Map<number, BaseItem>,
|
|
|
|
* inputCount: number,
|
2020-09-19 15:55:36 +00:00
|
|
|
* outItems: Array<ProducedItem>
|
|
|
|
* }} ProcessorImplementationPayload
|
|
|
|
*/
|
|
|
|
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
/**
|
|
|
|
* @type {Object<string, (ProcessorImplementationPayload) => void>}
|
|
|
|
*/
|
|
|
|
export const MOD_ITEM_PROCESSOR_HANDLERS = {};
|
|
|
|
|
2020-05-09 14:45:23 +00:00
|
|
|
export class ItemProcessorSystem extends GameSystemWithFilter {
|
|
|
|
constructor(root) {
|
|
|
|
super(root, [ItemProcessorComponent]);
|
2020-09-19 15:55:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {Object<enumItemProcessorTypes, function(ProcessorImplementationPayload) : string>}
|
|
|
|
*/
|
|
|
|
this.handlers = {
|
2020-09-22 12:47:59 +00:00
|
|
|
[enumItemProcessorTypes.balancer]: this.process_BALANCER,
|
2020-09-19 15:55:36 +00:00
|
|
|
[enumItemProcessorTypes.cutter]: this.process_CUTTER,
|
|
|
|
[enumItemProcessorTypes.cutterQuad]: this.process_CUTTER_QUAD,
|
|
|
|
[enumItemProcessorTypes.rotater]: this.process_ROTATER,
|
|
|
|
[enumItemProcessorTypes.rotaterCCW]: this.process_ROTATER_CCW,
|
|
|
|
[enumItemProcessorTypes.rotater180]: this.process_ROTATER_180,
|
|
|
|
[enumItemProcessorTypes.stacker]: this.process_STACKER,
|
|
|
|
[enumItemProcessorTypes.trash]: this.process_TRASH,
|
|
|
|
[enumItemProcessorTypes.mixer]: this.process_MIXER,
|
|
|
|
[enumItemProcessorTypes.painter]: this.process_PAINTER,
|
|
|
|
[enumItemProcessorTypes.painterDouble]: this.process_PAINTER_DOUBLE,
|
|
|
|
[enumItemProcessorTypes.painterQuad]: this.process_PAINTER_QUAD,
|
|
|
|
[enumItemProcessorTypes.hub]: this.process_HUB,
|
|
|
|
[enumItemProcessorTypes.reader]: this.process_READER,
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2021-05-23 14:32:05 +00:00
|
|
|
[enumItemProcessorTypes.goal]: this.process_GOAL,
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
...MOD_ITEM_PROCESSOR_HANDLERS,
|
2020-09-19 15:55:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Bind all handlers
|
|
|
|
for (const key in this.handlers) {
|
|
|
|
this.handlers[key] = this.handlers[key].bind(this);
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
|
|
|
for (let i = 0; i < this.allEntities.length; ++i) {
|
|
|
|
const entity = this.allEntities[i];
|
|
|
|
|
|
|
|
const processorComp = entity.components.ItemProcessor;
|
|
|
|
const ejectorComp = entity.components.ItemEjector;
|
|
|
|
|
2020-08-30 13:31:53 +00:00
|
|
|
const currentCharge = processorComp.ongoingCharges[0];
|
2020-08-29 20:35:30 +00:00
|
|
|
|
2020-08-30 13:31:53 +00:00
|
|
|
if (currentCharge) {
|
|
|
|
// Process next charge
|
|
|
|
if (currentCharge.remainingTime > 0.0) {
|
|
|
|
currentCharge.remainingTime -= this.root.dynamicTickrate.deltaSeconds;
|
|
|
|
if (currentCharge.remainingTime < 0.0) {
|
|
|
|
// Add bonus time, this is the time we spent too much
|
|
|
|
processorComp.bonusTime += -currentCharge.remainingTime;
|
|
|
|
}
|
|
|
|
}
|
2020-08-29 20:35:30 +00:00
|
|
|
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
// Check if it finished and we don't already have queued ejects
|
|
|
|
if (currentCharge.remainingTime <= 0.0 && !processorComp.queuedEjects.length) {
|
2020-08-30 13:31:53 +00:00
|
|
|
const itemsToEject = currentCharge.items;
|
2020-05-09 14:45:23 +00:00
|
|
|
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
// Go over all items and add them to the queue
|
2020-08-30 13:31:53 +00:00
|
|
|
for (let j = 0; j < itemsToEject.length; ++j) {
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
processorComp.queuedEjects.push(itemsToEject[j]);
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
2020-08-30 13:31:53 +00:00
|
|
|
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
processorComp.ongoingCharges.shift();
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we have an empty queue and can start a new charge
|
2020-08-30 13:31:53 +00:00
|
|
|
if (processorComp.ongoingCharges.length < MAX_QUEUED_CHARGES) {
|
2020-08-29 07:35:14 +00:00
|
|
|
if (this.canProcess(entity)) {
|
2020-08-11 11:29:47 +00:00
|
|
|
this.startNewCharge(entity);
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
}
|
Mod Support - 1.5.0 Update (#1361)
* initial modloader draft
* modloader features
* Refactor mods to use signals
* Add support for modifying and registering new transltions
* Minor adjustments
* Support for string building ids for mods
* Initial support for adding new buildings
* Refactor how mods are loaded to resolve circular dependencies and prepare for future mod loading
* Lazy Load mods to make sure all dependencies are loaded
* Expose all exported members automatically to mods
* Fix duplicate exports
* Allow loading mods from standalone
* update changelog
* Fix mods folder incorrect path
* Fix modloading in standalone
* Fix sprites not getting replaced, update demo mod
* Load dev mod via raw loader
* Improve mod developing so mods are directly ready to be deployed, load mods from local file server
* Proper mods ui
* Allow mods to register game systems and draw stuff
* Change mods path
* Fix sprites not loading
* Minor adjustments, closes #1333
* Add support for loading atlases via mods
* Add support for loading mods from external sources in DEV
* Add confirmation when loading mods
* Fix circular dependency
* Minor Keybindings refactor, add support for keybindings to mods, add support for dialogs to mods
* Add some mod signals
* refactor game loading states
* Make shapez exports global
* Start to make mods safer
* Refactor file system electron event handling
* Properly isolate electron renderer process
* Update to latest electron
* Show errors when loading mods
* Update confirm dialgo
* Minor restructure, start to add mod examples
* Allow adding custom themesw
* Add more examples and allow defining custom item processor operations
* Add interface to register new buildings
* Fixed typescript type errors (#1335)
* Refactor building registry, make it easier for mods to add new buildings
* Allow overriding existing methods
* Add more examples and more features
* More mod examples
* Make mod loading simpler
* Add example how to add custom drawings
* Remove unused code
* Minor modloader adjustments
* Support for rotation variants in mods (was broken previously)
* Allow mods to replace builtin sub shapes
* Add helper methods to extend classes
* Fix menu bar on mac os
* Remember window state
* Add support for paste signals
* Add example how to add custom components and systems
* Support for mod settings
* Add example for adding a new item type
* Update class extensions
* Minor adjustments
* Fix typo
* Add notification blocks mod example
* Add small tutorial
* Update readme
* Add better instructions
* Update JSDoc for Replacing Methods (#1336)
* upgraded types for overriding methods
* updated comments
Co-authored-by: Edward Badel <you@example.com>
* Direction lock now indicates when there is a building inbetween
* Fix mod examples
* Fix linter error
* Game state register (#1341)
* Added a gamestate register helper
Added a gamestate register helper
* Update mod_interface.js
* export build options
* Fix runBeforeMethod and runAfterMethod
* Minor game system code cleanup
* Belt path drawing optimization
* Fix belt path optimization
* Belt drawing improvements, again
* Do not render belts in statics disabled view
* Allow external URL to load more than one mod (#1337)
* Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
* Update modloader.js
* Prettier fixes
* Added link to create-shapezio-mod npm page (#1339)
Added link to create-shapezio-mod npm page: https://www.npmjs.com/package/create-shapezio-mod
* allow command line switch to load more than one mod (#1342)
* Fixed class handle type (#1345)
* Fixed class handle type
* Fixed import game state
* Minor adjustments
* Refactor item acceptor to allow only single direction slots
* Allow specifying minimumGameVersion
* Add sandbox example
* Replaced concatenated strings with template literals (#1347)
* Mod improvements
* Make wired pins component optional on the storage
* Fix mod examples
* Bind `this` for method overriding JSDoc (#1352)
* fix entity debugger reaching HTML elements (#1353)
* Store mods in savegame and show warning when it differs
* Closes #1357
* Fix All Shapez Exports Being Const (#1358)
* Allowed setting of variables inside webpack modules
* remove console log
* Fix stringification of things inside of eval
Co-authored-by: Edward Badel <you@example.com>
* Fix building placer intersection warning
* Add example for storing data in the savegame
* Fix double painter bug (#1349)
* Add example on how to extend builtin buildings
* update readme
* Disable steam achievements when playing with mods
* Update translations
Co-authored-by: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com>
Co-authored-by: Bagel03 <70449196+Bagel03@users.noreply.github.com>
Co-authored-by: Edward Badel <you@example.com>
Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
Co-authored-by: saile515 <63782477+saile515@users.noreply.github.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2022-02-01 15:35:49 +00:00
|
|
|
|
|
|
|
for (let j = 0; j < processorComp.queuedEjects.length; ++j) {
|
|
|
|
const { item, requiredSlot, preferredSlot } = processorComp.queuedEjects[j];
|
|
|
|
|
|
|
|
assert(ejectorComp, "To eject items, the building needs to have an ejector");
|
|
|
|
|
|
|
|
let slot = null;
|
|
|
|
if (requiredSlot !== null && requiredSlot !== undefined) {
|
|
|
|
// We have a slot override, check if that is free
|
|
|
|
if (ejectorComp.canEjectOnSlot(requiredSlot)) {
|
|
|
|
slot = requiredSlot;
|
|
|
|
}
|
|
|
|
} else if (preferredSlot !== null && preferredSlot !== undefined) {
|
|
|
|
// We have a slot preference, try using it but otherwise use a free slot
|
|
|
|
if (ejectorComp.canEjectOnSlot(preferredSlot)) {
|
|
|
|
slot = preferredSlot;
|
|
|
|
} else {
|
|
|
|
slot = ejectorComp.getFirstFreeSlot();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We can eject on any slot
|
|
|
|
slot = ejectorComp.getFirstFreeSlot();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot !== null) {
|
|
|
|
// Alright, we can actually eject
|
|
|
|
if (!ejectorComp.tryEject(slot, item)) {
|
|
|
|
assert(false, "Failed to eject");
|
|
|
|
} else {
|
|
|
|
processorComp.queuedEjects.splice(j, 1);
|
|
|
|
j -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the entity should accept the given item on the given slot.
|
|
|
|
* This should only be called with matching items! I.e. if a color item is expected
|
|
|
|
* on the given slot, then only a color item must be passed.
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @param {BaseItem} item The item to accept
|
|
|
|
* @param {number} slotIndex The slot index
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
checkRequirements(entity, item, slotIndex) {
|
|
|
|
const itemProcessorComp = entity.components.ItemProcessor;
|
|
|
|
const pinsComp = entity.components.WiredPins;
|
|
|
|
|
|
|
|
switch (itemProcessorComp.processingRequirement) {
|
|
|
|
case enumItemProcessorRequirements.painterQuad: {
|
|
|
|
if (slotIndex === 0) {
|
|
|
|
// Always accept the shape
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the network value at the given slot
|
|
|
|
const network = pinsComp.slots[slotIndex - 1].linkedNetwork;
|
2020-09-19 17:30:04 +00:00
|
|
|
const slotIsEnabled = network && network.hasValue() && isTruthyItem(network.currentValue);
|
2020-08-29 07:35:14 +00:00
|
|
|
if (!slotIsEnabled) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// By default, everything is accepted
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-29 05:56:47 +00:00
|
|
|
/**
|
|
|
|
* Checks whether it's possible to process something
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
canProcess(entity) {
|
2020-08-29 07:35:14 +00:00
|
|
|
const processorComp = entity.components.ItemProcessor;
|
|
|
|
|
|
|
|
switch (processorComp.processingRequirement) {
|
|
|
|
// DEFAULT
|
|
|
|
// By default, we can start processing once all inputs are there
|
|
|
|
case null: {
|
2021-08-04 10:34:15 +00:00
|
|
|
return processorComp.inputCount >= processorComp.inputsPerCharge;
|
2020-08-29 07:35:14 +00:00
|
|
|
}
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
// QUAD PAINTER
|
|
|
|
// For the quad painter, it might be possible to start processing earlier
|
|
|
|
case enumItemProcessorRequirements.painterQuad: {
|
2020-08-29 05:56:47 +00:00
|
|
|
const pinsComp = entity.components.WiredPins;
|
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
// First slot is the shape, so if it's not there we can't do anything
|
2021-08-04 10:49:01 +00:00
|
|
|
const shapeItem = /** @type {ShapeItem} */ (processorComp.inputSlots.get(0));
|
|
|
|
if (!shapeItem) {
|
2020-08-29 07:35:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const slotStatus = [];
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
// Check which slots are enabled
|
2020-08-29 05:56:47 +00:00
|
|
|
for (let i = 0; i < 4; ++i) {
|
2020-08-29 07:35:14 +00:00
|
|
|
// Extract the network value on the Nth pin
|
2020-09-19 17:30:04 +00:00
|
|
|
const network = pinsComp.slots[i].linkedNetwork;
|
|
|
|
const networkValue = network && network.hasValue() ? network.currentValue : null;
|
2020-08-29 07:35:14 +00:00
|
|
|
|
|
|
|
// If there is no "1" on that slot, don't paint there
|
2020-08-29 09:08:30 +00:00
|
|
|
if (!isTruthyItem(networkValue)) {
|
2020-08-29 07:35:14 +00:00
|
|
|
slotStatus.push(false);
|
|
|
|
continue;
|
|
|
|
}
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
slotStatus.push(true);
|
|
|
|
}
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
// All slots are disabled
|
|
|
|
if (!slotStatus.includes(true)) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-08-29 07:35:14 +00:00
|
|
|
// Check if all colors of the enabled slots are there
|
|
|
|
for (let i = 0; i < slotStatus.length; ++i) {
|
2021-08-04 10:49:01 +00:00
|
|
|
if (slotStatus[i] && !processorComp.inputSlots.get(1 + i)) {
|
2020-08-29 07:35:14 +00:00
|
|
|
// A slot which is enabled wasn't enabled. Make sure if there is anything on the quadrant,
|
|
|
|
// it is not possible to paint, but if there is nothing we can ignore it
|
2020-08-29 05:56:47 +00:00
|
|
|
for (let j = 0; j < 4; ++j) {
|
|
|
|
const layer = shapeItem.definition.layers[j];
|
|
|
|
if (layer && layer[i]) {
|
2020-08-29 07:35:14 +00:00
|
|
|
return false;
|
2020-08-29 05:56:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-08-29 07:35:14 +00:00
|
|
|
|
2020-08-29 05:56:47 +00:00
|
|
|
default:
|
2020-08-29 07:35:14 +00:00
|
|
|
assertAlways(false, "Unknown requirement for " + processorComp.processingRequirement);
|
2020-08-29 05:56:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 14:45:23 +00:00
|
|
|
/**
|
|
|
|
* Starts a new charge for the entity
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
startNewCharge(entity) {
|
|
|
|
const processorComp = entity.components.ItemProcessor;
|
|
|
|
|
|
|
|
// First, take items
|
|
|
|
const items = processorComp.inputSlots;
|
2020-05-16 20:45:40 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/** @type {Array<ProducedItem>} */
|
2020-05-09 14:45:23 +00:00
|
|
|
const outItems = [];
|
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/** @type {function(ProcessorImplementationPayload) : void} */
|
|
|
|
const handler = this.handlers[processorComp.type];
|
|
|
|
assert(handler, "No handler for processor type defined: " + processorComp.type);
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
// Call implementation
|
|
|
|
handler({
|
|
|
|
entity,
|
|
|
|
items,
|
|
|
|
outItems,
|
2021-08-04 10:49:01 +00:00
|
|
|
inputCount: processorComp.inputCount,
|
2020-09-19 15:55:36 +00:00
|
|
|
});
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
// Track produced items
|
|
|
|
for (let i = 0; i < outItems.length; ++i) {
|
|
|
|
if (!outItems[i].doNotTrack) {
|
|
|
|
this.root.signals.itemProduced.dispatch(outItems[i].item);
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
2020-09-19 15:55:36 +00:00
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
// Queue Charge
|
|
|
|
const baseSpeed = this.root.hubGoals.getProcessorBaseSpeed(processorComp.type);
|
|
|
|
const originalTime = 1 / baseSpeed;
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
const bonusTimeToApply = Math.min(originalTime, processorComp.bonusTime);
|
|
|
|
const timeToProcess = originalTime - bonusTimeToApply;
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
processorComp.bonusTime -= bonusTimeToApply;
|
|
|
|
processorComp.ongoingCharges.push({
|
|
|
|
items: outItems,
|
|
|
|
remainingTime: timeToProcess,
|
|
|
|
});
|
2021-08-04 10:34:15 +00:00
|
|
|
|
2021-08-04 10:49:01 +00:00
|
|
|
processorComp.inputSlots.clear();
|
2021-08-04 10:34:15 +00:00
|
|
|
processorComp.inputCount = 0;
|
2020-09-19 15:55:36 +00:00
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
2020-09-22 12:47:59 +00:00
|
|
|
process_BALANCER(payload) {
|
2020-09-23 06:59:39 +00:00
|
|
|
assert(
|
|
|
|
payload.entity.components.ItemEjector,
|
|
|
|
"To be a balancer, the building needs to have an ejector"
|
|
|
|
);
|
2020-09-19 15:55:36 +00:00
|
|
|
const availableSlots = payload.entity.components.ItemEjector.slots.length;
|
|
|
|
const processorComp = payload.entity.components.ItemProcessor;
|
|
|
|
|
2021-08-04 10:49:01 +00:00
|
|
|
for (let i = 0; i < 2; ++i) {
|
|
|
|
const item = payload.items.get(i);
|
|
|
|
if (!item) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-19 15:55:36 +00:00
|
|
|
payload.outItems.push({
|
2021-08-04 10:49:01 +00:00
|
|
|
item,
|
2021-08-29 12:43:13 +00:00
|
|
|
preferredSlot: processorComp.nextOutputSlot++ % availableSlots,
|
2020-09-19 15:55:36 +00:00
|
|
|
doNotTrack: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_CUTTER(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const inputItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(inputItem instanceof ShapeItem, "Input for cut is not a shape");
|
|
|
|
const inputDefinition = inputItem.definition;
|
|
|
|
|
|
|
|
const cutDefinitions = this.root.shapeDefinitionMgr.shapeActionCutHalf(inputDefinition);
|
|
|
|
|
2021-08-25 09:56:29 +00:00
|
|
|
const ejectorComp = payload.entity.components.ItemEjector;
|
2020-09-19 15:55:36 +00:00
|
|
|
for (let i = 0; i < cutDefinitions.length; ++i) {
|
|
|
|
const definition = cutDefinitions[i];
|
2021-08-25 09:56:29 +00:00
|
|
|
|
|
|
|
if (definition.isEntirelyEmpty()) {
|
|
|
|
ejectorComp.slots[i].lastItem = null;
|
|
|
|
continue;
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
2021-08-25 09:56:29 +00:00
|
|
|
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(definition),
|
|
|
|
requiredSlot: i,
|
|
|
|
});
|
2020-09-19 15:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_CUTTER_QUAD(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const inputItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(inputItem instanceof ShapeItem, "Input for cut is not a shape");
|
|
|
|
const inputDefinition = inputItem.definition;
|
|
|
|
|
|
|
|
const cutDefinitions = this.root.shapeDefinitionMgr.shapeActionCutQuad(inputDefinition);
|
|
|
|
|
2021-08-25 09:56:29 +00:00
|
|
|
const ejectorComp = payload.entity.components.ItemEjector;
|
2020-09-19 15:55:36 +00:00
|
|
|
for (let i = 0; i < cutDefinitions.length; ++i) {
|
|
|
|
const definition = cutDefinitions[i];
|
2021-08-25 09:56:29 +00:00
|
|
|
|
|
|
|
if (definition.isEntirelyEmpty()) {
|
|
|
|
ejectorComp.slots[i].lastItem = null;
|
|
|
|
continue;
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
2021-08-25 09:56:29 +00:00
|
|
|
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(definition),
|
|
|
|
requiredSlot: i,
|
|
|
|
});
|
2020-09-19 15:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_ROTATER(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const inputItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(inputItem instanceof ShapeItem, "Input for rotation is not a shape");
|
|
|
|
const inputDefinition = inputItem.definition;
|
|
|
|
|
|
|
|
const rotatedDefinition = this.root.shapeDefinitionMgr.shapeActionRotateCW(inputDefinition);
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(rotatedDefinition),
|
|
|
|
});
|
|
|
|
}
|
2020-05-16 20:45:40 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_ROTATER_CCW(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const inputItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(inputItem instanceof ShapeItem, "Input for rotation is not a shape");
|
|
|
|
const inputDefinition = inputItem.definition;
|
|
|
|
|
|
|
|
const rotatedDefinition = this.root.shapeDefinitionMgr.shapeActionRotateCCW(inputDefinition);
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(rotatedDefinition),
|
|
|
|
});
|
|
|
|
}
|
2020-05-16 22:21:33 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_ROTATER_180(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const inputItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(inputItem instanceof ShapeItem, "Input for rotation is not a shape");
|
|
|
|
const inputDefinition = inputItem.definition;
|
|
|
|
|
|
|
|
const rotatedDefinition = this.root.shapeDefinitionMgr.shapeActionRotate180(inputDefinition);
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(rotatedDefinition),
|
|
|
|
});
|
|
|
|
}
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_STACKER(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const lowerItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
|
|
|
const upperItem = /** @type {ShapeItem} */ (payload.items.get(1));
|
2020-09-19 15:55:36 +00:00
|
|
|
|
|
|
|
assert(lowerItem instanceof ShapeItem, "Input for lower stack is not a shape");
|
|
|
|
assert(upperItem instanceof ShapeItem, "Input for upper stack is not a shape");
|
|
|
|
|
|
|
|
const stackedDefinition = this.root.shapeDefinitionMgr.shapeActionStack(
|
|
|
|
lowerItem.definition,
|
|
|
|
upperItem.definition
|
|
|
|
);
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(stackedDefinition),
|
|
|
|
});
|
|
|
|
}
|
2020-08-29 05:56:47 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_TRASH(payload) {
|
|
|
|
// Do nothing ..
|
|
|
|
}
|
2020-05-16 22:21:33 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_MIXER(payload) {
|
|
|
|
// Find both colors and combine them
|
2021-08-04 10:49:01 +00:00
|
|
|
const item1 = /** @type {ColorItem} */ (payload.items.get(0));
|
|
|
|
const item2 = /** @type {ColorItem} */ (payload.items.get(1));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(item1 instanceof ColorItem, "Input for color mixer is not a color");
|
|
|
|
assert(item2 instanceof ColorItem, "Input for color mixer is not a color");
|
|
|
|
|
|
|
|
const color1 = item1.color;
|
|
|
|
const color2 = item2.color;
|
|
|
|
|
|
|
|
// Try finding mixer color, and if we can't mix it we simply return the same color
|
|
|
|
const mixedColor = enumColorMixingResults[color1][color2];
|
|
|
|
let resultColor = color1;
|
|
|
|
if (mixedColor) {
|
|
|
|
resultColor = mixedColor;
|
|
|
|
}
|
|
|
|
payload.outItems.push({
|
|
|
|
item: COLOR_ITEM_SINGLETONS[resultColor],
|
|
|
|
});
|
|
|
|
}
|
2020-05-16 22:21:33 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_PAINTER(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const shapeItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
|
|
|
const colorItem = /** @type {ColorItem} */ (payload.items.get(1));
|
2020-08-13 18:30:43 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
const colorizedDefinition = this.root.shapeDefinitionMgr.shapeActionPaintWith(
|
|
|
|
shapeItem.definition,
|
|
|
|
colorItem.color
|
|
|
|
);
|
2020-08-13 18:30:43 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(colorizedDefinition),
|
|
|
|
});
|
|
|
|
}
|
2020-08-13 18:30:43 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_PAINTER_DOUBLE(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const shapeItem1 = /** @type {ShapeItem} */ (payload.items.get(0));
|
|
|
|
const shapeItem2 = /** @type {ShapeItem} */ (payload.items.get(1));
|
|
|
|
const colorItem = /** @type {ColorItem} */ (payload.items.get(2));
|
2020-09-19 15:55:36 +00:00
|
|
|
|
|
|
|
assert(shapeItem1 instanceof ShapeItem, "Input for painter is not a shape");
|
|
|
|
assert(shapeItem2 instanceof ShapeItem, "Input for painter is not a shape");
|
|
|
|
assert(colorItem instanceof ColorItem, "Input for painter is not a color");
|
|
|
|
|
|
|
|
const colorizedDefinition1 = this.root.shapeDefinitionMgr.shapeActionPaintWith(
|
|
|
|
shapeItem1.definition,
|
|
|
|
colorItem.color
|
|
|
|
);
|
|
|
|
|
|
|
|
const colorizedDefinition2 = this.root.shapeDefinitionMgr.shapeActionPaintWith(
|
|
|
|
shapeItem2.definition,
|
|
|
|
colorItem.color
|
|
|
|
);
|
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(colorizedDefinition1),
|
|
|
|
});
|
2020-08-13 18:30:43 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(colorizedDefinition2),
|
|
|
|
});
|
|
|
|
}
|
2020-08-13 18:30:43 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_PAINTER_QUAD(payload) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const shapeItem = /** @type {ShapeItem} */ (payload.items.get(0));
|
2020-09-19 15:55:36 +00:00
|
|
|
assert(shapeItem instanceof ShapeItem, "Input for painter is not a shape");
|
|
|
|
|
|
|
|
/** @type {Array<enumColors>} */
|
|
|
|
const colors = [null, null, null, null];
|
|
|
|
for (let i = 0; i < 4; ++i) {
|
2021-08-04 10:49:01 +00:00
|
|
|
const colorItem = /** @type {ColorItem} */ (payload.items.get(i + 1));
|
|
|
|
if (colorItem) {
|
|
|
|
colors[i] = colorItem.color;
|
2020-08-29 08:38:23 +00:00
|
|
|
}
|
2020-09-19 15:55:36 +00:00
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
const colorizedDefinition = this.root.shapeDefinitionMgr.shapeActionPaintWith4Colors(
|
|
|
|
shapeItem.definition,
|
|
|
|
/** @type {[string, string, string, string]} */ (colors)
|
|
|
|
);
|
2020-05-18 09:47:17 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
payload.outItems.push({
|
|
|
|
item: this.root.shapeDefinitionMgr.getShapeItemFromDefinition(colorizedDefinition),
|
|
|
|
});
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_READER(payload) {
|
|
|
|
// Pass through the item
|
2021-08-04 10:49:01 +00:00
|
|
|
const item = payload.items.get(0);
|
2020-09-19 15:55:36 +00:00
|
|
|
payload.outItems.push({
|
|
|
|
item,
|
|
|
|
doNotTrack: true,
|
|
|
|
});
|
2020-08-30 13:31:53 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
// Track the item
|
|
|
|
const readerComp = payload.entity.components.BeltReader;
|
|
|
|
readerComp.lastItemTimes.push(this.root.time.now());
|
|
|
|
readerComp.lastItem = item;
|
|
|
|
}
|
2020-08-30 13:31:53 +00:00
|
|
|
|
2020-09-19 15:55:36 +00:00
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_HUB(payload) {
|
|
|
|
const hubComponent = payload.entity.components.Hub;
|
|
|
|
assert(hubComponent, "Hub item processor has no hub component");
|
|
|
|
|
2021-08-04 10:49:01 +00:00
|
|
|
// Hardcoded
|
|
|
|
for (let i = 0; i < payload.inputCount; ++i) {
|
|
|
|
const item = /** @type {ShapeItem} */ (payload.items.get(i));
|
|
|
|
if (!item) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-19 15:55:36 +00:00
|
|
|
this.root.hubGoals.handleDefinitionDelivered(item.definition);
|
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2021-05-23 14:32:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {ProcessorImplementationPayload} payload
|
|
|
|
*/
|
|
|
|
process_GOAL(payload) {
|
|
|
|
const goalComp = payload.entity.components.GoalAcceptor;
|
2021-08-04 10:49:01 +00:00
|
|
|
const item = payload.items.get(0);
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2021-05-23 14:32:05 +00:00
|
|
|
const now = this.root.time.now();
|
|
|
|
|
2021-06-24 16:39:50 +00:00
|
|
|
if (goalComp.item && !item.equals(goalComp.item)) {
|
|
|
|
goalComp.clearItems();
|
|
|
|
} else {
|
|
|
|
goalComp.currentDeliveredItems = Math.min(
|
|
|
|
goalComp.currentDeliveredItems + 1,
|
|
|
|
globalConfig.goalAcceptorItemsRequired
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2021-05-23 14:32:05 +00:00
|
|
|
if (this.root.gameMode.getIsEditor()) {
|
|
|
|
// while playing in editor, assign the item
|
2021-08-04 10:49:01 +00:00
|
|
|
goalComp.item = item;
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2021-05-23 14:32:05 +00:00
|
|
|
}
|
2021-06-24 16:39:50 +00:00
|
|
|
|
|
|
|
goalComp.lastDelivery = {
|
|
|
|
item,
|
|
|
|
time: now,
|
|
|
|
};
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
2021-05-23 14:32:05 +00:00
|
|
|
}
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|