mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Fixed wrong Wire logic
This commit is contained in:
parent
ef3bccdaa8
commit
c2983a9770
@ -24,10 +24,10 @@ const wireTunnelsOverlayMatrix = {
|
|||||||
* @enum {Array<Array<Vector>>}
|
* @enum {Array<Array<Vector>>}
|
||||||
*/
|
*/
|
||||||
export const ConnectionDirections = {
|
export const ConnectionDirections = {
|
||||||
[defaultBuildingVariant]: [[new Vector(0, 1), new Vector(0, -1)], [new Vector(-1, 0), new Vector(1, 0)]],
|
[defaultBuildingVariant]: [[new Vector(0, 1), new Vector(0, 1)], [new Vector(1, 0), new Vector(1, 0)]],
|
||||||
[enumWireTunnelVariants.DoubleElbow]: [[new Vector(0, 1), new Vector(1, 0)], [new Vector(0, -1), new Vector(-1, 0)]],
|
[enumWireTunnelVariants.DoubleElbow]: [[new Vector(0, 1), new Vector(1, 0)], [new Vector(0, -1), new Vector(-1, 0)]],
|
||||||
[enumWireTunnelVariants.Elbow]: [[new Vector(0, 1), new Vector(1, 0)]],
|
[enumWireTunnelVariants.Elbow]: [[new Vector(0, 1), new Vector(1, 0)]],
|
||||||
[enumWireTunnelVariants.Straight]: [[new Vector(0, 1), new Vector(0, -1)]],
|
[enumWireTunnelVariants.Straight]: [[new Vector(0, 1), new Vector(0, 1)]],
|
||||||
};
|
};
|
||||||
|
|
||||||
export class MetaWireTunnelBuilding extends MetaBuilding {
|
export class MetaWireTunnelBuilding extends MetaBuilding {
|
||||||
@ -102,7 +102,6 @@ export class MetaWireTunnelBuilding extends MetaBuilding {
|
|||||||
*/
|
*/
|
||||||
updateVariants(entity, rotationVariant, variant) {
|
updateVariants(entity, rotationVariant, variant) {
|
||||||
if(entity.components.WireTunnel){
|
if(entity.components.WireTunnel){
|
||||||
let a = new Vector(1, 0);
|
|
||||||
//a.rotateInplaceFastMultipleOf90(rotationVariant);
|
//a.rotateInplaceFastMultipleOf90(rotationVariant);
|
||||||
entity.components.WireTunnel.UpdateConnections(variant, ConnectionDirections[variant])
|
entity.components.WireTunnel.UpdateConnections(variant, ConnectionDirections[variant])
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,11 @@ export class WireTunnelComponent extends Component {
|
|||||||
if(!this.Connections[ahash]) {
|
if(!this.Connections[ahash]) {
|
||||||
this.Connections[ahash] = b;
|
this.Connections[ahash] = b;
|
||||||
}
|
}
|
||||||
|
let alta = a.rotateFastMultipleOf90(180);
|
||||||
const bhash = b.toString();
|
let altb = b.rotateFastMultipleOf90(180);
|
||||||
|
const bhash = altb.toString();
|
||||||
if(!this.Connections[bhash]) {
|
if(!this.Connections[bhash]) {
|
||||||
this.Connections[bhash] = a;
|
this.Connections[bhash] = alta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(this.Connections);
|
console.log(this.Connections);
|
||||||
@ -71,7 +72,7 @@ export class WireTunnelComponent extends Component {
|
|||||||
CanConnect(dir) {
|
CanConnect(dir) {
|
||||||
return !!this.Connections[dir.toString()];
|
return !!this.Connections[dir.toString()];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("./static_map_entity").StaticMapEntityComponent} staticComp
|
* @param {import("./static_map_entity").StaticMapEntityComponent} staticComp
|
||||||
* @param {Vector} input
|
* @param {Vector} input
|
||||||
@ -80,7 +81,8 @@ export class WireTunnelComponent extends Component {
|
|||||||
GetOutputDirection(staticComp, input) {
|
GetOutputDirection(staticComp, input) {
|
||||||
const inputDir = staticComp.unapplyRotationToVector(input); //TODO: Fix the Wierd Shit
|
const inputDir = staticComp.unapplyRotationToVector(input); //TODO: Fix the Wierd Shit
|
||||||
if(this.CanConnect(inputDir)){
|
if(this.CanConnect(inputDir)){
|
||||||
return staticComp.applyRotationToVector(this.Connections[inputDir.toString()]);;
|
let out = this.Connections[inputDir.toString()];
|
||||||
|
return staticComp.applyRotationToVector(out);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -243,10 +243,10 @@ export class GameLogic {
|
|||||||
|
|
||||||
const targetStaticComp = targetEntity.components.StaticMapEntity;
|
const targetStaticComp = targetEntity.components.StaticMapEntity;
|
||||||
|
|
||||||
// Check if its a crossing
|
// Check if its a tunnel
|
||||||
const wireTunnelComp = targetEntity.components.WireTunnel;
|
const wireTunnelComp = targetEntity.components.WireTunnel;
|
||||||
if (wireTunnelComp) {
|
if (wireTunnelComp) {
|
||||||
const inputDir = targetStaticComp.unapplyRotationToVector(offset.rotateFastMultipleOf90(270));
|
const inputDir = targetStaticComp.unapplyRotationToVector(offset);
|
||||||
return wireTunnelComp.CanConnect(inputDir);
|
return wireTunnelComp.CanConnect(inputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user