2020-08-30 15:31:53 +02:00
|
|
|
import { globalConfig } from "../core/config";
|
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 16:35:49 +01:00
|
|
|
import { smoothenDpi } from "../core/dpi_manager";
|
2020-08-30 15:31:53 +02:00
|
|
|
import { DrawParameters } from "../core/draw_parameters";
|
|
|
|
import { createLogger } from "../core/logging";
|
|
|
|
import { Rectangle } from "../core/rectangle";
|
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 16:35:49 +01:00
|
|
|
import { ORIGINAL_SPRITE_SCALE } from "../core/sprites";
|
2020-09-19 10:34:46 +02:00
|
|
|
import { clamp, epsilonCompare, round4Digits } from "../core/utils";
|
2020-08-30 15:31:53 +02:00
|
|
|
import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector } from "../core/vector";
|
|
|
|
import { BasicSerializableObject, types } from "../savegame/serialization";
|
|
|
|
import { BaseItem } from "./base_item";
|
|
|
|
import { Entity } from "./entity";
|
|
|
|
import { typeItemSingleton } from "./item_resolver";
|
|
|
|
import { GameRoot } from "./root";
|
|
|
|
|
|
|
|
const logger = createLogger("belt_path");
|
|
|
|
|
|
|
|
// Helpers for more semantic access into interleaved arrays
|
|
|
|
|
|
|
|
const DEBUG = G_IS_DEV && false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores a path of belts, used for optimizing performance
|
|
|
|
*/
|
|
|
|
export class BeltPath extends BasicSerializableObject {
|
|
|
|
static getId() {
|
|
|
|
return "BeltPath";
|
|
|
|
}
|
|
|
|
|
|
|
|
static getSchema() {
|
|
|
|
return {
|
|
|
|
entityPath: types.array(types.entity),
|
|
|
|
items: types.array(types.pair(types.ufloat, typeItemSingleton)),
|
|
|
|
spacingToFirstItem: types.ufloat,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a path from a serialized object
|
|
|
|
* @param {GameRoot} root
|
|
|
|
* @param {Object} data
|
|
|
|
* @returns {BeltPath|string}
|
|
|
|
*/
|
|
|
|
static fromSerialized(root, data) {
|
|
|
|
// Create fake object which looks like a belt path but skips the constructor
|
|
|
|
const fakeObject = /** @type {BeltPath} */ (Object.create(BeltPath.prototype));
|
|
|
|
fakeObject.root = root;
|
|
|
|
|
|
|
|
// Deserialize the data
|
|
|
|
const errorCodeDeserialize = fakeObject.deserialize(data);
|
|
|
|
if (errorCodeDeserialize) {
|
|
|
|
return errorCodeDeserialize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute other properties
|
|
|
|
fakeObject.init(false);
|
|
|
|
|
|
|
|
return fakeObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {GameRoot} root
|
|
|
|
* @param {Array<Entity>} entityPath
|
|
|
|
*/
|
|
|
|
constructor(root, entityPath) {
|
|
|
|
super();
|
|
|
|
this.root = root;
|
|
|
|
|
|
|
|
assert(entityPath.length > 0, "invalid entity path");
|
|
|
|
this.entityPath = entityPath;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the items sorted, and their distance to the previous item (or start)
|
|
|
|
* Layout: [distanceToNext, item]
|
|
|
|
* @type {Array<[number, BaseItem]>}
|
|
|
|
*/
|
|
|
|
this.items = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the spacing to the first item
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.init();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("constructor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Initializes the path by computing the properties which are not saved
|
|
|
|
* @param {boolean} computeSpacing Whether to also compute the spacing
|
|
|
|
*/
|
|
|
|
init(computeSpacing = true) {
|
|
|
|
this.onPathChanged();
|
|
|
|
|
|
|
|
this.totalLength = this.computeTotalLength();
|
|
|
|
|
|
|
|
if (computeSpacing) {
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current bounds of this path
|
|
|
|
* @type {Rectangle}
|
|
|
|
*/
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
// Connect the belts
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
this.entityPath[i].components.Belt.assignedPath = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 16:32:05 +02:00
|
|
|
/**
|
|
|
|
* Clears all items
|
|
|
|
*/
|
|
|
|
clearAllItems() {
|
|
|
|
this.items = [];
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
this.numCompressedItemsAfterFirstItem = 0;
|
|
|
|
}
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
/**
|
|
|
|
* Returns whether this path can accept a new item
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
canAcceptItem() {
|
|
|
|
return this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to accept the item
|
|
|
|
* @param {BaseItem} item
|
|
|
|
*/
|
|
|
|
tryAcceptItem(item) {
|
|
|
|
if (this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts) {
|
|
|
|
// So, since we already need one tick to accept this item we will add this directly.
|
|
|
|
const beltProgressPerTick =
|
|
|
|
this.root.hubGoals.getBeltBaseSpeed() *
|
|
|
|
this.root.dynamicTickrate.deltaSeconds *
|
|
|
|
globalConfig.itemSpacingOnBelts;
|
|
|
|
|
|
|
|
// First, compute how much progress we can make *at max*
|
|
|
|
const maxProgress = Math.max(0, this.spacingToFirstItem - globalConfig.itemSpacingOnBelts);
|
|
|
|
const initialProgress = Math.min(maxProgress, beltProgressPerTick);
|
|
|
|
|
|
|
|
this.items.unshift([this.spacingToFirstItem - initialProgress, item]);
|
|
|
|
this.spacingToFirstItem = initialProgress;
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("accept-item");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SLOW / Tries to find the item closest to the given tile
|
|
|
|
* @param {Vector} tile
|
|
|
|
* @returns {BaseItem|null}
|
|
|
|
*/
|
|
|
|
findItemAtTile(tile) {
|
|
|
|
// @TODO: This breaks color blind mode otherwise
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the tile bounds of the path
|
|
|
|
* @returns {Rectangle}
|
|
|
|
*/
|
|
|
|
computeBounds() {
|
|
|
|
let bounds = this.entityPath[0].components.StaticMapEntity.getTileSpaceBounds();
|
|
|
|
for (let i = 1; i < this.entityPath.length; ++i) {
|
|
|
|
const staticComp = this.entityPath[i].components.StaticMapEntity;
|
|
|
|
const otherBounds = staticComp.getTileSpaceBounds();
|
|
|
|
bounds = bounds.getUnion(otherBounds);
|
|
|
|
}
|
|
|
|
return bounds.allScaled(globalConfig.tileSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recomputes cache variables once the path was changed
|
|
|
|
*/
|
|
|
|
onPathChanged() {
|
2022-06-20 10:21:13 +02:00
|
|
|
this.boundAcceptor = this.computeAcceptingEntityAndSlot().acceptor;
|
2020-09-21 18:09:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* How many items past the first item are compressed
|
|
|
|
*/
|
|
|
|
this.numCompressedItemsAfterFirstItem = 0;
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by the belt system when the surroundings changed
|
|
|
|
*/
|
|
|
|
onSurroundingsChanged() {
|
|
|
|
this.onPathChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds the entity which accepts our items
|
2020-09-21 18:07:47 +02:00
|
|
|
* @param {boolean=} debug_Silent Whether debug output should be silent
|
2022-06-20 10:21:13 +02:00
|
|
|
* @return { { acceptor?: (BaseItem, number?) => boolean, entity?: Entity } }
|
2020-08-30 15:31:53 +02:00
|
|
|
*/
|
2020-09-21 18:07:47 +02:00
|
|
|
computeAcceptingEntityAndSlot(debug_Silent = false) {
|
|
|
|
DEBUG && !debug_Silent && logger.log("Recomputing acceptor target");
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
const lastEntity = this.entityPath[this.entityPath.length - 1];
|
|
|
|
const lastStatic = lastEntity.components.StaticMapEntity;
|
|
|
|
const lastBeltComp = lastEntity.components.Belt;
|
|
|
|
|
|
|
|
// Figure out where and into which direction we eject items
|
|
|
|
const ejectSlotWsTile = lastStatic.localTileToWorld(new Vector(0, 0));
|
|
|
|
const ejectSlotWsDirection = lastStatic.localDirectionToWorld(lastBeltComp.direction);
|
|
|
|
const ejectSlotWsDirectionVector = enumDirectionToVector[ejectSlotWsDirection];
|
|
|
|
const ejectSlotTargetWsTile = ejectSlotWsTile.add(ejectSlotWsDirectionVector);
|
|
|
|
|
|
|
|
// Try to find the given acceptor component to take the item
|
|
|
|
const targetEntity = this.root.map.getLayerContentXY(
|
|
|
|
ejectSlotTargetWsTile.x,
|
|
|
|
ejectSlotTargetWsTile.y,
|
|
|
|
"regular"
|
|
|
|
);
|
|
|
|
|
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 16:32:05 +02:00
|
|
|
if (!targetEntity) {
|
2022-06-20 10:21:13 +02:00
|
|
|
return {};
|
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 16:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const noSimplifiedBelts = !this.root.app.settings.getAllSettings().simplifiedBelts;
|
2020-08-30 15:31:53 +02: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 16:32:05 +02:00
|
|
|
DEBUG && !debug_Silent && logger.log(" Found target entity", targetEntity.uid);
|
|
|
|
const targetStaticComp = targetEntity.components.StaticMapEntity;
|
|
|
|
const targetBeltComp = targetEntity.components.Belt;
|
|
|
|
|
|
|
|
// Check for belts (special case)
|
|
|
|
if (targetBeltComp) {
|
|
|
|
const beltAcceptingDirection = targetStaticComp.localDirectionToWorld(enumDirection.top);
|
|
|
|
DEBUG &&
|
|
|
|
!debug_Silent &&
|
|
|
|
logger.log(
|
|
|
|
" Entity is accepting items from",
|
|
|
|
ejectSlotWsDirection,
|
|
|
|
"vs",
|
|
|
|
beltAcceptingDirection,
|
|
|
|
"Rotation:",
|
|
|
|
targetStaticComp.rotation
|
|
|
|
);
|
|
|
|
if (ejectSlotWsDirection === beltAcceptingDirection) {
|
2022-06-20 10:21:13 +02:00
|
|
|
return {
|
|
|
|
entity: targetEntity,
|
|
|
|
acceptor: item => {
|
|
|
|
const path = targetBeltComp.assignedPath;
|
|
|
|
assert(path, "belt has no path");
|
|
|
|
return path.tryAcceptItem(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 16:32:05 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for item acceptors
|
|
|
|
const targetAcceptorComp = targetEntity.components.ItemAcceptor;
|
|
|
|
if (!targetAcceptorComp) {
|
|
|
|
// Entity doesn't accept items
|
2022-06-20 10:21:13 +02:00
|
|
|
return {};
|
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 16:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const ejectingDirection = targetStaticComp.worldDirectionToLocal(ejectSlotWsDirection);
|
|
|
|
const matchingSlot = targetAcceptorComp.findMatchingSlot(
|
|
|
|
targetStaticComp.worldToLocalTile(ejectSlotTargetWsTile),
|
|
|
|
ejectingDirection
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!matchingSlot) {
|
|
|
|
// No matching slot found
|
2022-06-20 10:21:13 +02:00
|
|
|
return {};
|
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 16:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const matchingSlotIndex = matchingSlot.index;
|
|
|
|
const passOver = this.computePassOverFunctionWithoutBelts(targetEntity, matchingSlotIndex);
|
|
|
|
if (!passOver) {
|
2022-06-20 10:21:13 +02:00
|
|
|
return {};
|
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 16:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const matchingDirection = enumInvertedDirections[ejectingDirection];
|
|
|
|
const filter = matchingSlot.slot.filter;
|
|
|
|
|
2022-06-20 10:21:13 +02:00
|
|
|
return {
|
|
|
|
entity: targetEntity,
|
|
|
|
acceptor: function (item, remainingProgress = 0.0) {
|
|
|
|
// Check if the acceptor has a filter
|
|
|
|
if (filter && item._type !== filter) {
|
|
|
|
return false;
|
|
|
|
}
|
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 16:32:05 +02:00
|
|
|
|
2022-06-20 10:21:13 +02:00
|
|
|
// Try to pass over
|
|
|
|
if (passOver(item, matchingSlotIndex)) {
|
|
|
|
// Trigger animation on the acceptor comp
|
|
|
|
if (noSimplifiedBelts) {
|
|
|
|
targetAcceptorComp.onItemAccepted(
|
|
|
|
matchingSlotIndex,
|
|
|
|
matchingDirection,
|
|
|
|
item,
|
|
|
|
remainingProgress
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return true;
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
2022-06-20 10:21:13 +02:00
|
|
|
return false;
|
|
|
|
},
|
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 16:32:05 +02:00
|
|
|
};
|
|
|
|
}
|
2020-08-30 15:31:53 +02: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 16:32:05 +02:00
|
|
|
/**
|
|
|
|
* Computes a method to pass over the item to the entity
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @param {number} matchingSlotIndex
|
|
|
|
* @returns {(item: BaseItem, slotIndex: number) => boolean | void}
|
|
|
|
*/
|
|
|
|
computePassOverFunctionWithoutBelts(entity, matchingSlotIndex) {
|
|
|
|
const systems = this.root.systemMgr.systems;
|
|
|
|
const hubGoals = this.root.hubGoals;
|
|
|
|
|
|
|
|
// NOTICE: THIS IS COPIED FROM THE ITEM EJECTOR SYSTEM FOR PEROFMANCE REASONS
|
|
|
|
|
|
|
|
const itemProcessorComp = entity.components.ItemProcessor;
|
|
|
|
if (itemProcessorComp) {
|
|
|
|
// Its an item processor ..
|
|
|
|
return function (item) {
|
|
|
|
// Check for potential filters
|
|
|
|
if (!systems.itemProcessor.checkRequirements(entity, item, matchingSlotIndex)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return itemProcessorComp.tryTakeItem(item, matchingSlotIndex);
|
|
|
|
};
|
|
|
|
}
|
2020-08-30 15:31:53 +02: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 16:32:05 +02:00
|
|
|
const undergroundBeltComp = entity.components.UndergroundBelt;
|
|
|
|
if (undergroundBeltComp) {
|
|
|
|
// Its an underground belt. yay.
|
|
|
|
return function (item) {
|
|
|
|
return undergroundBeltComp.tryAcceptExternalItem(
|
|
|
|
item,
|
|
|
|
hubGoals.getUndergroundBeltBaseSpeed()
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
2020-08-30 15:31:53 +02: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 16:32:05 +02:00
|
|
|
const storageComp = entity.components.Storage;
|
|
|
|
if (storageComp) {
|
|
|
|
// It's a storage
|
|
|
|
return function (item) {
|
|
|
|
if (storageComp.canAcceptItem(item)) {
|
|
|
|
storageComp.takeItem(item);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2020-08-30 15:31:53 +02: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 16:32:05 +02:00
|
|
|
const filterComp = entity.components.Filter;
|
|
|
|
if (filterComp) {
|
|
|
|
// It's a filter! Unfortunately the filter has to know a lot about it's
|
|
|
|
// surrounding state and components, so it can't be within the component itself.
|
|
|
|
return function (item) {
|
|
|
|
if (systems.filter.tryAcceptItem(entity, matchingSlotIndex, item)) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-08-30 15:31:53 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Following code will be compiled out outside of dev versions
|
|
|
|
/* dev:start */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to throw an error on mismatch
|
|
|
|
* @param {string} change
|
|
|
|
* @param {Array<any>} reason
|
|
|
|
*/
|
|
|
|
debug_failIntegrity(change, ...reason) {
|
|
|
|
throw new Error("belt path invalid (" + change + "): " + reason.map(i => "" + i).join(" "));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if this path is valid
|
|
|
|
*/
|
|
|
|
debug_checkIntegrity(currentChange = "change") {
|
|
|
|
const fail = (...args) => this.debug_failIntegrity(currentChange, ...args);
|
|
|
|
|
|
|
|
// Check for empty path
|
|
|
|
if (this.entityPath.length === 0) {
|
|
|
|
return fail("Belt path is empty");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for mismatching length
|
|
|
|
const totalLength = this.computeTotalLength();
|
|
|
|
if (!epsilonCompare(this.totalLength, totalLength, 0.01)) {
|
|
|
|
return this.debug_failIntegrity(
|
|
|
|
currentChange,
|
|
|
|
"Total length mismatch, stored =",
|
|
|
|
this.totalLength,
|
|
|
|
"but correct is",
|
|
|
|
totalLength
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for misconnected entities
|
|
|
|
for (let i = 0; i < this.entityPath.length - 1; ++i) {
|
|
|
|
const entity = this.entityPath[i];
|
|
|
|
if (entity.destroyed) {
|
|
|
|
return fail("Reference to destroyed entity " + entity.uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
const followUp = this.root.systemMgr.systems.belt.findFollowUpEntity(entity);
|
|
|
|
if (!followUp) {
|
|
|
|
return fail(
|
|
|
|
"Follow up entity for the",
|
|
|
|
i,
|
|
|
|
"-th entity (total length",
|
|
|
|
this.entityPath.length,
|
|
|
|
") was null!"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (followUp !== this.entityPath[i + 1]) {
|
|
|
|
return fail(
|
|
|
|
"Follow up entity mismatch, stored is",
|
|
|
|
this.entityPath[i + 1].uid,
|
|
|
|
"but real one is",
|
|
|
|
followUp.uid
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (entity.components.Belt.assignedPath !== this) {
|
|
|
|
return fail(
|
|
|
|
"Entity with uid",
|
|
|
|
entity.uid,
|
|
|
|
"doesn't have this path assigned, but this path contains the entity."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check spacing
|
|
|
|
if (this.spacingToFirstItem > this.totalLength + 0.005) {
|
|
|
|
return fail(
|
|
|
|
currentChange,
|
|
|
|
"spacing to first item (",
|
|
|
|
this.spacingToFirstItem,
|
|
|
|
") is greater than total length (",
|
|
|
|
this.totalLength,
|
|
|
|
")"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check distance if empty
|
|
|
|
if (this.items.length === 0 && !epsilonCompare(this.spacingToFirstItem, this.totalLength, 0.01)) {
|
|
|
|
return fail(
|
|
|
|
currentChange,
|
|
|
|
"Path is empty but spacing to first item (",
|
|
|
|
this.spacingToFirstItem,
|
|
|
|
") does not equal total length (",
|
|
|
|
this.totalLength,
|
|
|
|
")"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check items etc
|
|
|
|
let currentPos = this.spacingToFirstItem;
|
|
|
|
for (let i = 0; i < this.items.length; ++i) {
|
|
|
|
const item = this.items[i];
|
|
|
|
|
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 16:32:05 +02:00
|
|
|
if (item[0 /* nextDistance */] < 0 || item[0 /* nextDistance */] > this.totalLength + 0.02) {
|
2020-08-30 15:31:53 +02:00
|
|
|
return fail(
|
|
|
|
"Item has invalid offset to next 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 16:32:05 +02:00
|
|
|
item[0 /* nextDistance */],
|
2020-08-30 15:31:53 +02:00
|
|
|
"(total length:",
|
|
|
|
this.totalLength,
|
|
|
|
")"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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 16:32:05 +02:00
|
|
|
currentPos += item[0 /* nextDistance */];
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check the total sum matches
|
|
|
|
if (!epsilonCompare(currentPos, this.totalLength, 0.01)) {
|
|
|
|
return fail(
|
|
|
|
"total sum (",
|
|
|
|
currentPos,
|
|
|
|
") of first item spacing (",
|
|
|
|
this.spacingToFirstItem,
|
|
|
|
") and items does not match total length (",
|
|
|
|
this.totalLength,
|
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 16:32:05 +02:00
|
|
|
") -> items: " + this.items.map(i => i[0 /* nextDistance */]).join("|")
|
2020-08-30 15:31:53 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check bounds
|
|
|
|
const actualBounds = this.computeBounds();
|
|
|
|
if (!actualBounds.equalsEpsilon(this.worldBounds, 0.01)) {
|
|
|
|
return fail("Bounds are stale");
|
|
|
|
}
|
2020-09-21 18:07:47 +02:00
|
|
|
|
|
|
|
// Check acceptor
|
2022-06-20 10:21:13 +02:00
|
|
|
const acceptor = this.computeAcceptingEntityAndSlot(true).acceptor;
|
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 16:32:05 +02:00
|
|
|
if (!!acceptor !== !!this.boundAcceptor) {
|
|
|
|
return fail("Acceptor target mismatch, acceptor", !!acceptor, "vs stored", !!this.boundAcceptor);
|
2020-09-21 18:07:47 +02:00
|
|
|
}
|
2020-09-21 18:09:27 +02:00
|
|
|
|
|
|
|
// Check first nonzero offset
|
|
|
|
let firstNonzero = 0;
|
|
|
|
for (let i = this.items.length - 2; i >= 0; --i) {
|
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 16:32:05 +02:00
|
|
|
if (this.items[i][0 /* nextDistance */] < globalConfig.itemSpacingOnBelts + 1e-5) {
|
2020-09-21 18:09:27 +02:00
|
|
|
++firstNonzero;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Should warn, but this check isn't actually accurate
|
|
|
|
// if (firstNonzero !== this.numCompressedItemsAfterFirstItem) {
|
|
|
|
// console.warn(
|
|
|
|
// "First nonzero index is " +
|
|
|
|
// firstNonzero +
|
|
|
|
// " but stored is " +
|
|
|
|
// this.numCompressedItemsAfterFirstItem
|
|
|
|
// );
|
|
|
|
// }
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dev:end */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extends the belt path by the given belt
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
extendOnEnd(entity) {
|
|
|
|
DEBUG && logger.log("Extending belt path by entity at", entity.components.StaticMapEntity.origin);
|
|
|
|
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
|
|
|
|
// Append the entity
|
|
|
|
this.entityPath.push(entity);
|
|
|
|
this.onPathChanged();
|
|
|
|
|
|
|
|
// Extend the path length
|
|
|
|
const additionalLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
this.totalLength += additionalLength;
|
|
|
|
DEBUG && logger.log(" Extended total length by", additionalLength, "to", this.totalLength);
|
|
|
|
|
|
|
|
// If we have no item, just update the distance to the first item
|
|
|
|
if (this.items.length === 0) {
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
DEBUG && logger.log(" Extended spacing to first to", this.totalLength, "(= total length)");
|
|
|
|
} else {
|
|
|
|
// Otherwise, update the next-distance of the last item
|
|
|
|
const lastItem = this.items[this.items.length - 1];
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" Extended spacing of last item from",
|
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 16:32:05 +02:00
|
|
|
lastItem[0 /* nextDistance */],
|
2020-08-30 15:31:53 +02:00
|
|
|
"to",
|
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 16:32:05 +02:00
|
|
|
lastItem[0 /* nextDistance */] + additionalLength
|
2020-08-30 15:31:53 +02: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 16:32:05 +02:00
|
|
|
lastItem[0 /* nextDistance */] += additionalLength;
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assign reference
|
|
|
|
beltComp.assignedPath = this;
|
|
|
|
|
|
|
|
// Update bounds
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("extend-on-end");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extends the path with the given entity on the beginning
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
extendOnBeginning(entity) {
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
|
|
|
|
DEBUG && logger.log("Extending the path on the beginning");
|
|
|
|
|
|
|
|
// All items on that belt are simply lost (for now)
|
|
|
|
|
|
|
|
const length = beltComp.getEffectiveLengthTiles();
|
|
|
|
|
|
|
|
// Extend the length of this path
|
|
|
|
this.totalLength += length;
|
|
|
|
|
|
|
|
// Simply adjust the first item spacing cuz we have no items contained
|
|
|
|
this.spacingToFirstItem += length;
|
|
|
|
|
|
|
|
// Set handles and append entity
|
|
|
|
beltComp.assignedPath = this;
|
|
|
|
this.entityPath.unshift(entity);
|
|
|
|
this.onPathChanged();
|
|
|
|
|
|
|
|
// Update bounds
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("extend-on-begin");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the given entity is the end entity of the path
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isEndEntity(entity) {
|
|
|
|
return this.entityPath[this.entityPath.length - 1] === entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the given entity is the start entity of the path
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isStartEntity(entity) {
|
|
|
|
return this.entityPath[0] === entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Splits this path at the given entity by removing it, and
|
|
|
|
* returning the new secondary paht
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @returns {BeltPath}
|
|
|
|
*/
|
|
|
|
deleteEntityOnPathSplitIntoTwo(entity) {
|
|
|
|
DEBUG && logger.log("Splitting path at entity", entity.components.StaticMapEntity.origin);
|
|
|
|
|
|
|
|
// First, find where the current path ends
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
beltComp.assignedPath = null;
|
|
|
|
|
|
|
|
const entityLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
assert(this.entityPath.indexOf(entity) >= 0, "Entity not contained for split");
|
|
|
|
assert(this.entityPath.indexOf(entity) !== 0, "Entity is first");
|
|
|
|
assert(this.entityPath.indexOf(entity) !== this.entityPath.length - 1, "Entity is last");
|
|
|
|
|
|
|
|
let firstPathEntityCount = 0;
|
|
|
|
let firstPathLength = 0;
|
|
|
|
let firstPathEndEntity = null;
|
|
|
|
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
const otherEntity = this.entityPath[i];
|
|
|
|
if (otherEntity === entity) {
|
|
|
|
DEBUG && logger.log("Found entity at", i, "of length", firstPathLength);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++firstPathEntityCount;
|
|
|
|
firstPathEndEntity = otherEntity;
|
|
|
|
firstPathLength += otherEntity.components.Belt.getEffectiveLengthTiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"First path ends at",
|
|
|
|
firstPathLength,
|
|
|
|
"and entity",
|
|
|
|
firstPathEndEntity.components.StaticMapEntity.origin,
|
|
|
|
"and has",
|
|
|
|
firstPathEntityCount,
|
|
|
|
"entities"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Compute length of second path
|
|
|
|
const secondPathLength = this.totalLength - firstPathLength - entityLength;
|
|
|
|
const secondPathStart = firstPathLength + entityLength;
|
|
|
|
const secondEntities = this.entityPath.splice(firstPathEntityCount + 1);
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Second path starts at",
|
|
|
|
secondPathStart,
|
|
|
|
"and has a length of ",
|
|
|
|
secondPathLength,
|
|
|
|
"with",
|
|
|
|
secondEntities.length,
|
|
|
|
"entities"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Remove the last item
|
|
|
|
this.entityPath.pop();
|
|
|
|
|
|
|
|
DEBUG && logger.log("Splitting", this.items.length, "items");
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Old items are",
|
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 16:32:05 +02:00
|
|
|
this.items.map(i => i[0 /* nextDistance */])
|
2020-08-30 15:31:53 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Create second path
|
|
|
|
const secondPath = new BeltPath(this.root, secondEntities);
|
|
|
|
|
|
|
|
// Remove all items which are no longer relevant and transfer them to the second path
|
|
|
|
let itemPos = this.spacingToFirstItem;
|
|
|
|
for (let i = 0; i < this.items.length; ++i) {
|
|
|
|
const item = this.items[i];
|
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 16:32:05 +02:00
|
|
|
const distanceToNext = item[0 /* nextDistance */];
|
2020-08-30 15:31:53 +02:00
|
|
|
|
|
|
|
DEBUG && logger.log(" Checking item at", itemPos, "with distance of", distanceToNext, "to next");
|
|
|
|
|
|
|
|
// Check if this item is past the first path
|
|
|
|
if (itemPos >= firstPathLength) {
|
|
|
|
// Remove it from the first path
|
|
|
|
this.items.splice(i, 1);
|
|
|
|
i -= 1;
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(" Removed item from first path since its no longer contained @", itemPos);
|
|
|
|
|
|
|
|
// Check if its on the second path (otherwise its on the removed belt and simply lost)
|
|
|
|
if (itemPos >= secondPathStart) {
|
|
|
|
// Put item on second path
|
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 16:32:05 +02:00
|
|
|
secondPath.items.push([distanceToNext, item[1 /* item */]]);
|
2020-08-30 15:31:53 +02:00
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" Put item to second path @",
|
|
|
|
itemPos,
|
|
|
|
"with distance to next =",
|
|
|
|
distanceToNext
|
|
|
|
);
|
|
|
|
|
|
|
|
// If it was the first item, adjust the distance to the first item
|
|
|
|
if (secondPath.items.length === 1) {
|
|
|
|
DEBUG && logger.log(" Sinc it was the first, set sapcing of first to", itemPos);
|
|
|
|
secondPath.spacingToFirstItem = itemPos - secondPathStart;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DEBUG && logger.log(" Item was on the removed belt, so its gone - forever!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Seems this item is on the first path (so all good), so just make sure it doesn't
|
|
|
|
// have a nextDistance which is bigger than the total path length
|
|
|
|
const clampedDistanceToNext = Math.min(itemPos + distanceToNext, firstPathLength) - itemPos;
|
|
|
|
if (clampedDistanceToNext < distanceToNext) {
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Correcting next distance (first path) from",
|
|
|
|
distanceToNext,
|
|
|
|
"to",
|
|
|
|
clampedDistanceToNext
|
|
|
|
);
|
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 16:32:05 +02:00
|
|
|
item[0 /* nextDistance */] = clampedDistanceToNext;
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advance items
|
|
|
|
itemPos += distanceToNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"New items are",
|
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 16:32:05 +02:00
|
|
|
this.items.map(i => i[0 /* nextDistance */])
|
2020-08-30 15:31:53 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"And second path items are",
|
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 16:32:05 +02:00
|
|
|
secondPath.items.map(i => i[0 /* nextDistance */])
|
2020-08-30 15:31:53 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Adjust our total length
|
|
|
|
this.totalLength = firstPathLength;
|
|
|
|
|
|
|
|
// Make sure that if we are empty, we set our first distance properly
|
|
|
|
if (this.items.length === 0) {
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.onPathChanged();
|
|
|
|
secondPath.onPathChanged();
|
|
|
|
|
|
|
|
// Update bounds
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("split-two-first");
|
|
|
|
secondPath.debug_checkIntegrity("split-two-second");
|
|
|
|
}
|
|
|
|
|
|
|
|
return secondPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes the last entity
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
deleteEntityOnEnd(entity) {
|
|
|
|
assert(
|
|
|
|
this.entityPath[this.entityPath.length - 1] === entity,
|
|
|
|
"Not actually the last entity (instead " + this.entityPath.indexOf(entity) + ")"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Ok, first remove the entity
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
const beltLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Deleting last entity on path with length",
|
|
|
|
this.entityPath.length,
|
|
|
|
"(reducing",
|
|
|
|
this.totalLength,
|
|
|
|
" by",
|
|
|
|
beltLength,
|
|
|
|
")"
|
|
|
|
);
|
|
|
|
this.totalLength -= beltLength;
|
|
|
|
this.entityPath.pop();
|
|
|
|
this.onPathChanged();
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" New path has length of",
|
|
|
|
this.totalLength,
|
|
|
|
"with",
|
|
|
|
this.entityPath.length,
|
|
|
|
"entities"
|
|
|
|
);
|
|
|
|
|
|
|
|
// This is just for sanity
|
|
|
|
beltComp.assignedPath = null;
|
|
|
|
|
|
|
|
// Clean up items
|
|
|
|
if (this.items.length === 0) {
|
|
|
|
// Simple case with no items, just update the first item spacing
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
} else {
|
|
|
|
// Ok, make sure we simply drop all items which are no longer contained
|
|
|
|
let itemOffset = this.spacingToFirstItem;
|
|
|
|
let lastItemOffset = itemOffset;
|
|
|
|
|
|
|
|
DEBUG && logger.log(" Adjusting", this.items.length, "items");
|
|
|
|
|
|
|
|
for (let i = 0; i < this.items.length; ++i) {
|
|
|
|
const item = this.items[i];
|
|
|
|
|
|
|
|
// Get rid of items past this path
|
|
|
|
if (itemOffset >= this.totalLength) {
|
|
|
|
DEBUG && logger.log("Dropping item (current index=", i, ")");
|
|
|
|
this.items.splice(i, 1);
|
|
|
|
i -= 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
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 16:32:05 +02:00
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Item",
|
|
|
|
i,
|
|
|
|
"is at",
|
|
|
|
itemOffset,
|
|
|
|
"with next offset",
|
|
|
|
item[0 /* nextDistance */]
|
|
|
|
);
|
2020-08-30 15:31:53 +02:00
|
|
|
lastItemOffset = itemOffset;
|
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 16:32:05 +02:00
|
|
|
itemOffset += item[0 /* nextDistance */];
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we still have an item, make sure the last item matches
|
|
|
|
if (this.items.length > 0) {
|
|
|
|
// We can easily compute the next distance since we know where the last item is now
|
|
|
|
const lastDistance = this.totalLength - lastItemOffset;
|
|
|
|
assert(
|
|
|
|
lastDistance >= 0.0,
|
|
|
|
"Last item distance mismatch: " +
|
|
|
|
lastDistance +
|
|
|
|
" -> Total length was " +
|
|
|
|
this.totalLength +
|
|
|
|
" and lastItemOffset was " +
|
|
|
|
lastItemOffset
|
|
|
|
);
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Adjusted distance of last item: it is at",
|
|
|
|
lastItemOffset,
|
|
|
|
"so it has a distance of",
|
|
|
|
lastDistance,
|
|
|
|
"to the end (",
|
|
|
|
this.totalLength,
|
|
|
|
")"
|
|
|
|
);
|
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 16:32:05 +02:00
|
|
|
this.items[this.items.length - 1][0 /* nextDistance */] = lastDistance;
|
2020-08-30 15:31:53 +02:00
|
|
|
} else {
|
|
|
|
DEBUG && logger.log(" Removed all items so we'll update spacing to total length");
|
|
|
|
|
|
|
|
// We removed all items so update our spacing
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update bounds
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("delete-on-end");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes the entity of the start of the path
|
|
|
|
* @see deleteEntityOnEnd
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
deleteEntityOnStart(entity) {
|
|
|
|
assert(
|
|
|
|
entity === this.entityPath[0],
|
|
|
|
"Not actually the start entity (instead " + this.entityPath.indexOf(entity) + ")"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Ok, first remove the entity
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
const beltLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
"Deleting first entity on path with length",
|
|
|
|
this.entityPath.length,
|
|
|
|
"(reducing",
|
|
|
|
this.totalLength,
|
|
|
|
" by",
|
|
|
|
beltLength,
|
|
|
|
")"
|
|
|
|
);
|
|
|
|
this.totalLength -= beltLength;
|
|
|
|
this.entityPath.shift();
|
|
|
|
this.onPathChanged();
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" New path has length of",
|
|
|
|
this.totalLength,
|
|
|
|
"with",
|
|
|
|
this.entityPath.length,
|
|
|
|
"entities"
|
|
|
|
);
|
|
|
|
|
|
|
|
// This is just for sanity
|
|
|
|
beltComp.assignedPath = null;
|
|
|
|
|
|
|
|
// Clean up items
|
|
|
|
if (this.items.length === 0) {
|
|
|
|
// Simple case with no items, just update the first item spacing
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
} else {
|
|
|
|
// Simple case, we had no item on the beginning -> all good
|
|
|
|
if (this.spacingToFirstItem >= beltLength) {
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" No item on the first place, so we can just adjust the spacing (spacing=",
|
|
|
|
this.spacingToFirstItem,
|
|
|
|
") removed =",
|
|
|
|
beltLength
|
|
|
|
);
|
|
|
|
this.spacingToFirstItem -= beltLength;
|
|
|
|
} else {
|
|
|
|
// Welp, okay we need to drop all items which are < beltLength and adjust
|
|
|
|
// the other item offsets as well
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" We have at least one item in the beginning, drop those and adjust spacing (first item @",
|
|
|
|
this.spacingToFirstItem,
|
|
|
|
") since we removed",
|
|
|
|
beltLength,
|
|
|
|
"length from path"
|
|
|
|
);
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" Items:",
|
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 16:32:05 +02:00
|
|
|
this.items.map(i => i[0 /* nextDistance */])
|
2020-08-30 15:31:53 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Find offset to first item
|
|
|
|
let itemOffset = this.spacingToFirstItem;
|
|
|
|
for (let i = 0; i < this.items.length; ++i) {
|
|
|
|
const item = this.items[i];
|
|
|
|
if (itemOffset <= beltLength) {
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" -> Dropping item with index",
|
|
|
|
i,
|
|
|
|
"at",
|
|
|
|
itemOffset,
|
|
|
|
"since it was on the removed belt"
|
|
|
|
);
|
|
|
|
// This item must be dropped
|
|
|
|
this.items.splice(i, 1);
|
|
|
|
i -= 1;
|
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 16:32:05 +02:00
|
|
|
itemOffset += item[0 /* nextDistance */];
|
2020-08-30 15:31:53 +02:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
// This item can be kept, thus its the first we know
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.items.length > 0) {
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" Offset of first non-dropped item was at:",
|
|
|
|
itemOffset,
|
|
|
|
"-> setting spacing to it (total length=",
|
|
|
|
this.totalLength,
|
|
|
|
")"
|
|
|
|
);
|
|
|
|
|
|
|
|
this.spacingToFirstItem = itemOffset - beltLength;
|
|
|
|
assert(
|
|
|
|
this.spacingToFirstItem >= 0.0,
|
|
|
|
"Invalid spacing after delete on start: " + this.spacingToFirstItem
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
DEBUG && logger.log(" We dropped all items, simply set spacing to total length");
|
|
|
|
// We dropped all items, simple one
|
|
|
|
this.spacingToFirstItem = this.totalLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update bounds
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("delete-on-start");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extends the path by the given other path
|
|
|
|
* @param {BeltPath} otherPath
|
|
|
|
*/
|
|
|
|
extendByPath(otherPath) {
|
|
|
|
assert(otherPath !== this, "Circular path dependency");
|
|
|
|
|
|
|
|
const entities = otherPath.entityPath;
|
|
|
|
DEBUG && logger.log("Extending path by other path, starting to add entities");
|
|
|
|
|
|
|
|
const oldLength = this.totalLength;
|
|
|
|
|
|
|
|
DEBUG && logger.log(" Adding", entities.length, "new entities, current length =", this.totalLength);
|
|
|
|
|
|
|
|
// First, append entities
|
|
|
|
for (let i = 0; i < entities.length; ++i) {
|
|
|
|
const entity = entities[i];
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
|
|
|
|
// Add to path and update references
|
|
|
|
this.entityPath.push(entity);
|
|
|
|
beltComp.assignedPath = this;
|
|
|
|
|
|
|
|
// Update our length
|
|
|
|
const additionalLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
this.totalLength += additionalLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" Path is now",
|
|
|
|
this.entityPath.length,
|
|
|
|
"entities and has a length of",
|
|
|
|
this.totalLength
|
|
|
|
);
|
|
|
|
|
|
|
|
// Now, update the distance of our last item
|
|
|
|
if (this.items.length !== 0) {
|
|
|
|
const lastItem = this.items[this.items.length - 1];
|
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 16:32:05 +02:00
|
|
|
lastItem[0 /* nextDistance */] += otherPath.spacingToFirstItem;
|
2020-08-30 15:31:53 +02:00
|
|
|
DEBUG &&
|
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 16:32:05 +02:00
|
|
|
logger.log(
|
|
|
|
" Add distance to last item, effectively being",
|
|
|
|
lastItem[0 /* nextDistance */],
|
|
|
|
"now"
|
|
|
|
);
|
2020-08-30 15:31:53 +02:00
|
|
|
} else {
|
|
|
|
// Seems we have no items, update our first item distance
|
|
|
|
this.spacingToFirstItem = oldLength + otherPath.spacingToFirstItem;
|
|
|
|
DEBUG &&
|
|
|
|
logger.log(
|
|
|
|
" We had no items, so our new spacing to first is old length (",
|
|
|
|
oldLength,
|
|
|
|
") plus others spacing to first (",
|
|
|
|
otherPath.spacingToFirstItem,
|
|
|
|
") =",
|
|
|
|
this.spacingToFirstItem
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG && logger.log(" Pushing", otherPath.items.length, "items from other path");
|
|
|
|
|
|
|
|
// Aaand push the other paths items
|
|
|
|
for (let i = 0; i < otherPath.items.length; ++i) {
|
|
|
|
const item = otherPath.items[i];
|
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 16:32:05 +02:00
|
|
|
this.items.push([item[0 /* nextDistance */], item[1 /* item */]]);
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update bounds
|
|
|
|
this.worldBounds = this.computeBounds();
|
|
|
|
|
|
|
|
this.onPathChanged();
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("extend-by-path");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the total length of the path
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
|
|
|
computeTotalLength() {
|
|
|
|
let length = 0;
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
const entity = this.entityPath[i];
|
|
|
|
length += entity.components.Belt.getEffectiveLengthTiles();
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs one tick
|
|
|
|
*/
|
|
|
|
update() {
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("pre-update");
|
|
|
|
}
|
|
|
|
|
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 16:32:05 +02:00
|
|
|
// Skip empty belts
|
|
|
|
if (this.items.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
// Divide by item spacing on belts since we use throughput and not speed
|
|
|
|
let beltSpeed =
|
|
|
|
this.root.hubGoals.getBeltBaseSpeed() *
|
|
|
|
this.root.dynamicTickrate.deltaSeconds *
|
|
|
|
globalConfig.itemSpacingOnBelts;
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.instantBelts) {
|
|
|
|
beltSpeed *= 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store whether this is the first item we processed, so premature
|
|
|
|
// item ejection is available
|
|
|
|
let isFirstItemProcessed = true;
|
|
|
|
|
|
|
|
// Store how much velocity (strictly its distance, not velocity) we have to distribute over all items
|
|
|
|
let remainingVelocity = beltSpeed;
|
|
|
|
|
2020-09-21 18:09:27 +02:00
|
|
|
// Store the last item we processed, so we can skip clashed ones
|
|
|
|
let lastItemProcessed;
|
|
|
|
|
|
|
|
for (lastItemProcessed = this.items.length - 1; lastItemProcessed >= 0; --lastItemProcessed) {
|
|
|
|
const nextDistanceAndItem = this.items[lastItemProcessed];
|
2020-08-30 15:31:53 +02:00
|
|
|
|
|
|
|
// Compute how much spacing we need at least
|
2020-09-21 18:09:27 +02:00
|
|
|
const minimumSpacing =
|
|
|
|
lastItemProcessed === this.items.length - 1 ? 0 : globalConfig.itemSpacingOnBelts;
|
2020-08-30 15:31:53 +02:00
|
|
|
|
|
|
|
// Compute how much we can advance
|
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 16:32:05 +02:00
|
|
|
let clampedProgress = nextDistanceAndItem[0 /* nextDistance */] - minimumSpacing;
|
|
|
|
|
|
|
|
// Make sure we don't advance more than the remaining velocity has stored
|
|
|
|
if (remainingVelocity < clampedProgress) {
|
|
|
|
clampedProgress = remainingVelocity;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we don't advance back
|
|
|
|
if (clampedProgress < 0) {
|
|
|
|
clampedProgress = 0;
|
|
|
|
}
|
2020-08-30 15:31:53 +02:00
|
|
|
|
|
|
|
// Reduce our velocity by the amount we consumed
|
|
|
|
remainingVelocity -= clampedProgress;
|
|
|
|
|
|
|
|
// Reduce the spacing
|
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 16:32:05 +02:00
|
|
|
nextDistanceAndItem[0 /* nextDistance */] -= clampedProgress;
|
2020-08-30 15:31:53 +02:00
|
|
|
|
2020-12-07 19:15:57 +01:00
|
|
|
// Advance all items behind by the progress we made
|
|
|
|
this.spacingToFirstItem += clampedProgress;
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
// If the last item can be ejected, eject it and reduce the spacing, because otherwise
|
|
|
|
// we lose velocity
|
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 16:32:05 +02:00
|
|
|
if (isFirstItemProcessed && nextDistanceAndItem[0 /* nextDistance */] < 1e-7) {
|
2020-08-30 15:31:53 +02:00
|
|
|
// Store how much velocity we "lost" because we bumped the item to the end of the
|
|
|
|
// belt but couldn't move it any farther. We need this to tell the item acceptor
|
|
|
|
// animation to start a tad later, so everything matches up. Yes I'm a perfectionist.
|
|
|
|
const excessVelocity = beltSpeed - clampedProgress;
|
|
|
|
|
|
|
|
// Try to directly get rid of the 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 16:32:05 +02:00
|
|
|
if (
|
|
|
|
this.boundAcceptor &&
|
|
|
|
this.boundAcceptor(nextDistanceAndItem[1 /* item */], excessVelocity)
|
|
|
|
) {
|
2020-08-30 15:31:53 +02:00
|
|
|
this.items.pop();
|
2020-09-21 18:09:27 +02:00
|
|
|
|
2020-12-07 19:15:57 +01:00
|
|
|
const itemBehind = this.items[lastItemProcessed - 1];
|
|
|
|
if (itemBehind && this.numCompressedItemsAfterFirstItem > 0) {
|
|
|
|
// So, with the next tick we will skip this item, but it actually has the potential
|
|
|
|
// to process farther -> If we don't advance here, we loose a tiny bit of progress
|
|
|
|
// every tick which causes the belt to be slower than it actually is.
|
|
|
|
// Also see #999
|
|
|
|
const fixupProgress = Math.max(
|
|
|
|
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 16:32:05 +02:00
|
|
|
Math.min(remainingVelocity, itemBehind[0 /* nextDistance */])
|
2020-12-07 19:15:57 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// See above
|
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 16:32:05 +02:00
|
|
|
itemBehind[0 /* nextDistance */] -= fixupProgress;
|
2020-12-07 19:15:57 +01:00
|
|
|
remainingVelocity -= fixupProgress;
|
|
|
|
this.spacingToFirstItem += fixupProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reduce the number of compressed items since the first item no longer exists
|
2020-09-21 18:09:27 +02:00
|
|
|
this.numCompressedItemsAfterFirstItem = Math.max(
|
|
|
|
0,
|
|
|
|
this.numCompressedItemsAfterFirstItem - 1
|
|
|
|
);
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 18:09:27 +02:00
|
|
|
if (isFirstItemProcessed) {
|
|
|
|
// Skip N null items after first items
|
|
|
|
lastItemProcessed -= this.numCompressedItemsAfterFirstItem;
|
|
|
|
}
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
isFirstItemProcessed = false;
|
2020-10-07 19:31:11 +02:00
|
|
|
if (remainingVelocity < 1e-7) {
|
2020-08-30 15:31:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 18:09:27 +02:00
|
|
|
// Compute compressed item count
|
|
|
|
this.numCompressedItemsAfterFirstItem = Math.max(
|
|
|
|
0,
|
|
|
|
this.numCompressedItemsAfterFirstItem,
|
|
|
|
this.items.length - 2 - lastItemProcessed
|
|
|
|
);
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
// Check if we have an item which is ready to be emitted
|
|
|
|
const lastItem = this.items[this.items.length - 1];
|
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 16:32:05 +02:00
|
|
|
if (lastItem && lastItem[0 /* nextDistance */] === 0) {
|
|
|
|
if (this.boundAcceptor && this.boundAcceptor(lastItem[1 /* item */])) {
|
2020-08-30 15:31:53 +02:00
|
|
|
this.items.pop();
|
2020-09-21 18:09:27 +02:00
|
|
|
this.numCompressedItemsAfterFirstItem = Math.max(
|
|
|
|
0,
|
|
|
|
this.numCompressedItemsAfterFirstItem - 1
|
|
|
|
);
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
|
|
|
|
this.debug_checkIntegrity("post-update");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes a world space position from the given progress
|
|
|
|
* @param {number} progress
|
|
|
|
* @returns {Vector}
|
|
|
|
*/
|
|
|
|
computePositionFromProgress(progress) {
|
|
|
|
let currentLength = 0;
|
|
|
|
|
2020-09-19 07:49:17 +02:00
|
|
|
// floating point issues ..
|
2020-08-30 15:31:53 +02:00
|
|
|
assert(progress <= this.totalLength + 0.02, "Progress too big: " + progress);
|
|
|
|
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
const beltComp = this.entityPath[i].components.Belt;
|
|
|
|
const localLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
|
|
|
|
if (currentLength + localLength >= progress || i === this.entityPath.length - 1) {
|
|
|
|
// Min required here due to floating point issues
|
|
|
|
const localProgress = Math.min(1.0, progress - currentLength);
|
|
|
|
|
|
|
|
assert(localProgress >= 0.0, "Invalid local progress: " + localProgress);
|
|
|
|
const localSpace = beltComp.transformBeltToLocalSpace(localProgress);
|
|
|
|
return this.entityPath[i].components.StaticMapEntity.localTileToWorld(localSpace);
|
|
|
|
}
|
|
|
|
currentLength += localLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(false, "invalid progress: " + progress + " (max: " + this.totalLength + ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
*/
|
|
|
|
drawDebug(parameters) {
|
|
|
|
if (!parameters.visibleRect.containsRect(this.worldBounds)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters.context.fillStyle = "#d79a25";
|
|
|
|
parameters.context.strokeStyle = "#d79a25";
|
|
|
|
parameters.context.beginPath();
|
|
|
|
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
const entity = this.entityPath[i];
|
|
|
|
const pos = entity.components.StaticMapEntity;
|
|
|
|
const worldPos = pos.origin.toWorldSpaceCenterOfTile();
|
|
|
|
|
|
|
|
if (i === 0) {
|
|
|
|
parameters.context.moveTo(worldPos.x, worldPos.y);
|
|
|
|
} else {
|
|
|
|
parameters.context.lineTo(worldPos.x, worldPos.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parameters.context.stroke();
|
|
|
|
|
|
|
|
// Items
|
|
|
|
let progress = this.spacingToFirstItem;
|
|
|
|
for (let i = 0; i < this.items.length; ++i) {
|
|
|
|
const nextDistanceAndItem = this.items[i];
|
|
|
|
const worldPos = this.computePositionFromProgress(progress).toWorldSpaceCenterOfTile();
|
|
|
|
parameters.context.fillStyle = "#268e4d";
|
|
|
|
parameters.context.beginRoundedRect(worldPos.x - 5, worldPos.y - 5, 10, 10, 3);
|
|
|
|
parameters.context.fill();
|
|
|
|
parameters.context.font = "6px GameFont";
|
|
|
|
parameters.context.fillStyle = "#111";
|
|
|
|
parameters.context.fillText(
|
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 16:32:05 +02:00
|
|
|
"" + round4Digits(nextDistanceAndItem[0 /* nextDistance */]),
|
2020-08-30 15:31:53 +02:00
|
|
|
worldPos.x + 5,
|
|
|
|
worldPos.y + 2
|
|
|
|
);
|
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 16:32:05 +02:00
|
|
|
progress += nextDistanceAndItem[0 /* nextDistance */];
|
2020-09-21 18:09:27 +02:00
|
|
|
|
|
|
|
if (this.items.length - 1 - this.numCompressedItemsAfterFirstItem === i) {
|
|
|
|
parameters.context.fillStyle = "red";
|
|
|
|
parameters.context.fillRect(worldPos.x + 5, worldPos.y, 20, 3);
|
|
|
|
}
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
const entity = this.entityPath[i];
|
|
|
|
parameters.context.fillStyle = "#d79a25";
|
|
|
|
const pos = entity.components.StaticMapEntity;
|
|
|
|
const worldPos = pos.origin.toWorldSpaceCenterOfTile();
|
|
|
|
parameters.context.beginCircle(worldPos.x, worldPos.y, i === 0 ? 5 : 3);
|
|
|
|
parameters.context.fill();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let progress = 0; progress <= this.totalLength + 0.01; progress += 0.2) {
|
|
|
|
const worldPos = this.computePositionFromProgress(progress).toWorldSpaceCenterOfTile();
|
|
|
|
parameters.context.fillStyle = "red";
|
|
|
|
parameters.context.beginCircle(worldPos.x, worldPos.y, 1);
|
|
|
|
parameters.context.fill();
|
|
|
|
}
|
|
|
|
|
|
|
|
const firstItemIndicator = this.computePositionFromProgress(
|
|
|
|
this.spacingToFirstItem
|
|
|
|
).toWorldSpaceCenterOfTile();
|
|
|
|
parameters.context.fillStyle = "purple";
|
|
|
|
parameters.context.fillRect(firstItemIndicator.x - 3, firstItemIndicator.y - 1, 6, 2);
|
|
|
|
}
|
|
|
|
|
2020-09-19 10:34:46 +02:00
|
|
|
/**
|
|
|
|
* Checks if this belt path should render simplified
|
|
|
|
*/
|
|
|
|
checkIsPotatoMode() {
|
|
|
|
// POTATO Mode: Only show items when belt is hovered
|
|
|
|
if (!this.root.app.settings.getAllSettings().simplifiedBelts) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-19 14:48:48 +02:00
|
|
|
if (this.root.currentLayer !== "regular") {
|
|
|
|
// Not in regular layer
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-19 10:34:46 +02:00
|
|
|
const mousePos = this.root.app.mousePosition;
|
|
|
|
if (!mousePos) {
|
|
|
|
// Mouse not registered
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const tile = this.root.camera.screenToWorld(mousePos).toTileSpace();
|
|
|
|
const contents = this.root.map.getLayerContentXY(tile.x, tile.y, "regular");
|
|
|
|
if (!contents || !contents.components.Belt) {
|
|
|
|
// Nothing below
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contents.components.Belt.assignedPath !== this) {
|
|
|
|
// Not this path
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
/**
|
|
|
|
* Draws the path
|
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
*/
|
|
|
|
draw(parameters) {
|
|
|
|
if (!parameters.visibleRect.containsRect(this.worldBounds)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.items.length === 0) {
|
|
|
|
// Early out
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-19 10:34:46 +02:00
|
|
|
if (this.checkIsPotatoMode()) {
|
|
|
|
const firstItem = this.items[0];
|
|
|
|
if (this.entityPath.length > 1 && firstItem) {
|
|
|
|
const medianBeltIndex = clamp(
|
|
|
|
Math.round(this.entityPath.length / 2 - 1),
|
|
|
|
0,
|
|
|
|
this.entityPath.length - 1
|
|
|
|
);
|
|
|
|
const medianBelt = this.entityPath[medianBeltIndex];
|
2020-09-19 10:45:55 +02:00
|
|
|
const beltComp = medianBelt.components.Belt;
|
2020-09-19 10:34:46 +02:00
|
|
|
const staticComp = medianBelt.components.StaticMapEntity;
|
2020-09-19 10:45:55 +02:00
|
|
|
const centerPosLocal = beltComp.transformBeltToLocalSpace(
|
|
|
|
this.entityPath.length % 2 === 0 ? beltComp.getEffectiveLengthTiles() : 0.5
|
2020-09-19 10:34:46 +02:00
|
|
|
);
|
|
|
|
const centerPos = staticComp.localTileToWorld(centerPosLocal).toWorldSpaceCenterOfTile();
|
|
|
|
|
|
|
|
parameters.context.globalAlpha = 0.5;
|
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 16:32:05 +02:00
|
|
|
firstItem[1 /* item */].drawItemCenteredClipped(centerPos.x, centerPos.y, parameters);
|
2020-09-19 10:34:46 +02:00
|
|
|
parameters.context.globalAlpha = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
let currentItemPos = this.spacingToFirstItem;
|
|
|
|
let currentItemIndex = 0;
|
|
|
|
|
|
|
|
let trackPos = 0.0;
|
|
|
|
|
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 16:35:49 +01:00
|
|
|
/**
|
|
|
|
* @type {Array<[Vector, BaseItem]>}
|
|
|
|
*/
|
|
|
|
let drawStack = [];
|
|
|
|
let drawStackProp = "";
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
// Iterate whole track and check items
|
|
|
|
for (let i = 0; i < this.entityPath.length; ++i) {
|
|
|
|
const entity = this.entityPath[i];
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
const beltLength = beltComp.getEffectiveLengthTiles();
|
|
|
|
|
|
|
|
// Check if the current items are on the belt
|
|
|
|
while (trackPos + beltLength >= currentItemPos - 1e-5) {
|
2020-09-19 07:49:17 +02:00
|
|
|
// It's on the belt, render it now
|
2020-08-30 15:31:53 +02:00
|
|
|
const staticComp = entity.components.StaticMapEntity;
|
|
|
|
assert(
|
|
|
|
currentItemPos - trackPos >= 0,
|
|
|
|
"invalid track pos: " + currentItemPos + " vs " + trackPos + " (l =" + beltLength + ")"
|
|
|
|
);
|
|
|
|
|
|
|
|
const localPos = beltComp.transformBeltToLocalSpace(currentItemPos - trackPos);
|
|
|
|
const worldPos = staticComp.localTileToWorld(localPos).toWorldSpaceCenterOfTile();
|
|
|
|
|
|
|
|
const distanceAndItem = this.items[currentItemIndex];
|
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 16:35:49 +01:00
|
|
|
const item = distanceAndItem[1 /* item */];
|
|
|
|
const nextItemDistance = distanceAndItem[0 /* nextDistance */];
|
2020-08-30 15:31:53 +02: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 16:35:49 +01:00
|
|
|
if (
|
|
|
|
!parameters.visibleRect.containsCircle(
|
|
|
|
worldPos.x,
|
|
|
|
worldPos.y,
|
|
|
|
globalConfig.defaultItemDiameter
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
// this one isn't visible, do not append it
|
|
|
|
// Start a new stack
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
|
|
|
drawStack = [];
|
|
|
|
drawStackProp = "";
|
|
|
|
} else {
|
|
|
|
if (drawStack.length > 1) {
|
|
|
|
// Check if we can append to the stack, since its already a stack of two same items
|
|
|
|
const referenceItem = drawStack[0];
|
2022-02-01 17:04:43 +01:00
|
|
|
|
|
|
|
if (
|
|
|
|
referenceItem[1].equals(item) &&
|
|
|
|
Math.abs(referenceItem[0][drawStackProp] - worldPos[drawStackProp]) < 0.001
|
|
|
|
) {
|
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 16:35:49 +01:00
|
|
|
// Will continue stack
|
|
|
|
} else {
|
|
|
|
// Start a new stack, since item doesn't follow in row
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
|
|
|
drawStack = [];
|
|
|
|
drawStackProp = "";
|
|
|
|
}
|
|
|
|
} else if (drawStack.length === 1) {
|
|
|
|
const firstItem = drawStack[0];
|
|
|
|
|
|
|
|
// Check if we can make it a stack
|
|
|
|
if (firstItem[1 /* item */].equals(item)) {
|
|
|
|
// Same item, check if it is either horizontal or vertical
|
|
|
|
const startPos = firstItem[0 /* pos */];
|
|
|
|
|
|
|
|
if (Math.abs(startPos.x - worldPos.x) < 0.001) {
|
|
|
|
drawStackProp = "x";
|
|
|
|
} else if (Math.abs(startPos.y - worldPos.y) < 0.001) {
|
|
|
|
drawStackProp = "y";
|
|
|
|
} else {
|
|
|
|
// Start a new stack
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
|
|
|
drawStack = [];
|
|
|
|
drawStackProp = "";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Start a new stack, since item doesn't equal
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
|
|
|
drawStack = [];
|
|
|
|
drawStackProp = "";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// First item of stack, do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
drawStack.push([worldPos, item]);
|
|
|
|
}
|
2020-08-30 15:31:53 +02:00
|
|
|
|
|
|
|
// Check for the next item
|
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 16:35:49 +01:00
|
|
|
currentItemPos += nextItemDistance;
|
2020-08-30 15:31:53 +02:00
|
|
|
++currentItemIndex;
|
|
|
|
|
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 16:35:49 +01:00
|
|
|
if (
|
|
|
|
nextItemDistance > globalConfig.itemSpacingOnBelts + 0.001 ||
|
|
|
|
drawStack.length > globalConfig.maxBeltShapeBundleSize
|
|
|
|
) {
|
|
|
|
// If next item is not directly following, abort drawing
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
|
|
|
drawStack = [];
|
|
|
|
drawStackProp = "";
|
|
|
|
}
|
|
|
|
|
2020-08-30 15:31:53 +02:00
|
|
|
if (currentItemIndex >= this.items.length) {
|
|
|
|
// We rendered all items
|
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 16:35:49 +01:00
|
|
|
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
2020-08-30 15:31:53 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trackPos += beltLength;
|
|
|
|
}
|
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 16:35:49 +01:00
|
|
|
|
|
|
|
this.drawDrawStack(drawStack, parameters, drawStackProp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {HTMLCanvasElement} canvas
|
|
|
|
* @param {CanvasRenderingContext2D} context
|
|
|
|
* @param {number} w
|
|
|
|
* @param {number} h
|
|
|
|
* @param {number} dpi
|
|
|
|
* @param {object} param0
|
|
|
|
* @param {string} param0.direction
|
|
|
|
* @param {Array<[Vector, BaseItem]>} param0.stack
|
|
|
|
* @param {GameRoot} param0.root
|
|
|
|
* @param {number} param0.zoomLevel
|
|
|
|
*/
|
|
|
|
drawShapesInARow(canvas, context, w, h, dpi, { direction, stack, root, zoomLevel }) {
|
|
|
|
context.scale(dpi, dpi);
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.showShapeGrouping) {
|
|
|
|
context.fillStyle = "rgba(0, 0, 255, 0.5)";
|
|
|
|
context.fillRect(0, 0, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
const parameters = new DrawParameters({
|
|
|
|
context,
|
|
|
|
desiredAtlasScale: ORIGINAL_SPRITE_SCALE,
|
|
|
|
root,
|
|
|
|
visibleRect: new Rectangle(-1000, -1000, 2000, 2000),
|
|
|
|
zoomLevel,
|
|
|
|
});
|
|
|
|
|
|
|
|
const itemSize = globalConfig.itemSpacingOnBelts * globalConfig.tileSize;
|
|
|
|
const item = stack[0];
|
|
|
|
const pos = new Vector(itemSize / 2, itemSize / 2);
|
|
|
|
|
|
|
|
for (let i = 0; i < stack.length; i++) {
|
|
|
|
item[1].drawItemCenteredClipped(pos.x, pos.y, parameters, globalConfig.defaultItemDiameter);
|
|
|
|
pos[direction] += globalConfig.itemSpacingOnBelts * globalConfig.tileSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Array<[Vector, BaseItem]>} stack
|
|
|
|
* @param {DrawParameters} parameters
|
|
|
|
*/
|
|
|
|
drawDrawStack(stack, parameters, directionProp) {
|
|
|
|
if (stack.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const firstItem = stack[0];
|
|
|
|
const firstItemPos = firstItem[0];
|
|
|
|
if (stack.length === 1) {
|
|
|
|
firstItem[1].drawItemCenteredClipped(
|
|
|
|
firstItemPos.x,
|
|
|
|
firstItemPos.y,
|
|
|
|
parameters,
|
|
|
|
globalConfig.defaultItemDiameter
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const itemSize = globalConfig.itemSpacingOnBelts * globalConfig.tileSize;
|
|
|
|
const inverseDirection = directionProp === "x" ? "y" : "x";
|
|
|
|
|
|
|
|
const dimensions = new Vector(itemSize, itemSize);
|
|
|
|
dimensions[inverseDirection] *= stack.length;
|
|
|
|
|
|
|
|
const directionVector = firstItemPos.copy().sub(stack[1][0]);
|
|
|
|
|
|
|
|
const dpi = smoothenDpi(globalConfig.shapesSharpness * parameters.zoomLevel);
|
|
|
|
|
|
|
|
const sprite = this.root.buffers.getForKey({
|
|
|
|
key: "beltpaths",
|
2022-02-22 16:37:55 +01:00
|
|
|
subKey:
|
|
|
|
"stack-" +
|
|
|
|
directionProp +
|
|
|
|
"-" +
|
|
|
|
dpi +
|
|
|
|
"#" +
|
|
|
|
stack.length +
|
|
|
|
"#" +
|
|
|
|
firstItem[1].getItemType() +
|
|
|
|
"#" +
|
|
|
|
firstItem[1].serialize(),
|
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 16:35:49 +01:00
|
|
|
dpi,
|
|
|
|
w: dimensions.x,
|
|
|
|
h: dimensions.y,
|
|
|
|
redrawMethod: this.drawShapesInARow.bind(this),
|
|
|
|
additionalParams: {
|
|
|
|
direction: inverseDirection,
|
|
|
|
stack,
|
|
|
|
root: this.root,
|
|
|
|
zoomLevel: parameters.zoomLevel,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const anchor = directionVector[inverseDirection] < 0 ? firstItem : stack[stack.length - 1];
|
|
|
|
|
|
|
|
parameters.context.drawImage(
|
|
|
|
sprite,
|
|
|
|
anchor[0].x - itemSize / 2,
|
|
|
|
anchor[0].y - itemSize / 2,
|
|
|
|
dimensions.x,
|
|
|
|
dimensions.y
|
|
|
|
);
|
2020-08-30 15:31:53 +02:00
|
|
|
}
|
|
|
|
}
|