mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Display's Finally Fixed now it is time for Emerald Block's quest
This commit is contained in:
parent
3226b59b96
commit
224dad1cec
@ -1,5 +1,6 @@
|
||||
import { enumDirection, Vector } from "../../core/vector";
|
||||
import { enumPinSlotType, WiredPinsComponent } from "../components/wired_pins";
|
||||
import { WirelessCodeComponent } from "../components/wireless_code";
|
||||
import { Entity } from "../entity";
|
||||
import { defaultBuildingVariant, MetaBuilding } from "../meta_building";
|
||||
import { GameRoot } from "../root";
|
||||
@ -31,7 +32,7 @@ export class MetaWirelessDisplayBuilding extends MetaBuilding {
|
||||
* @param {GameRoot} root
|
||||
*/
|
||||
getIsUnlocked(root) {
|
||||
return root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display);
|
||||
return true //root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +41,7 @@ export class MetaWirelessDisplayBuilding extends MetaBuilding {
|
||||
getAvailableVariants(root) {
|
||||
let available = [defaultBuildingVariant];
|
||||
|
||||
if (root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display)) {
|
||||
if (true || root.hubGoals.isRewardUnlocked(enumHubGoalRewards.reward_display)) {
|
||||
available.push(enumWirelessDisplayVariants.remote_control);
|
||||
}
|
||||
|
||||
@ -80,7 +81,7 @@ export class MetaWirelessDisplayBuilding extends MetaBuilding {
|
||||
type: enumPinSlotType.logicalAcceptor,
|
||||
},
|
||||
],
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import { BeltReaderComponent } from "./components/belt_reader";
|
||||
import { FilterComponent } from "./components/filter";
|
||||
import { ItemProducerComponent } from "./components/item_producer";
|
||||
import { WirelessDisplayComponent } from "./components/wireless_display";
|
||||
import { WirelessCodeComponent } from "./components/wireless_code";
|
||||
|
||||
export function initComponentRegistry() {
|
||||
gComponentRegistry.register(StaticMapEntityComponent);
|
||||
@ -43,6 +44,7 @@ export function initComponentRegistry() {
|
||||
gComponentRegistry.register(BeltReaderComponent);
|
||||
gComponentRegistry.register(FilterComponent);
|
||||
gComponentRegistry.register(ItemProducerComponent);
|
||||
gComponentRegistry.register(WirelessCodeComponent);
|
||||
|
||||
// IMPORTANT ^^^^^ UPDATE ENTITY COMPONENT STORAGE AFTERWARDS
|
||||
|
||||
|
31
src/js/game/components/wireless_code.js
Normal file
31
src/js/game/components/wireless_code.js
Normal file
@ -0,0 +1,31 @@
|
||||
import { enumDirection, Vector } from "../../core/vector";
|
||||
import { BaseItem } from "../base_item";
|
||||
import { Component } from "../component";
|
||||
import { types } from "../../savegame/serialization";
|
||||
import { typeItemSingleton } from "../item_resolver";
|
||||
import { gComponentRegistry } from "../../core/global_registries";
|
||||
|
||||
export class WirelessCodeComponent extends Component {
|
||||
static getId() {
|
||||
return "WirelessCode";
|
||||
}
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
wireless_code: types.string
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} id
|
||||
*/
|
||||
constructor(id) {
|
||||
super();
|
||||
this.wireless_code = id;
|
||||
}
|
||||
|
||||
getWirelessCode() {
|
||||
return this.wireless_code;
|
||||
}
|
||||
}
|
@ -8,10 +8,6 @@ export class WirelessDisplayComponent extends Component {
|
||||
return "WirelessDisplay";
|
||||
}
|
||||
|
||||
static getWirelessCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static getSchema() {
|
||||
return {
|
||||
signal: types.nullable(typeItemSingleton),
|
||||
|
@ -89,7 +89,6 @@ export class GameCore {
|
||||
this.root.savegame = savegame;
|
||||
this.root.gameWidth = this.app.screenWidth;
|
||||
this.root.gameHeight = this.app.screenHeight;
|
||||
|
||||
// Initialize canvas element & context
|
||||
this.internalInitCanvas();
|
||||
|
||||
|
@ -12,7 +12,6 @@ import { Loader } from "../core/loader";
|
||||
import { drawRotatedSprite } from "../core/draw_utils";
|
||||
import { gComponentRegistry } from "../core/global_registries";
|
||||
import { getBuildingDataFromCode } from "./building_codes";
|
||||
import { WirelessDisplayComponent } from "./components/wireless_display";
|
||||
|
||||
export class Entity extends BasicSerializableObject {
|
||||
/**
|
||||
@ -65,12 +64,6 @@ export class Entity extends BasicSerializableObject {
|
||||
* @type {string} */
|
||||
this.destroyReason;
|
||||
|
||||
/**
|
||||
* Stores wireless code of this entity
|
||||
* @type {string}
|
||||
*/
|
||||
this.wireless_code;
|
||||
|
||||
/* typehints:end */
|
||||
}
|
||||
|
||||
@ -83,7 +76,6 @@ export class Entity extends BasicSerializableObject {
|
||||
* @returns {import("../savegame/serialization").Schema}
|
||||
*/
|
||||
static getSchema() {
|
||||
console.log(types);
|
||||
return {
|
||||
uid: types.uint,
|
||||
components: types.keyValueMap(types.objData(gComponentRegistry), false),
|
||||
@ -94,7 +86,6 @@ export class Entity extends BasicSerializableObject {
|
||||
* Returns a clone of this entity
|
||||
*/
|
||||
clone() {
|
||||
const wireless_code = this.wireless_code;
|
||||
const staticComp = this.components.StaticMapEntity;
|
||||
const buildingData = getBuildingDataFromCode(staticComp.code);
|
||||
|
||||
@ -105,7 +96,7 @@ export class Entity extends BasicSerializableObject {
|
||||
rotation: staticComp.rotation,
|
||||
rotationVariant: buildingData.rotationVariant,
|
||||
variant: buildingData.variant,
|
||||
wirelessCode: this.wireless_code,
|
||||
wireless_code: this.components.WirelessCode,
|
||||
});
|
||||
|
||||
for (const key in this.components) {
|
||||
|
@ -20,6 +20,7 @@ import { BeltReaderComponent } from "./components/belt_reader";
|
||||
import { FilterComponent } from "./components/filter";
|
||||
import { ItemProducerComponent } from "./components/item_producer";
|
||||
import { WirelessDisplayComponent } from "./components/wireless_display";
|
||||
import { WirelessCodeComponent } from "./components/wireless_code";
|
||||
/* typehints:end */
|
||||
|
||||
/**
|
||||
@ -93,6 +94,9 @@ export class EntityComponentStorage {
|
||||
/** @type {ItemProducerComponent} */
|
||||
this.ItemProducer;
|
||||
|
||||
/** @type {WirelessCodeComponent} */
|
||||
this.WirelessCode;
|
||||
|
||||
/* typehints:end */
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ export class EntityManager extends BasicSerializableObject {
|
||||
|
||||
this.entities.push(entity);
|
||||
|
||||
//console.log(entity.components);
|
||||
// Register into the componentToEntity map
|
||||
for (const componentId in entity.components) {
|
||||
if (entity.components[componentId]) {
|
||||
|
@ -79,7 +79,7 @@ export class GameLogic {
|
||||
}
|
||||
|
||||
// Perform additional placement checks
|
||||
if (this.root.signals.prePlacementCheck.dispatch(entity, offset) === STOP_PROPAGATION) {
|
||||
if (this.root.signals.prePlacementCheck.dispatch(entity, offset) === STOP_PROPAGATION && !entity.components.Wire) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@ import { StaticMapEntityComponent } from "./components/static_map_entity";
|
||||
import { Entity } from "./entity";
|
||||
import { GameRoot } from "./root";
|
||||
import { getCodeFromBuildingData } from "./building_codes";
|
||||
import { WirelessCodeComponent } from "./components/wireless_code";
|
||||
import { WirelessDisplayComponent } from "./components/wireless_display";
|
||||
|
||||
export const defaultBuildingVariant = "default";
|
||||
|
||||
@ -199,7 +201,7 @@ export class MetaBuilding {
|
||||
* @param {number} param0.rotationVariant Rotation variant
|
||||
* @param {string} param0.variant
|
||||
*/
|
||||
createEntity({ root, origin, rotation, originalRotation, rotationVariant, variant, wirelessCode }) {
|
||||
createEntity({ root, origin, rotation, originalRotation, rotationVariant, variant, wireless_code }) {
|
||||
const entity = new Entity(root);
|
||||
entity.layer = this.getLayer();
|
||||
entity.addComponent(
|
||||
@ -213,8 +215,10 @@ export class MetaBuilding {
|
||||
);
|
||||
this.setupEntityComponents(entity, root);
|
||||
this.updateVariants(entity, rotationVariant, variant);
|
||||
if (wirelessCode) {
|
||||
entity.wireless_code = wirelessCode;
|
||||
if (entity.components.WirelessDisplay && wireless_code) {
|
||||
if (!entity.components.WirelessCode) {
|
||||
entity.components.WirelessCode = wireless_code;
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import { BOOL_FALSE_SINGLETON, BOOL_TRUE_SINGLETON } from "../items/boolean_item
|
||||
import { init } from "logrocket";
|
||||
import { Signal } from "../../core/signal";
|
||||
import { serializeError } from "../../core/logging";
|
||||
import { WirelessCodeComponent } from "../components/wireless_code";
|
||||
import { enumInvertedDirections } from "../../core/vector";
|
||||
|
||||
export class WirelessDisplaySystem extends GameSystemWithFilter {
|
||||
constructor(root) {
|
||||
@ -39,6 +41,19 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
|
||||
this.wirelessMachineList = {};
|
||||
|
||||
this.displayNumber = 0;
|
||||
this.entityCount = 0;
|
||||
}
|
||||
|
||||
update() {
|
||||
if (this.entityCount != this.allEntities.length) {
|
||||
for (let i = 0; i < this.allEntities.length; i++) {
|
||||
const entity = this.allEntities[i];
|
||||
if (entity.components.WirelessDisplay && entity.components.WiredPins && entity.components.WirelessCode && !this.wirelessMachineList[entity.components.WirelessCode]) {
|
||||
this.wirelessMachineList[entity.components.WirelessCode["wireless_code"]] = entity;
|
||||
}
|
||||
}
|
||||
this.entityCount = this.allEntities.length;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,11 +102,11 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (signalValueInput.getValue() && !entity.components.WiredPins){
|
||||
entity.wireless_code = signalValueInput.getValue();
|
||||
} else if (signalValueInput.getValue() && entity.components.WiredPins){
|
||||
entity.wireless_code = signalValueInput.getValue();
|
||||
this.wirelessMachineList[entity.wireless_code] = entity;
|
||||
if (signalValueInput.getValue() && !entity.components.WiredPins) {
|
||||
entity.addComponent(new WirelessCodeComponent(signalValueInput.getValue()));
|
||||
} else if (signalValueInput.getValue() && entity.components.WiredPins) {
|
||||
entity.addComponent(new WirelessCodeComponent(signalValueInput.getValue()));
|
||||
this.wirelessMachineList[entity.components.WirelessCode["wireless_code"]] = entity;
|
||||
}
|
||||
};
|
||||
|
||||
@ -160,8 +175,8 @@ export class WirelessDisplaySystem extends GameSystemWithFilter {
|
||||
const contents = chunk.containedEntitiesByLayer.regular;
|
||||
for (let i = 0; i < contents.length; ++i) {
|
||||
const entity_a = contents[i];
|
||||
if (entity_a && !entity_a.components.WiredPins && entity_a.components.WirelessDisplay) {
|
||||
const entity_b = this.wirelessMachineList[entity_a.wireless_code];
|
||||
if (entity_a && !entity_a.components.WiredPins && entity_a.components.WirelessDisplay && entity_a.components.WirelessCode) {
|
||||
const entity_b = this.wirelessMachineList[entity_a.components.WirelessCode["wireless_code"]];
|
||||
if (entity_b) {
|
||||
if (!this.allEntities.includes(entity_b)) {
|
||||
this.wirelessMachineList[entity_b] = undefined;
|
||||
|
@ -140,7 +140,6 @@ export class SavegameSerializer {
|
||||
if (errorReason) {
|
||||
return ExplainedResult.bad(errorReason);
|
||||
}
|
||||
|
||||
return ExplainedResult.good();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
/* typehints:start */
|
||||
import { GameRoot } from "../game/root";
|
||||
import { BasicSerializableObject } from "./serialization";
|
||||
import { BasicSerializableObject, types } from "./serialization";
|
||||
/* typehints:end */
|
||||
|
||||
import { Vector } from "../core/vector";
|
||||
import { round4Digits } from "../core/utils";
|
||||
import { convertCompilerOptionsFromJson } from "typescript";
|
||||
export const globalJsonSchemaDefs = {};
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ import { globalConfig } from "../core/config";
|
||||
import { createLogger } from "../core/logging";
|
||||
import { Vector } from "../core/vector";
|
||||
import { getBuildingDataFromCode } from "../game/building_codes";
|
||||
import { WirelessCodeComponent } from "../game/components/wireless_code";
|
||||
import { Entity } from "../game/entity";
|
||||
import { GameRoot } from "../game/root";
|
||||
|
||||
@ -57,6 +58,7 @@ export class SerializerInternal {
|
||||
originalRotation: staticData.originalRotation,
|
||||
rotationVariant: data.rotationVariant,
|
||||
variant: data.variant,
|
||||
wireless_code: payload.components.WirelessCode,
|
||||
});
|
||||
|
||||
entity.uid = payload.uid;
|
||||
@ -87,6 +89,9 @@ export class SerializerInternal {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (entity.components.WirelessCode && !entity.components.WirelessCode.WirelessCodeComponent && entity.components.WirelessCode.wireless_code) {
|
||||
entity.components.WirelessCode = new WirelessCodeComponent(entity.components.WirelessCode.wireless_code);
|
||||
}
|
||||
|
||||
const errorStatus = entity.components[componentId].deserialize(data[componentId], root);
|
||||
if (errorStatus) {
|
||||
|
Loading…
Reference in New Issue
Block a user