Exemplo n.º 1
0
        //Stuff for pipes to go in here

        public void Initialise(PipeTile DataToTake, MetaDataNode metaDataNode, Vector3Int searchVec, Matrix locatedon, int RotationOffset)
        {
            RelatedTile = DataToTake;
            IsOn        = metaDataNode;
            pipeData    = new PipeData();
            pipeData.SetUp(DataToTake, RotationOffset);
            pipeData.pipeNode = this;
            NodeLocation      = searchVec;
            LocatedOn         = locatedon;
            pipeData.OnEnable();
        }
Exemplo n.º 2
0
        public void SetUp(PipeTile PipeTile, int RotationOffset)
        {
            Connections = PipeTile.Connections.Copy();
            Connections.Rotate(RotationOffset);
            PipeLayer     = PipeTile.PipeLayer;
            NetCompatible = PipeTile.NetCompatible;
            mixAndVolume.SetVolume(PipeTile.Volume);
            switch (PipeTile.CustomLogic)
            {
            case CustomLogic.None:
                //Awaiting custom logic
                //PipeAction = new Action(); //However
                break;
            }


            CustomLogic = PipeTile.CustomLogic;
        }
Exemplo n.º 3
0
 public virtual void ServerPerformInteraction(HandApply interaction)
 {
     if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wrench))
     {
         var metaDataNode    = registerItem.Matrix.MetaDataLayer.Get(registerItem.LocalPositionServer);
         var connectionsCopy = GetConnections();
         int offset          = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z);
         connectionsCopy.Rotate(offset);
         if (PipeTile.CanAddPipe(metaDataNode, connectionsCopy) == false)
         {
             return;
         }
         ToolUtils.ServerPlayToolSound(interaction);
         BuildPipe();
     }
     else
     {
         rotatable.Rotate();
     }
 }
