public AdjustableDelayGateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { int data = Terrain.ExtractData(subsystemElectricity.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z)); m_delaySteps = AdjustableDelayGateBlock.GetDelay(data); }
//假如以输入设备为中心 public MyElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace_) : base(subsystemElectricity, cellFace_) { cellFace = cellFace_; //保存输入设备的坐标 subsystemBlockEntities = subsystemElectricity.Project.FindSubsystem <SubsystemBlockEntities>(); //获取该设备的实体 cptBase = subsystemBlockEntities.GetBlockEntity(cellFace.X, cellFace.Y, cellFace.Z).Entity.FindComponent <ComponentEnergyMachine>(true); cptBase.connections = subsystemItemElectric.getConlist(SubsystemElectricity.SubsystemTerrain.Terrain, cellFace.Point); }
public SRLatchElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { float?num = subsystemElectricity.ReadPersistentVoltage(cellFace.Point); if (num.HasValue) { m_voltage = num.Value; } }
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.Top || connectorDirection == ElectricConnectorDirection.Right || connectorDirection == ElectricConnectorDirection.Left || connectorDirection == ElectricConnectorDirection.Bottom || connectorDirection == ElectricConnectorDirection.In) { return(ElectricConnectorType.Output); } } return(null); }
public override bool Simulate() { float voltage = m_voltage; int num = 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.Top) { if (ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace))) { num |= 1; } } else if (connectorDirection == ElectricConnectorDirection.Right) { if (ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace))) { num |= 2; } } else if (connectorDirection == ElectricConnectorDirection.Bottom) { if (ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace))) { num |= 4; } } else if (connectorDirection == ElectricConnectorDirection.Left && ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace))) { num |= 8; } } } } TruthTableData blockData = m_subsystemTruthTableCircuitBlockBehavior.GetBlockData(base.CellFaces[0].Point); m_voltage = ((blockData != null) ? ((float)(int)blockData.Data[num] / 15f) : 0f); return(m_voltage != voltage); }
public override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer) { int data = Terrain.ExtractData(value); int voltageLevel = BatteryBlock.GetVoltageLevel(data); DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditBatteryDialog(voltageLevel, delegate(int newVoltageLevel) { int num = BatteryBlock.SetVoltageLevel(data, newVoltageLevel); if (num != data) { int value2 = Terrain.ReplaceData(value, num); base.SubsystemTerrain.ChangeCell(x, y, z, value2); SubsystemElectricity subsystemElectricity = base.Project.FindSubsystem <SubsystemElectricity>(throwOnError: true); ElectricElement electricElement = subsystemElectricity.GetElectricElement(x, y, z, 4); if (electricElement != null) { subsystemElectricity.QueueElectricElementConnectionsForSimulation(electricElement, subsystemElectricity.CircuitStep + 1); } } })); return(true); }
public override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer) { int data = Terrain.ExtractData(value); int delay = AdjustableDelayGateBlock.GetDelay(data); DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditAdjustableDelayGateDialog(delay, delegate(int newDelay) { int num = AdjustableDelayGateBlock.SetDelay(data, newDelay); if (num != data) { int value2 = Terrain.ReplaceData(value, num); base.SubsystemTerrain.ChangeCell(x, y, z, value2); int face = ((AdjustableDelayGateBlock)BlocksManager.Blocks[224]).GetFace(value); SubsystemElectricity subsystemElectricity = base.Project.FindSubsystem <SubsystemElectricity>(throwOnError: true); ElectricElement electricElement = subsystemElectricity.GetElectricElement(x, y, z, face); if (electricElement != null) { subsystemElectricity.QueueElectricElementForSimulation(electricElement, subsystemElectricity.CircuitStep + 1); } } })); return(true); }
public override ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z) { return(new NorGateElectricElement(subsystemElectricity, new CellFace(x, y, z, GetFace(value)))); }
public TruthTableCircuitElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { m_subsystemTruthTableCircuitBlockBehavior = subsystemElectricity.Project.FindSubsystem <SubsystemTruthTableCircuitBlockBehavior>(throwOnError: true); }
public DetonatorElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
public UnloaderElectricElement(SubsystemElectricity subsystemElectricity, Point3 point) : base(subsystemElectricity, point) { }
public override bool Simulate() { float voltage = m_voltage; bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = 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) { flag2 = ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection == ElectricConnectorDirection.Left) { flag = ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); } else if (connectorDirection == ElectricConnectorDirection.Bottom) { flag3 = ElectricElement.IsSignalHigh(connection.NeighborElectricElement.GetOutputVoltage(connection.NeighborConnectorFace)); flag4 = true; } } } } if (flag4) { if (flag3 && m_clockAllowed) { m_clockAllowed = false; if (flag && flag2) { m_voltage = ((!ElectricElement.IsSignalHigh(m_voltage)) ? 1 : 0); } else if (flag) { m_voltage = 1f; } else if (flag2) { m_voltage = 0f; } } } else if (flag && m_setAllowed) { m_setAllowed = false; m_voltage = 1f; } else if (flag2 && m_resetAllowed) { m_resetAllowed = false; m_voltage = 0f; } if (!flag3) { m_clockAllowed = true; } if (!flag) { m_setAllowed = true; } if (!flag2) { m_resetAllowed = true; } if (m_voltage != voltage) { base.SubsystemElectricity.WritePersistentVoltage(base.CellFaces[0].Point, m_voltage); return(true); } return(false); }
public virtual ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z) { return(null); }
public FenceGateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { m_lastChangeCircuitStep = base.SubsystemElectricity.CircuitStep; m_needsReset = true; }
public GunpowderKegElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
public HygrometerElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
public SolarGeneratorElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
public ChristmasTreeElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace, int value) : base(subsystemElectricity, cellFace) { m_lastChangeCircuitStep = base.SubsystemElectricity.CircuitStep; m_voltage = (ChristmasTreeBlock.GetLightState(Terrain.ExtractData(value)) ? 1 : 0); }
public abstract ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z);
public override ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z) { return(new DigitalToAnalogConverterElectricElement(subsystemElectricity, new CellFace(x, y, z, GetFace(value)))); }
public DelayGateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
public ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z) {//创建电子元件元素 return(GetItem(ref value).CreateElectricElement(subsystemElectricity, value, x, y, z)); }