public override void OnBlockRemoved(int value, int newValue, int x, int y, int z) { if (DoorBlock.IsTopPart(base.SubsystemTerrain.Terrain, x, y, z)) { base.SubsystemTerrain.ChangeCell(x, y - 1, z, 0); } if (DoorBlock.IsBottomPart(base.SubsystemTerrain.Terrain, x, y, z)) { base.SubsystemTerrain.ChangeCell(x, y + 1, z, 0); } }
public bool IsDoorElectricallyConnected(int x, int y, int z) { int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z); int num = Terrain.ExtractContents(cellValue); int data = Terrain.ExtractData(cellValue); if (BlocksManager.Blocks[num] is DoorBlock) { int num2 = DoorBlock.IsBottomPart(base.SubsystemTerrain.Terrain, x, y, z) ? y : (y - 1); for (int i = num2; i <= num2 + 1; i++) { ElectricElement electricElement = m_subsystemElectricity.GetElectricElement(x, i, z, DoorBlock.GetHingeFace(data)); if (electricElement != null && electricElement.Connections.Count > 0) { return(true); } } } return(false); }
public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) { int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z); int num = Terrain.ExtractContents(cellValue); Block obj = BlocksManager.Blocks[num]; int data = Terrain.ExtractData(cellValue); if (!(obj is DoorBlock)) { return; } if (neighborX == x && neighborY == y && neighborZ == z) { if (DoorBlock.IsBottomPart(base.SubsystemTerrain.Terrain, x, y, z)) { int value = Terrain.ReplaceData(base.SubsystemTerrain.Terrain.GetCellValue(x, y + 1, z), data); base.SubsystemTerrain.ChangeCell(x, y + 1, z, value); } if (DoorBlock.IsTopPart(base.SubsystemTerrain.Terrain, x, y, z)) { int value2 = Terrain.ReplaceData(base.SubsystemTerrain.Terrain.GetCellValue(x, y - 1, z), data); base.SubsystemTerrain.ChangeCell(x, y - 1, z, value2); } } if (DoorBlock.IsBottomPart(base.SubsystemTerrain.Terrain, x, y, z)) { int cellContents = base.SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z); if (BlocksManager.Blocks[cellContents].IsTransparent) { base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false); } } if (!DoorBlock.IsBottomPart(base.SubsystemTerrain.Terrain, x, y, z) && !DoorBlock.IsTopPart(base.SubsystemTerrain.Terrain, x, y, z)) { base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false); } }