1
0
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:
Christopher-Robin 2020-10-18 02:03:33 +11:00
parent ef3bccdaa8
commit c2983a9770
No known key found for this signature in database
GPG Key ID: 39A83BF9D91CC108
3 changed files with 11 additions and 10 deletions

View File

@ -24,10 +24,10 @@ const wireTunnelsOverlayMatrix = {
* @enum {Array<Array<Vector>>}
*/
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.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 {
@ -102,7 +102,6 @@ export class MetaWireTunnelBuilding extends MetaBuilding {
*/
updateVariants(entity, rotationVariant, variant) {
if(entity.components.WireTunnel){
let a = new Vector(1, 0);
//a.rotateInplaceFastMultipleOf90(rotationVariant);
entity.components.WireTunnel.UpdateConnections(variant, ConnectionDirections[variant])
}

View File

@ -44,10 +44,11 @@ export class WireTunnelComponent extends Component {
if(!this.Connections[ahash]) {
this.Connections[ahash] = b;
}
const bhash = b.toString();
let alta = a.rotateFastMultipleOf90(180);
let altb = b.rotateFastMultipleOf90(180);
const bhash = altb.toString();
if(!this.Connections[bhash]) {
this.Connections[bhash] = a;
this.Connections[bhash] = alta;
}
}
console.log(this.Connections);
@ -71,7 +72,7 @@ export class WireTunnelComponent extends Component {
CanConnect(dir) {
return !!this.Connections[dir.toString()];
}
/**
* @param {import("./static_map_entity").StaticMapEntityComponent} staticComp
* @param {Vector} input
@ -80,7 +81,8 @@ export class WireTunnelComponent extends Component {
GetOutputDirection(staticComp, input) {
const inputDir = staticComp.unapplyRotationToVector(input); //TODO: Fix the Wierd Shit
if(this.CanConnect(inputDir)){
return staticComp.applyRotationToVector(this.Connections[inputDir.toString()]);;
let out = this.Connections[inputDir.toString()];
return staticComp.applyRotationToVector(out);
}
return null;
}

View File

@ -243,10 +243,10 @@ export class GameLogic {
const targetStaticComp = targetEntity.components.StaticMapEntity;
// Check if its a crossing
// Check if its a tunnel
const wireTunnelComp = targetEntity.components.WireTunnel;
if (wireTunnelComp) {
const inputDir = targetStaticComp.unapplyRotationToVector(offset.rotateFastMultipleOf90(270));
const inputDir = targetStaticComp.unapplyRotationToVector(offset);
return wireTunnelComp.CanConnect(inputDir);
}