mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-12 10:59:23 +00:00
Minor game system code cleanup
This commit is contained in:
parent
66f085250a
commit
38cca33985
@ -187,6 +187,7 @@ export class GameSystemManager {
|
|||||||
// IMPORTANT: We have 2 phases: In phase 1 we compute the output values of all gates,
|
// IMPORTANT: We have 2 phases: In phase 1 we compute the output values of all gates,
|
||||||
// processors etc. In phase 2 we propagate it through the wires network
|
// processors etc. In phase 2 we propagate it through the wires network
|
||||||
add("logicGate", LogicGateSystem);
|
add("logicGate", LogicGateSystem);
|
||||||
|
|
||||||
add("beltReader", BeltReaderSystem);
|
add("beltReader", BeltReaderSystem);
|
||||||
|
|
||||||
add("display", DisplaySystem);
|
add("display", DisplaySystem);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { arrayBeltVariantToRotation, MetaBeltBuilding } from "../buildings/belt"
|
|||||||
import { getCodeFromBuildingData } from "../building_codes";
|
import { getCodeFromBuildingData } from "../building_codes";
|
||||||
import { BeltComponent } from "../components/belt";
|
import { BeltComponent } from "../components/belt";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
|
import { GameSystem } from "../game_system";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { defaultBuildingVariant } from "../meta_building";
|
import { defaultBuildingVariant } from "../meta_building";
|
||||||
@ -22,9 +23,9 @@ const logger = createLogger("belt");
|
|||||||
/**
|
/**
|
||||||
* Manages all belts
|
* Manages all belts
|
||||||
*/
|
*/
|
||||||
export class BeltSystem extends GameSystemWithFilter {
|
export class BeltSystem extends GameSystem {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [BeltComponent]);
|
super(root);
|
||||||
/**
|
/**
|
||||||
* @type {Object.<enumDirection, Array<AtlasSprite>>}
|
* @type {Object.<enumDirection, Array<AtlasSprite>>}
|
||||||
*/
|
*/
|
||||||
@ -425,8 +426,10 @@ export class BeltSystem extends GameSystemWithFilter {
|
|||||||
|
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
for (let i = 0; i < this.allEntities.length; ++i) {
|
const beltEntities = this.root.entityMgr.getAllWithComponent(BeltComponent);
|
||||||
const entity = this.allEntities[i];
|
|
||||||
|
for (let i = 0; i < beltEntities.length; ++i) {
|
||||||
|
const entity = beltEntities[i];
|
||||||
if (visitedUids.has(entity.uid)) {
|
if (visitedUids.has(entity.uid)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { BeltUnderlaysComponent, enumClippedBeltUnderlayType } from "../componen
|
|||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
import { ItemEjectorComponent } from "../components/item_ejector";
|
import { ItemEjectorComponent } from "../components/item_ejector";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystem } from "../game_system";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
import { BELT_ANIM_COUNT } from "./belt";
|
import { BELT_ANIM_COUNT } from "./belt";
|
||||||
|
|
||||||
@ -31,9 +31,9 @@ const enumUnderlayTypeToClipRect = {
|
|||||||
[enumClippedBeltUnderlayType.bottomOnly]: new Rectangle(0, 0.5, 1, 0.5),
|
[enumClippedBeltUnderlayType.bottomOnly]: new Rectangle(0, 0.5, 1, 0.5),
|
||||||
};
|
};
|
||||||
|
|
||||||
export class BeltUnderlaysSystem extends GameSystemWithFilter {
|
export class BeltUnderlaysSystem extends GameSystem {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [BeltUnderlaysComponent]);
|
super(root);
|
||||||
|
|
||||||
this.underlayBeltSprites = [];
|
this.underlayBeltSprites = [];
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,8 @@ import { ConstantSignalComponent } from "../components/constant_signal";
|
|||||||
import { ItemProducerComponent } from "../components/item_producer";
|
import { ItemProducerComponent } from "../components/item_producer";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { MapChunk } from "../map_chunk";
|
import { MapChunk } from "../map_chunk";
|
||||||
import { GameRoot } from "../root";
|
|
||||||
|
|
||||||
export class ConstantProducerSystem extends GameSystemWithFilter {
|
export class ConstantProducerSystem extends GameSystemWithFilter {
|
||||||
/** @param {GameRoot} root */
|
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [ConstantSignalComponent, ItemProducerComponent]);
|
super(root, [ConstantSignalComponent, ItemProducerComponent]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,15 +2,14 @@ import { globalConfig } from "../../core/config";
|
|||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { BaseItem } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { enumColors } from "../colors";
|
import { enumColors } from "../colors";
|
||||||
import { DisplayComponent } from "../components/display";
|
import { GameSystem } from "../game_system";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
|
||||||
import { isTrueItem } from "../items/boolean_item";
|
import { isTrueItem } from "../items/boolean_item";
|
||||||
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
|
import { ColorItem, COLOR_ITEM_SINGLETONS } from "../items/color_item";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
|
|
||||||
export class DisplaySystem extends GameSystemWithFilter {
|
export class DisplaySystem extends GameSystem {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [DisplayComponent]);
|
super(root);
|
||||||
|
|
||||||
/** @type {Object<string, import("../../core/draw_utils").AtlasSprite>} */
|
/** @type {Object<string, import("../../core/draw_utils").AtlasSprite>} */
|
||||||
this.displaySprites = {};
|
this.displaySprites = {};
|
||||||
|
|||||||
@ -5,10 +5,8 @@ import { Vector } from "../../core/vector";
|
|||||||
import { GoalAcceptorComponent } from "../components/goal_acceptor";
|
import { GoalAcceptorComponent } from "../components/goal_acceptor";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { MapChunk } from "../map_chunk";
|
import { MapChunk } from "../map_chunk";
|
||||||
import { GameRoot } from "../root";
|
|
||||||
|
|
||||||
export class GoalAcceptorSystem extends GameSystemWithFilter {
|
export class GoalAcceptorSystem extends GameSystemWithFilter {
|
||||||
/** @param {GameRoot} root */
|
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [GoalAcceptorComponent]);
|
super(root, [GoalAcceptorComponent]);
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import { createLogger } from "../../core/logging";
|
|||||||
import { Rectangle } from "../../core/rectangle";
|
import { Rectangle } from "../../core/rectangle";
|
||||||
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
import { StaleAreaDetector } from "../../core/stale_area_detector";
|
||||||
import { enumDirection, enumDirectionToVector } from "../../core/vector";
|
import { enumDirection, enumDirectionToVector } from "../../core/vector";
|
||||||
import { ACHIEVEMENTS } from "../../platform/achievement_provider";
|
|
||||||
import { BaseItem } from "../base_item";
|
import { BaseItem } from "../base_item";
|
||||||
import { BeltComponent } from "../components/belt";
|
import { BeltComponent } from "../components/belt";
|
||||||
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
import { ItemAcceptorComponent } from "../components/item_acceptor";
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
/* typehints:start */
|
|
||||||
import { GameRoot } from "../root";
|
|
||||||
/* typehints:end */
|
|
||||||
|
|
||||||
import { ItemProducerComponent } from "../components/item_producer";
|
import { ItemProducerComponent } from "../components/item_producer";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
|
|
||||||
export class ItemProducerSystem extends GameSystemWithFilter {
|
export class ItemProducerSystem extends GameSystemWithFilter {
|
||||||
/** @param {GameRoot} root */
|
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [ItemProducerComponent]);
|
super(root, [ItemProducerComponent]);
|
||||||
this.item = null;
|
this.item = null;
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
|
||||||
import { LeverComponent } from "../components/lever";
|
|
||||||
import { BOOL_TRUE_SINGLETON, BOOL_FALSE_SINGLETON } from "../items/boolean_item";
|
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
|
||||||
import { globalConfig } from "../../core/config";
|
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
|
import { LeverComponent } from "../components/lever";
|
||||||
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
|
import { BOOL_FALSE_SINGLETON, BOOL_TRUE_SINGLETON } from "../items/boolean_item";
|
||||||
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
|
|
||||||
export class LeverSystem extends GameSystemWithFilter {
|
export class LeverSystem extends GameSystemWithFilter {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
|
||||||
import { StorageComponent } from "../components/storage";
|
|
||||||
import { DrawParameters } from "../../core/draw_parameters";
|
import { DrawParameters } from "../../core/draw_parameters";
|
||||||
import { formatBigNumber, lerp } from "../../core/utils";
|
|
||||||
import { Loader } from "../../core/loader";
|
import { Loader } from "../../core/loader";
|
||||||
import { BOOL_TRUE_SINGLETON, BOOL_FALSE_SINGLETON } from "../items/boolean_item";
|
import { formatBigNumber, lerp } from "../../core/utils";
|
||||||
|
import { StorageComponent } from "../components/storage";
|
||||||
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
|
import { BOOL_FALSE_SINGLETON, BOOL_TRUE_SINGLETON } from "../items/boolean_item";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
|
|
||||||
export class StorageSystem extends GameSystemWithFilter {
|
export class StorageSystem extends GameSystemWithFilter {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import { enumWireType, enumWireVariant, WireComponent } from "../components/wire
|
|||||||
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||||
import { WireTunnelComponent } from "../components/wire_tunnel";
|
import { WireTunnelComponent } from "../components/wire_tunnel";
|
||||||
import { Entity } from "../entity";
|
import { Entity } from "../entity";
|
||||||
|
import { GameSystem } from "../game_system";
|
||||||
import { GameSystemWithFilter } from "../game_system_with_filter";
|
import { GameSystemWithFilter } from "../game_system_with_filter";
|
||||||
import { isTruthyItem } from "../items/boolean_item";
|
import { isTruthyItem } from "../items/boolean_item";
|
||||||
import { MapChunkView } from "../map_chunk_view";
|
import { MapChunkView } from "../map_chunk_view";
|
||||||
@ -90,9 +91,9 @@ export class WireNetwork {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WireSystem extends GameSystemWithFilter {
|
export class WireSystem extends GameSystem {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
super(root, [WireComponent]);
|
super(root);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object<enumWireVariant, Object<enumWireType, AtlasSprite>>}
|
* @type {Object<enumWireVariant, Object<enumWireType, AtlasSprite>>}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user