public override bool Simulate() { float voltage = m_voltage; m_voltage = 0f; int rotation = base.Rotation; foreach (ElectricConnection connection in base.Connections) { if (connection.ConnectorType != ElectricConnectorType.Output && connection.NeighborConnectorType != 0 && ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace))) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, rotation, connection.ConnectorFace); if (connectorDirection.HasValue) { if (connectorDirection.Value == ElectricConnectorDirection.Top) { m_voltage += 71f / (339f * (float)Math.PI); } if (connectorDirection.Value == ElectricConnectorDirection.Right) { m_voltage += 142f / (339f * (float)Math.PI); } if (connectorDirection.Value == ElectricConnectorDirection.Bottom) { m_voltage += 4f / 15f; } if (connectorDirection.Value == ElectricConnectorDirection.Left) { m_voltage += 8f / 15f; } } } } return(m_voltage != voltage); }
public ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { int data = Terrain.ExtractData(value); int rotation = GetRotation(data); int designIndex = GetDesignIndex(data); FurnitureDesign design = terrain.SubsystemFurnitureBlockBehavior.GetDesign(designIndex); if (design != null) { int num = CellFace.OppositeFace((face < 4) ? ((face - rotation + 4) % 4) : face); if ((design.MountingFacesMask & (1 << num)) != 0 && SubsystemElectricity.GetConnectorDirection(face, 0, connectorFace).HasValue) { Point3 point = CellFace.FaceToPoint3(face); int cellValue = terrain.Terrain.GetCellValue(x - point.X, y - point.Y, z - point.Z); if (!BlocksManager.Blocks[Terrain.ExtractContents(cellValue)].IsFaceTransparent(terrain, CellFace.OppositeFace(num), cellValue)) { if (design.InteractionMode == FurnitureInteractionMode.Multistate || design.InteractionMode == FurnitureInteractionMode.ConnectedMultistate) { return(ElectricConnectorType.Input); } if (design.InteractionMode == FurnitureInteractionMode.ElectricButton || design.InteractionMode == FurnitureInteractionMode.ElectricSwitch) { return(ElectricConnectorType.Output); } } } } return(null); }
public override float GetOutputVoltage(int face) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, base.Rotation, face); if (connectorDirection.HasValue) { if (connectorDirection.Value == ElectricConnectorDirection.Top) { return((float)(GetClockValue() & 0xF) / 15f); } if (connectorDirection.Value == ElectricConnectorDirection.Right) { return((float)((GetClockValue() >> 4) & 0xF) / 15f); } if (connectorDirection.Value == ElectricConnectorDirection.Bottom) { return((float)((GetClockValue() >> 8) & 0xF) / 15f); } if (connectorDirection.Value == ElectricConnectorDirection.Left) { return((float)((GetClockValue() >> 12) & 0xF) / 15f); } if (connectorDirection.Value == ElectricConnectorDirection.In) { return((float)((GetClockValue() >> 16) & 0xF) / 15f); } } return(0f); }
public override float GetOutputVoltage(int face) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, base.Rotation, face); if (connectorDirection.HasValue) { if (connectorDirection.Value == ElectricConnectorDirection.Top) { return(((m_bits & 1) != 0) ? 1 : 0); } if (connectorDirection.Value == ElectricConnectorDirection.Right) { return(((m_bits & 2) != 0) ? 1 : 0); } if (connectorDirection.Value == ElectricConnectorDirection.Bottom) { return(((m_bits & 4) != 0) ? 1 : 0); } if (connectorDirection.Value == ElectricConnectorDirection.Left) { return(((m_bits & 8) != 0) ? 1 : 0); } } return(0f); }
public ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { if (face == 4 && SubsystemElectricity.GetConnectorDirection(4, 0, connectorFace).HasValue) { return(ElectricConnectorType.Output); } return(null); }
public ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { int data = Terrain.ExtractData(value); if (face != GetFace(data) || !SubsystemElectricity.GetConnectorDirection(face, 0, connectorFace).HasValue) { return(null); } return(ElectricConnectorType.Input); }
public override ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { int face2 = GetFace(value); if (face == face2 && SubsystemElectricity.GetConnectorDirection(face2, 0, connectorFace).HasValue) { return(ElectricConnectorType.Input); } return(null); }
public ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { int data = Terrain.ExtractData(value); if (face == GetMountingFace(data)) { int rotation = GetRotation(data); if (SubsystemElectricity.GetConnectorDirection(4, (4 - rotation) % 4, connectorFace) == ElectricConnectorDirection.Top) { return(ElectricConnectorType.Input); } } return(null); }
public ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { int hingeFace = GetHingeFace(Terrain.ExtractData(value)); if (face == hingeFace) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(hingeFace, 0, connectorFace); if (connectorDirection == ElectricConnectorDirection.Right || connectorDirection == ElectricConnectorDirection.Left || connectorDirection == ElectricConnectorDirection.In) { return(ElectricConnectorType.Input); } } return(null); }
public ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { if (GetHanging(Terrain.ExtractData(value))) { if (face != 5 || !SubsystemElectricity.GetConnectorDirection(face, 0, connectorFace).HasValue) { return(null); } return(ElectricConnectorType.Input); } if (face != 4 || !SubsystemElectricity.GetConnectorDirection(face, 0, connectorFace).HasValue) { return(null); } return(ElectricConnectorType.Input); }
public override float GetOutputVoltage(int face) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, base.Rotation, face); if (connectorDirection.HasValue) { if (connectorDirection.Value == ElectricConnectorDirection.Top) { return((float)m_counter / 15f); } if (connectorDirection.Value == ElectricConnectorDirection.Bottom) { return(m_overflow ? 1 : 0); } } return(0f); }
public override ElectricConnectorType?GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) { int data = Terrain.ExtractData(value); if (GetFace(value) == face) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(GetFace(value), RotateableMountedElectricElementBlock.GetRotation(data), connectorFace); if (connectorDirection == ElectricConnectorDirection.Bottom) { return(ElectricConnectorType.Input); } if (connectorDirection == ElectricConnectorDirection.Top || connectorDirection == ElectricConnectorDirection.In) { return(ElectricConnectorType.Output); } } return(null); }
public override bool Simulate() { int bits = m_bits; int rotation = base.Rotation; foreach (ElectricConnection connection in base.Connections) { if (connection.ConnectorType != ElectricConnectorType.Output && connection.NeighborConnectorType != 0) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, rotation, connection.ConnectorFace); if (connectorDirection.HasValue && connectorDirection.Value == ElectricConnectorDirection.In) { float outputVoltage = connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace); m_bits = (int)MathUtils.Round(outputVoltage * 15f); } } } return(m_bits != bits); }
public override bool Simulate() { int num = 0; int num2 = 15; int num3 = 2; int num4 = 0; int rotation = base.Rotation; foreach (ElectricConnection connection in base.Connections) { if (connection.ConnectorType != ElectricConnectorType.Output && connection.NeighborConnectorType != 0) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, rotation, connection.ConnectorFace); if (connectorDirection.HasValue) { if (connectorDirection.Value == ElectricConnectorDirection.In || connectorDirection.Value == ElectricConnectorDirection.Bottom) { num4 = (int)MathUtils.Round(15f * connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection.Value == ElectricConnectorDirection.Left) { num = (int)MathUtils.Round(15f * connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection.Value == ElectricConnectorDirection.Right) { num3 = (int)MathUtils.Round(15f * connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection.Value == ElectricConnectorDirection.Top) { num2 = (int)MathUtils.Round(15f * connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } } } } if (m_lastToneInput == 0 && num4 != 0 && num != 15 && base.SubsystemElectricity.SubsystemTime.GameTime >= m_playAllowedTime) { m_playAllowedTime = base.SubsystemElectricity.SubsystemTime.GameTime + 0.079999998211860657; string text = m_tones[num4]; float num5 = 0f; string text2 = null; if (text == "Drums") { num5 = 1f; if (num >= 0 && num < m_drums.Length) { text2 = $"Audio/SoundGenerator/Drums{m_drums[num]}"; } } else if (!string.IsNullOrEmpty(text)) { float num6 = 130.8125f * MathUtils.Pow(1.05946314f, num + 12 * num3); int num7 = 0; for (int i = 4; i <= m_maxOctaves[num4]; i++) { float num8 = num6 / (523.25f * MathUtils.Pow(2f, i - 5)); if (num7 == 0 || (num8 >= 0.5f && num8 < num5)) { num7 = i; num5 = num8; } } text2 = $"Audio/SoundGenerator/{text}C{num7}"; } if (num5 != 0f && !string.IsNullOrEmpty(text2)) { CellFace cellFace = base.CellFaces[0]; Vector3 position = new Vector3(cellFace.X, cellFace.Y, cellFace.Z); float volume = (float)num2 / 15f; float pitch = MathUtils.Clamp(MathUtils.Log(num5) / MathUtils.Log(2f), -1f, 1f); float minDistance = 0.5f + 5f * (float)num2 / 15f; base.SubsystemElectricity.SubsystemAudio.PlaySound(text2, volume, pitch, position, minDistance, autoDelay: true); float loudness = (num2 < 8) ? 0.25f : 0.5f; float range = MathUtils.Lerp(2f, 20f, (float)num2 / 15f); m_subsystemNoise.MakeNoise(position, loudness, range); if (m_particleSystem.SubsystemParticles == null) { m_subsystemParticles.AddParticleSystem(m_particleSystem); } Vector3 hsv = new Vector3(22.5f * (float)num + m_random.Float(0f, 22f), 0.5f + (float)num2 / 30f, 1f); m_particleSystem.AddNote(new Color(Color.HsvToRgb(hsv))); } } m_lastToneInput = num4; return(false); }
public override bool Simulate() { float voltage = m_voltage; bool flag = false; bool flag2 = false; bool flag3 = false; float num = 0f; int num2 = 0; int num3 = 0; int rotation = base.Rotation; foreach (ElectricConnection connection in base.Connections) { if (connection.ConnectorType != ElectricConnectorType.Output && connection.NeighborConnectorType != 0) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, rotation, connection.ConnectorFace); if (connectorDirection.HasValue) { if (connectorDirection == ElectricConnectorDirection.Right) { num2 = (int)MathUtils.Round(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace) * 15f); } else if (connectorDirection == ElectricConnectorDirection.Left) { num3 = (int)MathUtils.Round(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace) * 15f); } else if (connectorDirection == ElectricConnectorDirection.Bottom) { int num4 = (int)MathUtils.Round(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace) * 15f); flag = (num4 >= 8); flag3 = (num4 > 0 && num4 < 8); flag2 = true; } else if (connectorDirection == ElectricConnectorDirection.In) { num = connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace); } } } } MemoryBankData memoryBankData = m_subsystemMemoryBankBlockBehavior.GetBlockData(base.CellFaces[0].Point); int address = num2 + (num3 << 4); if (flag2) { if (flag && m_clockAllowed) { m_clockAllowed = false; m_voltage = ((memoryBankData != null) ? ((float)(int)memoryBankData.Read(address) / 15f) : 0f); } else if (flag3 && m_writeAllowed) { m_writeAllowed = false; if (memoryBankData == null) { memoryBankData = new MemoryBankData(); m_subsystemMemoryBankBlockBehavior.SetBlockData(base.CellFaces[0].Point, memoryBankData); } memoryBankData.Write(address, (byte)MathUtils.Round(num * 15f)); } } else { m_voltage = ((memoryBankData != null) ? ((float)(int)memoryBankData.Read(address) / 15f) : 0f); } if (!flag) { m_clockAllowed = true; } if (!flag3) { m_writeAllowed = true; } if (memoryBankData != null) { memoryBankData.LastOutput = (byte)MathUtils.Round(m_voltage * 15f); } return(m_voltage != voltage); }
public static void GenerateWireVertices(BlockGeometryGenerator generator, int value, int x, int y, int z, int mountingFace, float centerBoxSize, Vector2 centerOffset, TerrainGeometrySubset subset) { var terrain = generator.Terrain; Color color = WireBlock.WireColor; int num = Terrain.ExtractContents(value); if (num == ElementBlock.Index) { int?color2 = PaintableItemBlock.GetColor(Terrain.ExtractData(value)); if (color2.HasValue) { color = SubsystemPalette.GetColor(generator, color2); } } float num3 = LightingManager.LightIntensityByLightValue[Terrain.ExtractLight(value)]; Vector3 v = new Vector3(x + 0.5f, y + 0.5f, z + 0.5f) - 0.5f * CellFace.FaceToVector3(mountingFace); Vector3 vector = CellFace.FaceToVector3(mountingFace); var v2 = new Vector2(0.9376f, 0.0001f); var v3 = new Vector2(0.03125f, 0.00550781237f); Point3 point = CellFace.FaceToPoint3(mountingFace); int cellContents = terrain.GetCellContents(x - point.X, y - point.Y, z - point.Z); bool flag = cellContents == 2 || cellContents == 7 || cellContents == 8 || cellContents == 6 || cellContents == 62 || cellContents == 72; Vector3 v4 = CellFace.FaceToVector3(SubsystemElectricity.GetConnectorFace(mountingFace, ElectricConnectorDirection.Top)); Vector3 vector2 = CellFace.FaceToVector3(SubsystemElectricity.GetConnectorFace(mountingFace, ElectricConnectorDirection.Left)) * centerOffset.X + v4 * centerOffset.Y; int num4 = 0; var paths = new DynamicArray <ElectricConnectionPath>(); ElementBlock.Block.GetAllConnectedNeighbors(terrain, ElementBlock.Block.GetDevice(x, y, z, value), mountingFace, paths); foreach (ElectricConnectionPath tmpConnectionPath in paths) { if ((num4 & (1 << tmpConnectionPath.ConnectorFace)) == 0) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(mountingFace, 0, tmpConnectionPath.ConnectorFace); if (centerOffset != Vector2.Zero || connectorDirection != ElectricConnectorDirection.In) { num4 |= 1 << tmpConnectionPath.ConnectorFace; Color color3 = color; if (num != ElementBlock.Index) { int cellValue = terrain.GetCellValue(x + tmpConnectionPath.NeighborOffsetX, y + tmpConnectionPath.NeighborOffsetY, z + tmpConnectionPath.NeighborOffsetZ); if (Terrain.ExtractContents(cellValue) == ElementBlock.Index) { int?color4 = PaintableItemBlock.GetColor(Terrain.ExtractData(cellValue)); if (color4.HasValue) { color3 = SubsystemPalette.GetColor(generator, color4); } } } Vector3 vector3 = (connectorDirection != ElectricConnectorDirection.In) ? CellFace.FaceToVector3(tmpConnectionPath.ConnectorFace) : (-Vector3.Normalize(vector2)); var vector4 = Vector3.Cross(vector, vector3); float s = (centerBoxSize >= 0f) ? MathUtils.Max(0.03125f, centerBoxSize / 2f) : (centerBoxSize / 2f); float num5 = (connectorDirection == ElectricConnectorDirection.In) ? 0.03125f : 0.5f; float num6 = (connectorDirection == ElectricConnectorDirection.In) ? 0f : ((tmpConnectionPath.ConnectorFace == tmpConnectionPath.NeighborFace) ? (num5 + 0.03125f) : ((tmpConnectionPath.ConnectorFace != CellFace.OppositeFace(tmpConnectionPath.NeighborFace)) ? num5 : (num5 - 0.03125f))); Vector3 vector5 = v - vector4 * 0.03125f + vector3 * s + vector2; Vector3 vector6 = v - vector4 * 0.03125f + vector3 * num5; Vector3 vector7 = v + vector4 * 0.03125f + vector3 * num5; Vector3 vector8 = v + vector4 * 0.03125f + vector3 * s + vector2; Vector3 vector9 = v + vector * 0.03125f + vector3 * (centerBoxSize / 2f) + vector2; Vector3 vector10 = v + vector * 0.03125f + vector3 * num6; if (flag && centerBoxSize == 0f) { Vector3 v5 = 0.25f * BlockGeometryGenerator.GetRandomWireOffset(0.5f * (vector5 + vector8), vector); vector5 += v5; vector8 += v5; vector9 += v5; } Vector2 vector11 = v2 + v3 * new Vector2(MathUtils.Max(0.0625f, centerBoxSize), 0f); Vector2 vector12 = v2 + v3 * new Vector2(num5 * 2f, 0f); Vector2 vector13 = v2 + v3 * new Vector2(num5 * 2f, 1f); Vector2 vector14 = v2 + v3 * new Vector2(MathUtils.Max(0.0625f, centerBoxSize), 1f); Vector2 vector15 = v2 + v3 * new Vector2(centerBoxSize, 0.5f); Vector2 vector16 = v2 + v3 * new Vector2(num6 * 2f, 0.5f); float num9 = 0.5f * (num3 + LightingManager.LightIntensityByLightValue[Terrain.ExtractLight(terrain.GetCellValue(x + tmpConnectionPath.NeighborOffsetX, y + tmpConnectionPath.NeighborOffsetY, z + tmpConnectionPath.NeighborOffsetZ))]); float num10 = LightingManager.CalculateLighting(-vector4); float num11 = LightingManager.CalculateLighting(vector4); float num12 = LightingManager.CalculateLighting(vector); float num13 = num10 * num3; float num14 = num10 * num9; float num15 = num11 * num9; float num16 = num11 * num3; float num17 = num12 * num3; float num18 = num12 * num9; var color5 = new Color((byte)(color3.R * num13), (byte)(color3.G * num13), (byte)(color3.B * num13)); var color6 = new Color((byte)(color3.R * num14), (byte)(color3.G * num14), (byte)(color3.B * num14)); var color7 = new Color((byte)(color3.R * num15), (byte)(color3.G * num15), (byte)(color3.B * num15)); var color8 = new Color((byte)(color3.R * num16), (byte)(color3.G * num16), (byte)(color3.B * num16)); var color9 = new Color((byte)(color3.R * num17), (byte)(color3.G * num17), (byte)(color3.B * num17)); var color10 = new Color((byte)(color3.R * num18), (byte)(color3.G * num18), (byte)(color3.B * num18)); int count = subset.Vertices.Count; subset.Vertices.Count += 6; TerrainVertex[] array = subset.Vertices.Array; BlockGeometryGenerator.SetupVertex(vector5.X, vector5.Y, vector5.Z, color5, vector11.X, vector11.Y, ref array[count]); BlockGeometryGenerator.SetupVertex(vector6.X, vector6.Y, vector6.Z, color6, vector12.X, vector12.Y, ref array[count + 1]); BlockGeometryGenerator.SetupVertex(vector7.X, vector7.Y, vector7.Z, color7, vector13.X, vector13.Y, ref array[count + 2]); BlockGeometryGenerator.SetupVertex(vector8.X, vector8.Y, vector8.Z, color8, vector14.X, vector14.Y, ref array[count + 3]); BlockGeometryGenerator.SetupVertex(vector9.X, vector9.Y, vector9.Z, color9, vector15.X, vector15.Y, ref array[count + 4]); BlockGeometryGenerator.SetupVertex(vector10.X, vector10.Y, vector10.Z, color10, vector16.X, vector16.Y, ref array[count + 5]); int count2 = subset.Indices.Count; subset.Indices.Count += (connectorDirection == ElectricConnectorDirection.In) ? 15 : 12; ushort[] array2 = subset.Indices.Array; array2[count2] = (ushort)count; array2[count2 + 1] = (ushort)(count + 5); array2[count2 + 2] = (ushort)(count + 1); array2[count2 + 3] = (ushort)(count + 5); array2[count2 + 4] = (ushort)count; array2[count2 + 5] = (ushort)(count + 4); array2[count2 + 6] = (ushort)(count + 4); array2[count2 + 7] = (ushort)(count + 2); array2[count2 + 8] = (ushort)(count + 5); array2[count2 + 9] = (ushort)(count + 2); array2[count2 + 10] = (ushort)(count + 4); array2[count2 + 11] = (ushort)(count + 3); if (connectorDirection == ElectricConnectorDirection.In) { array2[count2 + 12] = (ushort)(count + 2); array2[count2 + 13] = (ushort)(count + 1); array2[count2 + 14] = (ushort)(count + 5); } } } } if (centerBoxSize == 0f && (num4 != 0 || (num == ElementBlock.Index && (Terrain.ExtractData(value) & 1023) == 5))) { for (int i = 0; i < 6; i++) { if (i != mountingFace && i != CellFace.OppositeFace(mountingFace) && (num4 & (1 << i)) == 0) { Vector3 vector17 = CellFace.FaceToVector3(i); var v6 = Vector3.Cross(vector, vector17); Vector3 vector18 = v - v6 * 0.03125f + vector17 * 0.03125f; Vector3 vector19 = v + v6 * 0.03125f + vector17 * 0.03125f; Vector3 vector20 = v + vector * 0.03125f; if (flag) { Vector3 v7 = 0.25f * BlockGeometryGenerator.GetRandomWireOffset(0.5f * (vector18 + vector19), vector); vector18 += v7; vector19 += v7; vector20 += v7; } Vector2 vector21 = v2 + v3 * new Vector2(0.0625f, 0f); Vector2 vector22 = v2 + v3 * new Vector2(0.0625f, 1f); Vector2 vector23 = v2 + v3 * new Vector2(0f, 0.5f); float num19 = LightingManager.CalculateLighting(vector17) * num3; float num20 = LightingManager.CalculateLighting(vector) * num3; var color11 = new Color((byte)(color.R * num19), (byte)(color.G * num19), (byte)(color.B * num19)); var color12 = new Color((byte)(color.R * num20), (byte)(color.G * num20), (byte)(color.B * num20)); int count3 = subset.Vertices.Count; subset.Vertices.Count += 3; var array3 = subset.Vertices.Array; BlockGeometryGenerator.SetupVertex(vector18.X, vector18.Y, vector18.Z, color11, vector21.X, vector21.Y, ref array3[count3]); BlockGeometryGenerator.SetupVertex(vector19.X, vector19.Y, vector19.Z, color11, vector22.X, vector22.Y, ref array3[count3 + 1]); BlockGeometryGenerator.SetupVertex(vector20.X, vector20.Y, vector20.Z, color12, vector23.X, vector23.Y, ref array3[count3 + 2]); int count4 = subset.Indices.Count; subset.Indices.Count += 3; ushort[] array4 = subset.Indices.Array; array4[count4] = (ushort)count3; array4[count4 + 1] = (ushort)(count3 + 2); array4[count4 + 2] = (ushort)(count3 + 1); } } } }
public override bool Simulate() { int counter = m_counter; bool overflow = m_overflow; bool flag = false; bool flag2 = false; bool flag3 = false; int rotation = base.Rotation; foreach (ElectricConnection connection in base.Connections) { if (connection.ConnectorType != ElectricConnectorType.Output && connection.NeighborConnectorType != 0) { ElectricConnectorDirection?connectorDirection = SubsystemElectricity.GetConnectorDirection(base.CellFaces[0].Face, rotation, connection.ConnectorFace); if (connectorDirection.HasValue) { if (connectorDirection == ElectricConnectorDirection.Right) { flag = ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection == ElectricConnectorDirection.Left) { flag2 = ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection == ElectricConnectorDirection.In) { flag3 = ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } } } } if (flag && m_plusAllowed) { m_plusAllowed = false; if (m_counter < 15) { m_counter++; m_overflow = false; } else { m_counter = 0; m_overflow = true; } } else if (flag2 && m_minusAllowed) { m_minusAllowed = false; if (m_counter > 0) { m_counter--; m_overflow = false; } else { m_counter = 15; m_overflow = true; } } else if (flag3 && m_resetAllowed) { m_counter = 0; m_overflow = false; } if (!flag) { m_plusAllowed = true; } if (!flag2) { m_minusAllowed = true; } if (!flag3) { m_resetAllowed = true; } if (m_counter != counter || m_overflow != overflow) { base.SubsystemElectricity.WritePersistentVoltage(base.CellFaces[0].Point, (float)m_counter / 15f * (float)((!m_overflow) ? 1 : (-1))); return(true); } return(false); }