Exemplo n.º 4
0
        public void CheckPipesAndCables()
        {
            bool isok        = true;
            var  report      = new StringBuilder();
            var  scenesGUIDs = AssetDatabase.FindAssets("t:Scene");
            var  scenesPaths = scenesGUIDs.Select(AssetDatabase.GUIDToAssetPath);
            List <ElectricalCableTile> Cables = new List <ElectricalCableTile>();

            foreach (var scene in scenesPaths)
            {
                if (scene.Contains("DevScenes") || scene.StartsWith("Packages"))
                {
                    continue;
                }

                var Openedscene = EditorSceneManager.OpenScene(scene);
                //report.AppendLine($"Checking {scene}");
                //Logger.Log($"Checking {scene}", Category.Tests);
                var Matrices = UnityEngine.Object.FindObjectsOfType <UnderFloorLayer>();

                foreach (var Underfloor in Matrices)
                {
                    BoundsInt bounds = Underfloor.Tilemap.cellBounds;

                    for (int n = bounds.xMin; n < bounds.xMax; n++)
                    {
                        for (int p = bounds.yMin; p < bounds.yMax; p++)
                        {
                            Cables.Clear();
                            Vector3Int localPlace   = (new Vector3Int(n, p, 0));
                            bool[]     PipeDirCheck = new bool[4];

                            for (int i = 0; i < 50; i++)
                            {
                                localPlace.z = -i + 1;
                                var getTile = Underfloor.Tilemap.GetTile(localPlace) as LayerTile;
                                if (getTile != null)
                                {
                                    var electricalCableTile = getTile as ElectricalCableTile;
                                    if (electricalCableTile != null)
                                    {
                                        if (Cables.Contains(electricalCableTile))
                                        {
                                            isok = false;
                                            report.AppendLine(
                                                $"A Duplicate cables at ({n}, {p}) in {Underfloor.matrix.gameObject.scene.name} - {Underfloor.matrix.name} with another Cable Name -> {electricalCableTile.name}");

                                            Underfloor.Tilemap.SetTile(localPlace, null);
                                            Underfloor.Tilemap.SetColor(localPlace, Color.white);
                                            Underfloor.Tilemap.SetTransformMatrix(localPlace, Matrix4x4.identity);
                                        }
                                        Cables.Add(electricalCableTile);
                                    }

                                    var pipeTile = getTile as PipeTile;
                                    if (pipeTile != null)
                                    {
                                        var matrixStruct = Underfloor.Tilemap.GetTransformMatrix(localPlace);
                                        var connection   = PipeTile.GetRotatedConnection(pipeTile, matrixStruct);
                                        var pipeDir      = connection.Directions;
                                        for (var d = 0; d < pipeDir.Length; d++)
                                        {
                                            if (pipeDir[d].Bool)
                                            {
                                                if (PipeDirCheck[d])
                                                {
                                                    isok = false;
                                                    report.AppendLine(
                                                        $"A pipe is overlapping its connection at ({n}, {p}) in {Underfloor.matrix.gameObject.scene.name} - {Underfloor.matrix.name} with another pipe");
                                                    Underfloor.Tilemap.SetTile(localPlace, null);
                                                    Underfloor.Tilemap.SetColor(localPlace, Color.white);
                                                    Underfloor.Tilemap.SetTransformMatrix(localPlace, Matrix4x4.identity);
                                                    break;
                                                }
                                                PipeDirCheck[d] = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                EditorApplication.SaveScene();
            }

            if (isok == false)
            {
                Assert.Fail(report.ToString());
            }
        }
Exemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        group                 = GetComponent <GridLayoutGroup>();
        group.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
        group.constraintCount = columnTilesCount;

        for (int x = 0; x < columnTilesCount; x++)
        {
            for (int y = 0; y < rowTilesCount; y++)
            {
                if (x == 0 && y == 0)
                {
                    PipeTile go = Instantiate(pipeTile, this.transform);
                    go.currentDirection = circuits.Direction.right;
                    go.PipeActive       = true;
                    go.type             = circuits.TileType.start;
                }
                else if (x == columnTilesCount - 1 && y == rowTilesCount - 1)
                {
                    PipeTile go = Instantiate(pipeTile, this.transform);
                    go.currentDirection = circuits.Direction.right;
                    go.PipeActive       = false;
                    go.type             = circuits.TileType.end;
                }
                else
                {
                    PipeTile go = Instantiate(pipeTile, this.transform);
                    go.type             = ((circuits.TileType)Random.Range(2, 4));
                    go.currentDirection = circuits.Direction.up;
                    int direction = Random.Range(0, 4);

                    switch (go.type)
                    {
                    case circuits.TileType.start:
                        //go.typ
                        go.connections = new circuits.Direction[]
                        {
                            circuits.Direction.right
                        };
                        break;

                    case circuits.TileType.corner:
                        go.typeSprite       = cornerSprite;
                        go.typeSpriteActive = cornerSpriteActive;
                        go.PipeActive       = false;
                        go.connections      = new circuits.Direction[]
                        {
                            circuits.Direction.up,
                            circuits.Direction.right
                        };
                        for (int i = 0; i < direction; i++)
                        {
                            go.Rotate();
                        }
                        break;

                    case circuits.TileType.straight:
                        go.typeSprite       = straightSprite;
                        go.typeSpriteActive = straightSpriteActive;
                        go.PipeActive       = false;
                        go.connections      = new circuits.Direction[]
                        {
                            circuits.Direction.up,
                            circuits.Direction.down
                        };
                        if (direction % 2 == 1)
                        {
                            go.Rotate();
                        }
                        break;

                    case circuits.TileType.end:
                        go.typeSprite       = endSprite;
                        go.typeSpriteActive = endSpriteActive;
                        go.PipeActive       = false;
                        go.connections      = new circuits.Direction[]
                        {
                            circuits.Direction.left
                        };
                        break;
                    }
                }
            }
        }
    }