public override void Destroy(bool modifyLevel = false) { output.Destroy(); output = null; input.Destroy(); input = null; base.Destroy(modifyLevel); }
public Wire(PowerConnection input, PowerConnection output) { this.input = input; this.output = output; Power.wires.Add(this); color = Color.DarkRed; }
public PowerModule(Cell cell, bool removable = true) : base(cell, removable) { inputModulePosition = cell.ToVector2() + new Vector2(0, 3 * 8); outputModulePosition = cell.ToVector2() - new Vector2(0, 3 * 8); input = new PowerConnection(inputModulePosition, Connection.Input, 0, OnInputConnected, OnInputUpdate); output = new PowerConnection(outputModulePosition, Connection.Output, 0, OnOutputConnected); //Power.powerModules.Add(this); }
public Lever(Cell cell) : base(cell) { if (!Cell.GetCell(cell).isEmpty) { return; } state = false; texture = Textures.LeverDeactive; power = new PowerConnection(cell.ToVector2(), Connection.Output, 0, OnConnected); }
public TurnRail(Cell cell, TurnDirection turnDirection, bool removable = true) : base(cell, removable) { turnDir = turnDirection; texture = Textures.RailTurn; orientation = GetEffects(turnDir); if (cell.isEmpty) { power = new PowerConnection(cell.ToVector2(), Connection.Input, 1, null, OnSignalUpdate); } }
public PushRail(Cell cell, Orientation orientation, bool removable = true) : base(cell, orientation, removable) { texture = Textures.RailPush; power = new PowerConnection(cell.ToVector2(), Connection.Input, 0, null, OnSignalUpdate); }
public DetectorRail(Cell cell, Orientation orientation, bool removable = true) : base(cell, orientation, removable) { texture = Textures.RailDetector; power = new PowerConnection(cell.ToVector2(), Connection.Output, 0); }
public void Connect(PowerConnection connection) { Wire newWire = null; switch (this.connection) { case Connection.Input: if (wires.Count < 1) { newWire = new Wire(this, connection); } else { return; } break; case Connection.Output: //if (!wires.Contains(new Wire(connection, this))) newWire = new Wire(connection, this); break; default: break; } if (wires.Contains(newWire)) { return; } if (connection.connection == Connection.Input) { if (connection.wires.Count < 1) { connection.wires.Add(newWire); } else { return; } } else if (connection.connection == Connection.Output) { connection.wires.Add(newWire); } wires.Add(newWire); connection.connected = true; connected = true; onConnected?.Invoke(); switch (this.connection) { case Connection.Input: newWire.output.onConnected?.Invoke(); break; case Connection.Output: newWire.input.onConnected?.Invoke(); break; default: break; } }