public override bool AreUnderfloorSame(Matrix4x4 thisTransformMatrix, BasicTile basicTile, Matrix4x4 TransformMatrix) { if ((basicTile as PipeTile) != null) { var TilePipeTile = (PipeTile)basicTile; var TheConnection = TilePipeTile.Connections.Copy(); int Offset = PipeFunctions.GetOffsetAngle(TransformMatrix.rotation.eulerAngles.z); TheConnection.Rotate(Offset); var thisConnection = Connections.Copy(); int thisOffset = PipeFunctions.GetOffsetAngle(thisTransformMatrix.rotation.eulerAngles.z); thisConnection.Rotate(thisOffset); for (int i = 0; i < thisConnection.Directions.Length; i++) { if (thisConnection.Directions[i].Bool && TheConnection.Directions[i].Bool) { return(true); } } return(false); } return(base.AreUnderfloorSame(thisTransformMatrix, basicTile, TransformMatrix)); }
public virtual void ServerPerformInteraction(HandApply interaction) { if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wrench)) { var ZeroedLocation = new Vector3Int(x: registerItem.LocalPosition.x, y: registerItem.LocalPosition.y, 0); var metaData = registerItem.Matrix.MetaDataLayer.Get(ZeroedLocation); var thisConnections = GetConnections(); int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); thisConnections.Rotate(Offset); foreach (var Pipeo in metaData.PipeData) { var TheConnection = Pipeo.pipeData.Connections; for (int i = 0; i < thisConnections.Directions.Length; i++) { if (thisConnections.Directions[i].Bool && TheConnection.Directions[i].Bool) { return; } } } BuildPipe(); } RotatePipe(); }
public static Connections GetRotatedConnection(PipeTile pipeTile, Matrix4x4 matrixStruct) { var offset = PipeFunctions.GetOffsetAngle(matrixStruct.rotation.eulerAngles.z); var connection = pipeTile.Connections.Copy(); connection.Rotate(offset); return(connection); }
public void InitialiseNode(Vector3Int Location, Matrix matrix) { var ZeroedLocation = new Vector3Int(x: Location.x, y: Location.y, 0); var metaData = matrix.MetaDataLayer.Get(ZeroedLocation); var pipeNode = new PipeNode(); var rotation = matrix.UnderFloorLayer.Tilemap.GetTransformMatrix(Location); int Offset = PipeFunctions.GetOffsetAngle(rotation.rotation.eulerAngles.z); pipeNode.Initialise(this, metaData, ZeroedLocation, matrix, Offset); metaData.PipeData.Add(pipeNode); }
public void InitialiseNodeNew(Vector3Int Location, Matrix matrix, Matrix4x4 Matrix4x4) { var ZeroedLocation = new Vector3Int(x: Location.x, y: Location.y, 0); var metaData = matrix.MetaDataLayer.Get(ZeroedLocation); var pipeNode = new PipeNode(); var rotation = Matrix4x4; int Offset = PipeFunctions.GetOffsetAngle(rotation.rotation.eulerAngles.z); pipeNode.Initialise(this, metaData, ZeroedLocation, matrix, Offset); metaData.PipeData.Add(pipeNode); }
public virtual void OnSpawnServer(SpawnInfo info) { if (pipeData.PipeAction == null) { pipeData.PipeAction = new MonoActions(); } registerTile.SetPipeData(pipeData); pipeData.MonoPipe = this; int Offset = PipeFunctions.GetOffsetAngle(transform.localRotation.eulerAngles.z); pipeData.Connections.Rotate(Offset); pipeData.OnEnable(); spritehandler?.SetColor(Colour); }
public override void BuildPipe() { var searchVec = registerItem.LocalPosition; var Pipe = (GetPipeObject()); if (Pipe != null) { int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); Quaternion?rot = Quaternion.Euler(0.0f, 0.0f, Offset); var New = Spawn.ServerPrefab(Pipe.gameObject, registerItem.WorldPositionServer, localRotation: rot); New.GameObject.GetComponent <MonoPipe>().SetColour(Colour); Despawn.ServerSingle(this.gameObject); } }
public virtual void BuildPipe() { var searchVec = objectBehaviour.registerTile.LocalPosition; var Tile = (GetPipeTile()); if (Tile != null) { int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); Quaternion rot = Quaternion.Euler(0.0f, 0.0f, Offset); var Matrix = Matrix4x4.TRS(Vector3.zero, rot, Vector3.one); objectBehaviour.registerTile.Matrix.AddUnderFloorTile(searchVec, Tile, Matrix, Colour); Tile.InitialiseNode(searchVec, objectBehaviour.registerTile.Matrix); Despawn.ServerSingle(this.gameObject); } }
private void EnsureInit() { if (registerTile == null) { registerTile = GetComponent <RegisterTile>(); } registerTile.SetPipeData(pipeData); pipeData.MonoPipe = this; int Offset = PipeFunctions.GetOffsetAngle(this.transform.localRotation.eulerAngles.z); pipeData.Connections.Rotate(Offset); pipeData.OnEnable(); spritehandler?.SetColor(Colour); }
public override void BuildPipe() { var pipe = GetPipeObject(); if (pipe == null) { return; } int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); Quaternion?rot = Quaternion.Euler(0.0f, 0.0f, Offset); var New = Spawn.ServerPrefab(pipe.gameObject, registerItem.WorldPositionServer, localRotation: rot); New.GameObject.GetComponent <MonoPipe>().SetColour(Colour); _ = Despawn.ServerSingle(gameObject); }
public override void BuildPipe() { var searchVec = registerItem.LocalPosition; var tile = GetPipeTile(); if (tile == null) { return; } int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); Quaternion rot = Quaternion.Euler(0.0f, 0.0f, Offset); var Matrix = Matrix4x4.TRS(Vector3.zero, rot, Vector3.one); registerItem.Matrix.AddUnderFloorTile(searchVec, tile, Matrix, Colour); tile.InitialiseNodeNew(searchVec, registerItem.Matrix, Matrix); _ = Despawn.ServerSingle(this.gameObject); }