|
|
|
import { globalConfig } from "../core/config";
|
|
|
|
import { createLogger } from "../core/logging";
|
|
|
|
import { STOP_PROPAGATION } from "../core/signal";
|
|
|
|
import { round2Digits } from "../core/utils";
|
|
|
|
import { enumDirection, enumDirectionToVector, enumInvertedDirections, Vector } from "../core/vector";
|
|
|
|
import { getBuildingDataFromCode } from "./building_codes";
|
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>
3 years ago
|
|
|
import { Component } from "./component";
|
|
|
|
import { enumWireVariant } from "./components/wire";
|
|
|
|
import { Entity } from "./entity";
|
|
|
|
import { CHUNK_OVERLAY_RES } from "./map_chunk_view";
|
|
|
|
import { MetaBuilding } from "./meta_building";
|
|
|
|
import { GameRoot } from "./root";
|
|
|
|
import { WireNetwork } from "./systems/wire";
|
|
|
|
|
|
|
|
const logger = createLogger("ingame/logic");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Typing helper
|
|
|
|
* @typedef {Array<{
|
|
|
|
* entity: Entity,
|
|
|
|
* slot: import("./components/item_ejector").ItemEjectorSlot,
|
|
|
|
* fromTile: Vector,
|
|
|
|
* toDirection: enumDirection
|
|
|
|
* }>} EjectorsAffectingTile
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Typing helper
|
|
|
|
* @typedef {Array<{
|
|
|
|
* entity: Entity,
|
|
|
|
* slot: import("./components/item_acceptor").ItemAcceptorSlot,
|
|
|
|
* toTile: Vector,
|
|
|
|
* fromDirection: enumDirection
|
|
|
|
* }>} AcceptorsAffectingTile
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {{
|
|
|
|
* acceptors: AcceptorsAffectingTile,
|
|
|
|
* ejectors: EjectorsAffectingTile
|
|
|
|
* }} AcceptorsAndEjectorsAffectingTile
|
|
|
|
*/
|
|
|
|
|
|
|
|
export class GameLogic {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {GameRoot} root
|
|
|
|
*/
|
|
|
|
constructor(root) {
|
|
|
|
this.root = root;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the given entity can be placed
|
|
|
|
* @param {Entity} entity
|
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>
2 years ago
|
|
|
* @param {Object} param0
|
|
|
|
* @param {boolean=} param0.allowReplaceBuildings
|
|
|
|
* @param {Vector=} param0.offset Optional, move the entity by the given offset first
|
|
|
|
* @returns {boolean} true if the entity could be placed there
|
|
|
|
*/
|
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>
2 years ago
|
|
|
checkCanPlaceEntity(entity, { allowReplaceBuildings = true, offset = null }) {
|
|
|
|
// Compute area of the building
|
|
|
|
const rect = entity.components.StaticMapEntity.getTileSpaceBounds();
|
|
|
|
if (offset) {
|
|
|
|
rect.x += offset.x;
|
|
|
|
rect.y += offset.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the whole area of the building
|
|
|
|
for (let x = rect.x; x < rect.x + rect.w; ++x) {
|
|
|
|
for (let y = rect.y; y < rect.y + rect.h; ++y) {
|
|
|
|
// Check if there is any direct collision
|
|
|
|
const otherEntity = this.root.map.getLayerContentXY(x, y, entity.layer);
|
|
|
|
if (otherEntity) {
|
|
|
|
const staticComp = otherEntity.components.StaticMapEntity;
|
|
|
|
if (
|
|
|
|
!allowReplaceBuildings ||
|
|
|
|
!staticComp
|
|
|
|
.getMetaBuilding()
|
|
|
|
.getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant())
|
|
|
|
) {
|
|
|
|
// This one is a direct blocker
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform additional placement checks
|
|
|
|
if (this.root.gameMode.getIsEditor()) {
|
|
|
|
const toolbar = this.root.hud.parts.buildingsToolbar;
|
|
|
|
const id = entity.components.StaticMapEntity.getMetaBuilding().getId();
|
|
|
|
|
|
|
|
if (toolbar.buildingHandles[id].puzzleLocked) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.root.signals.prePlacementCheck.dispatch(entity, offset) === STOP_PROPAGATION) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to place the given building
|
|
|
|
* @param {object} param0
|
|
|
|
* @param {Vector} param0.origin
|
|
|
|
* @param {number} param0.rotation
|
|
|
|
* @param {number} param0.originalRotation
|
|
|
|
* @param {number} param0.rotationVariant
|
|
|
|
* @param {string} param0.variant
|
|
|
|
* @param {MetaBuilding} param0.building
|
|
|
|
* @returns {Entity}
|
|
|
|
*/
|
|
|
|
tryPlaceBuilding({ origin, rotation, rotationVariant, originalRotation, variant, building }) {
|
|
|
|
const entity = building.createEntity({
|
|
|
|
root: this.root,
|
|
|
|
origin,
|
|
|
|
rotation,
|
|
|
|
originalRotation,
|
|
|
|
rotationVariant,
|
|
|
|
variant,
|
|
|
|
});
|
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>
2 years ago
|
|
|
if (this.checkCanPlaceEntity(entity, {})) {
|
|
|
|
this.freeEntityAreaBeforeBuild(entity);
|
|
|
|
this.root.map.placeStaticEntity(entity);
|
|
|
|
this.root.entityMgr.registerEntity(entity);
|
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all entities with a RemovableMapEntityComponent which need to get
|
|
|
|
* removed before placing this entity
|
|
|
|
* @param {Entity} entity
|
|
|
|
*/
|
|
|
|
freeEntityAreaBeforeBuild(entity) {
|
|
|
|
const staticComp = entity.components.StaticMapEntity;
|
|
|
|
const rect = staticComp.getTileSpaceBounds();
|
|
|
|
// Remove any removeable colliding entities on the same layer
|
|
|
|
for (let x = rect.x; x < rect.x + rect.w; ++x) {
|
|
|
|
for (let y = rect.y; y < rect.y + rect.h; ++y) {
|
|
|
|
const contents = this.root.map.getLayerContentXY(x, y, entity.layer);
|
|
|
|
if (contents) {
|
|
|
|
const staticComp = contents.components.StaticMapEntity;
|
|
|
|
assertAlways(
|
|
|
|
staticComp
|
|
|
|
.getMetaBuilding()
|
|
|
|
.getIsReplaceable(staticComp.getVariant(), staticComp.getRotationVariant()),
|
|
|
|
"Tried to replace non-repleaceable entity"
|
|
|
|
);
|
|
|
|
if (!this.tryDeleteBuilding(contents)) {
|
|
|
|
assertAlways(false, "Tried to replace non-repleaceable entity #2");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform other callbacks
|
|
|
|
this.root.signals.freeEntityAreaBeforeBuild.dispatch(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs a bulk operation, not updating caches in the meantime
|
|
|
|
* @param {function} operation
|
|
|
|
*/
|
|
|
|
performBulkOperation(operation) {
|
|
|
|
logger.warn("Running bulk operation ...");
|
|
|
|
assert(!this.root.bulkOperationRunning, "Can not run two bulk operations twice");
|
|
|
|
this.root.bulkOperationRunning = true;
|
|
|
|
const now = performance.now();
|
|
|
|
const returnValue = operation();
|
|
|
|
const duration = performance.now() - now;
|
|
|
|
logger.log("Done in", round2Digits(duration), "ms");
|
|
|
|
assert(this.root.bulkOperationRunning, "Bulk operation = false while bulk operation was running");
|
|
|
|
this.root.bulkOperationRunning = false;
|
|
|
|
this.root.signals.bulkOperationFinished.dispatch();
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
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>
3 years ago
|
|
|
/**
|
|
|
|
* Performs a immutable operation, causing no recalculations
|
|
|
|
* @param {function} operation
|
|
|
|
*/
|
|
|
|
performImmutableOperation(operation) {
|
|
|
|
logger.warn("Running immutable operation ...");
|
|
|
|
assert(!this.root.immutableOperationRunning, "Can not run two immutalbe operations twice");
|
|
|
|
this.root.immutableOperationRunning = true;
|
|
|
|
const now = performance.now();
|
|
|
|
const returnValue = operation();
|
|
|
|
const duration = performance.now() - now;
|
|
|
|
logger.log("Done in", round2Digits(duration), "ms");
|
|
|
|
assert(
|
|
|
|
this.root.immutableOperationRunning,
|
|
|
|
"Immutable operation = false while immutable operation was running"
|
|
|
|
);
|
|
|
|
this.root.immutableOperationRunning = false;
|
|
|
|
this.root.signals.immutableOperationFinished.dispatch();
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the given building can get removed
|
|
|
|
* @param {Entity} building
|
|
|
|
*/
|
|
|
|
canDeleteBuilding(building) {
|
|
|
|
const staticComp = building.components.StaticMapEntity;
|
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>
3 years ago
|
|
|
return staticComp.getMetaBuilding().getIsRemovable(this.root);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to delete the given building
|
|
|
|
* @param {Entity} building
|
|
|
|
*/
|
|
|
|
tryDeleteBuilding(building) {
|
|
|
|
if (!this.canDeleteBuilding(building)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.root.map.removeStaticEntity(building);
|
|
|
|
this.root.entityMgr.destroyEntity(building);
|
|
|
|
this.root.entityMgr.processDestroyList();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Computes the flag for a given tile
|
|
|
|
* @param {object} param0
|
|
|
|
* @param {enumWireVariant} param0.wireVariant
|
|
|
|
* @param {Vector} param0.tile The tile to check at
|
|
|
|
* @param {enumDirection} param0.edge The edge to check for
|
|
|
|
*/
|
|
|
|
computeWireEdgeStatus({ wireVariant, tile, edge }) {
|
|
|
|
const offset = enumDirectionToVector[edge];
|
|
|
|
const targetTile = tile.add(offset);
|
|
|
|
|
|
|
|
// Search for relevant pins
|
|
|
|
const pinEntities = this.root.map.getLayersContentsMultipleXY(targetTile.x, targetTile.y);
|
|
|
|
|
|
|
|
// Go over all entities which could have a pin
|
|
|
|
for (let i = 0; i < pinEntities.length; ++i) {
|
|
|
|
const pinEntity = pinEntities[i];
|
|
|
|
const pinComp = pinEntity.components.WiredPins;
|
|
|
|
const staticComp = pinEntity.components.StaticMapEntity;
|
|
|
|
|
|
|
|
// Skip those who don't have pins
|
|
|
|
if (!pinComp) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go over all pins
|
|
|
|
const pins = pinComp.slots;
|
|
|
|
for (let k = 0; k < pinComp.slots.length; ++k) {
|
|
|
|
const pinSlot = pins[k];
|
|
|
|
const pinLocation = staticComp.localTileToWorld(pinSlot.pos);
|
|
|
|
const pinDirection = staticComp.localDirectionToWorld(pinSlot.direction);
|
|
|
|
|
|
|
|
// Check if the pin has the right location
|
|
|
|
if (!pinLocation.equals(targetTile)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the pin has the right direction
|
|
|
|
if (pinDirection !== enumInvertedDirections[edge]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Found a pin!
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now check if there's a connectable entity on the wires layer
|
|
|
|
const targetEntity = this.root.map.getTileContent(targetTile, "wires");
|
|
|
|
if (!targetEntity) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const targetStaticComp = targetEntity.components.StaticMapEntity;
|
|
|
|
|
|
|
|
// Check if its a crossing
|
|
|
|
const wireTunnelComp = targetEntity.components.WireTunnel;
|
|
|
|
if (wireTunnelComp) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if its a wire
|
|
|
|
const wiresComp = targetEntity.components.Wire;
|
|
|
|
if (!wiresComp) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's connected if its the same variant
|
|
|
|
return wiresComp.variant === wireVariant;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all wire networks this entity participates in on the given tile
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @param {Vector} tile
|
|
|
|
* @returns {Array<WireNetwork>|null} Null if the entity is never able to be connected at the given tile
|
|
|
|
*/
|
|
|
|
getEntityWireNetworks(entity, tile) {
|
|
|
|
let canConnectAtAll = false;
|
|
|
|
|
|
|
|
/** @type {Set<WireNetwork>} */
|
|
|
|
const networks = new Set();
|
|
|
|
|
|
|
|
const staticComp = entity.components.StaticMapEntity;
|
|
|
|
const wireComp = entity.components.Wire;
|
|
|
|
if (wireComp) {
|
|
|
|
canConnectAtAll = true;
|
|
|
|
if (wireComp.linkedNetwork) {
|
|
|
|
networks.add(wireComp.linkedNetwork);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const tunnelComp = entity.components.WireTunnel;
|
|
|
|
if (tunnelComp) {
|
|
|
|
canConnectAtAll = true;
|
|
|
|
for (let i = 0; i < tunnelComp.linkedNetworks.length; ++i) {
|
|
|
|
networks.add(tunnelComp.linkedNetworks[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const pinsComp = entity.components.WiredPins;
|
|
|
|
if (pinsComp) {
|
|
|
|
const slots = pinsComp.slots;
|
|
|
|
for (let i = 0; i < slots.length; ++i) {
|
|
|
|
const slot = slots[i];
|
|
|
|
const slotLocalPos = staticComp.localTileToWorld(slot.pos);
|
|
|
|
if (slotLocalPos.equals(tile)) {
|
|
|
|
canConnectAtAll = true;
|
|
|
|
if (slot.linkedNetwork) {
|
|
|
|
networks.add(slot.linkedNetwork);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!canConnectAtAll) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Array.from(networks);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the entities tile *and* his overlay matrix is intersected
|
|
|
|
* @param {Entity} entity
|
|
|
|
* @param {Vector} worldPos
|
|
|
|
*/
|
|
|
|
getIsEntityIntersectedWithMatrix(entity, worldPos) {
|
|
|
|
const staticComp = entity.components.StaticMapEntity;
|
|
|
|
const tile = worldPos.toTileSpace();
|
|
|
|
|
|
|
|
if (!staticComp.getTileSpaceBounds().containsPoint(tile.x, tile.y)) {
|
|
|
|
// No intersection at all
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = getBuildingDataFromCode(staticComp.code);
|
|
|
|
const overlayMatrix = data.metaInstance.getSpecialOverlayRenderMatrix(
|
|
|
|
staticComp.rotation,
|
|
|
|
data.rotationVariant,
|
|
|
|
data.variant,
|
|
|
|
entity
|
|
|
|
);
|
|
|
|
// Always the same
|
|
|
|
if (!overlayMatrix) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const localPosition = worldPos
|
|
|
|
.divideScalar(globalConfig.tileSize)
|
|
|
|
.modScalar(1)
|
|
|
|
.multiplyScalar(CHUNK_OVERLAY_RES)
|
|
|
|
.floor();
|
|
|
|
|
|
|
|
return !!overlayMatrix[localPosition.x + localPosition.y * 3];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the acceptors and ejectors which affect the current tile
|
|
|
|
* @param {Vector} tile
|
|
|
|
* @returns {AcceptorsAndEjectorsAffectingTile}
|
|
|
|
*/
|
|
|
|
getEjectorsAndAcceptorsAtTile(tile) {
|
|
|
|
/** @type {EjectorsAffectingTile} */
|
|
|
|
let ejectors = [];
|
|
|
|
/** @type {AcceptorsAffectingTile} */
|
|
|
|
let acceptors = [];
|
|
|
|
|
|
|
|
// Well .. please ignore this code! :D
|
|
|
|
for (let dx = -1; dx <= 1; ++dx) {
|
|
|
|
for (let dy = -1; dy <= 1; ++dy) {
|
|
|
|
if (Math.abs(dx) + Math.abs(dy) !== 1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const entity = this.root.map.getLayerContentXY(tile.x + dx, tile.y + dy, "regular");
|
|
|
|
if (entity) {
|
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>
2 years ago
|
|
|
/**
|
|
|
|
* @type {Array<import("./components/item_ejector").ItemEjectorSlot>}
|
|
|
|
*/
|
|
|
|
let ejectorSlots = [];
|
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>
2 years ago
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {Array<import("./components/item_acceptor").ItemAcceptorSlot>}
|
|
|
|
*/
|
|
|
|
let acceptorSlots = [];
|
|
|
|
|
|
|
|
const staticComp = entity.components.StaticMapEntity;
|
|
|
|
const itemEjector = entity.components.ItemEjector;
|
|
|
|
const itemAcceptor = entity.components.ItemAcceptor;
|
|
|
|
const beltComp = entity.components.Belt;
|
|
|
|
|
|
|
|
if (itemEjector) {
|
|
|
|
ejectorSlots = itemEjector.slots.slice();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemAcceptor) {
|
|
|
|
acceptorSlots = itemAcceptor.slots.slice();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (beltComp) {
|
|
|
|
const fakeEjectorSlot = beltComp.getFakeEjectorSlot();
|
|
|
|
const fakeAcceptorSlot = beltComp.getFakeAcceptorSlot();
|
|
|
|
ejectorSlots.push(fakeEjectorSlot);
|
|
|
|
acceptorSlots.push(fakeAcceptorSlot);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let ejectorSlot = 0; ejectorSlot < ejectorSlots.length; ++ejectorSlot) {
|
|
|
|
const slot = ejectorSlots[ejectorSlot];
|
|
|
|
const wsTile = staticComp.localTileToWorld(slot.pos);
|
|
|
|
const wsDirection = staticComp.localDirectionToWorld(slot.direction);
|
|
|
|
const targetTile = wsTile.add(enumDirectionToVector[wsDirection]);
|
|
|
|
if (targetTile.equals(tile)) {
|
|
|
|
ejectors.push({
|
|
|
|
entity,
|
|
|
|
slot,
|
|
|
|
fromTile: wsTile,
|
|
|
|
toDirection: wsDirection,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let acceptorSlot = 0; acceptorSlot < acceptorSlots.length; ++acceptorSlot) {
|
|
|
|
const slot = acceptorSlots[acceptorSlot];
|
|
|
|
const wsTile = staticComp.localTileToWorld(slot.pos);
|
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>
2 years ago
|
|
|
const direction = slot.direction;
|
|
|
|
const wsDirection = staticComp.localDirectionToWorld(direction);
|
|
|
|
const sourceTile = wsTile.add(enumDirectionToVector[wsDirection]);
|
|
|
|
if (sourceTile.equals(tile)) {
|
|
|
|
acceptors.push({
|
|
|
|
entity,
|
|
|
|
slot,
|
|
|
|
toTile: wsTile,
|
|
|
|
fromDirection: wsDirection,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return { ejectors, acceptors };
|
|
|
|
}
|
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>
3 years ago
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears all belts and items
|
|
|
|
*/
|
|
|
|
clearAllBeltsAndItems() {
|
|
|
|
for (const entity of this.root.entityMgr.entities) {
|
|
|
|
for (const component of Object.values(entity.components)) {
|
|
|
|
/** @type {Component} */ (component).clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|