Esempio n. 1
0
 public override void Destroy(bool modifyLevel = false)
 {
     output.Destroy();
     output = null;
     input.Destroy();
     input = null;
     base.Destroy(modifyLevel);
 }
Esempio n. 2
0
        public Wire(PowerConnection input, PowerConnection output)
        {
            this.input  = input;
            this.output = output;
            Power.wires.Add(this);

            color = Color.DarkRed;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public DetectorRail(Cell cell, Orientation orientation, bool removable = true) : base(cell, orientation, removable)
        {
            texture = Textures.RailDetector;

            power = new PowerConnection(cell.ToVector2(), Connection.Output, 0);
        }
Esempio n. 8
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;
            }
        }