Пример #1
0
        public void GetAllConnectedNeighbors(int x, int y, int z, int mountingFace, DynamicArray <ElectricConnectionPath> list)
        {
            int cellValue = SubsystemTerrain.Terrain.GetCellValue(x, y, z);
            IElectricElementBlock electricElementBlock = BlocksManager.Blocks[Terrain.ExtractContents(cellValue)] as IElectricElementBlock;

            if (electricElementBlock == null)
            {
                return;
            }
            for (ElectricConnectorDirection electricConnectorDirection = ElectricConnectorDirection.Top; electricConnectorDirection < (ElectricConnectorDirection)5; electricConnectorDirection++)
            {
                for (int i = 0; i < 4; i++)
                {
                    ElectricConnectionPath electricConnectionPath = m_connectionPathsTable[20 * mountingFace + 4 * (int)electricConnectorDirection + i];
                    if (electricConnectionPath == null)
                    {
                        break;
                    }
                    ElectricConnectorType?connectorType = electricElementBlock.GetConnectorType(SubsystemTerrain, cellValue, mountingFace, electricConnectionPath.ConnectorFace, x, y, z);
                    if (!connectorType.HasValue)
                    {
                        break;
                    }
                    int x2         = x + electricConnectionPath.NeighborOffsetX;
                    int y2         = y + electricConnectionPath.NeighborOffsetY;
                    int z2         = z + electricConnectionPath.NeighborOffsetZ;
                    int cellValue2 = SubsystemTerrain.Terrain.GetCellValue(x2, y2, z2);
                    IElectricElementBlock electricElementBlock2 = BlocksManager.Blocks[Terrain.ExtractContents(cellValue2)] as IElectricElementBlock;
                    if (electricElementBlock2 == null)
                    {
                        continue;
                    }
                    ElectricConnectorType?connectorType2 = electricElementBlock2.GetConnectorType(SubsystemTerrain, cellValue2, electricConnectionPath.NeighborFace, electricConnectionPath.NeighborConnectorFace, x2, y2, z2);
                    if (connectorType2.HasValue && ((connectorType.Value != 0 && connectorType2.Value != ElectricConnectorType.Output) || (connectorType.Value != ElectricConnectorType.Output && connectorType2.Value != 0)))
                    {
                        int connectionMask  = electricElementBlock.GetConnectionMask(cellValue);
                        int connectionMask2 = electricElementBlock2.GetConnectionMask(cellValue2);
                        if ((connectionMask & connectionMask2) != 0)
                        {
                            list.Add(electricConnectionPath);
                        }
                    }
                }
            }
        }
Пример #2
0
 public static ElectricConnectionPath GetConnectionPath(int mountingFace, ElectricConnectorDirection localConnector, int neighborIndex)
 {
     return(m_connectionPathsTable[16 * mountingFace + 4 * (int)localConnector + neighborIndex]);
 }
Пример #3
0
 public static int GetConnectorFace(int mountingFace, ElectricConnectorDirection connectionDirection)
 {
     return(m_connectorFacesTable[(int)(5 * mountingFace + connectionDirection)]);
 }