public void OnLogicValueChanged(object data)
 {
     if (!((UnityEngine.Object)ports == (UnityEngine.Object)null) && !((UnityEngine.Object)base.gameObject == (UnityEngine.Object)null) && !((UnityEngine.Object) this == (UnityEngine.Object)null))
     {
         LogicValueChanged logicValueChanged = (LogicValueChanged)data;
         if (logicValueChanged.portID != READ_PORT_ID)
         {
             int inputValue  = ports.GetInputValue(SET_PORT_ID);
             int inputValue2 = ports.GetInputValue(RESET_PORT_ID);
             int num         = value;
             if (inputValue2 == 1)
             {
                 num = 0;
             }
             else if (inputValue == 1)
             {
                 num = 1;
             }
             if (num != value)
             {
                 value = num;
                 ports.SendSignal(READ_PORT_ID, value);
                 KBatchedAnimController component = GetComponent <KBatchedAnimController>();
                 if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                 {
                     component.Play((num == 0) ? "off" : "on", KAnim.PlayMode.Once, 1f, 0f);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        protected override void OnLogicValueChanged(LogicValueChanged data)
        {
            if (data.portID == FourBitLogic.GREATER_THAN || data.portID == FourBitLogic.LESS_THAN)
            {
                return;
            }

            int input1 = ports.GetInputValue(FourBitLogic.INPUT_1) & 0xf;
            int input2 = ports.GetInputValue(FourBitLogic.INPUT_2) & 0xf;

            bool newGreaterThan = input1 > input2;
            bool newLessThan    = input1 < input2;

            if (newGreaterThan != greaterThan)
            {
                greaterThan = newGreaterThan;
                ports.SendSignal(FourBitLogic.GREATER_THAN, greaterThan ? 1 : 0);
            }

            if (newLessThan != lessThan)
            {
                lessThan = newLessThan;
                ports.SendSignal(FourBitLogic.LESS_THAN, lessThan ? 1 : 0);
            }

            KBatchedAnimController kbac = GetComponent <KBatchedAnimController>();

            if (kbac != null)
            {
                int value = (greaterThan ? 1 : 0) | (lessThan ? 2 : 0);
                kbac.Play($"on_{value}");
            }
        }
Exemplo n.º 3
0
        protected override void OnLogicValueChanged(LogicValueChanged data)
        {
            int value = ports.GetInputValue(FourBitLogic.INPUT_1) & 0xf;

            KBatchedAnimController controller = GetComponent <KBatchedAnimController>();

            controller.Play($"on_{value}");
        }
Exemplo n.º 4
0
    private void OnLogicValueChanged(object data)
    {
        LogicValueChanged logicValueChanged = (LogicValueChanged)data;

        if (logicValueChanged.portID == PORT_ID)
        {
            SetLogicMeter(logicValueChanged.newValue > 0);
        }
    }
Exemplo n.º 5
0
    private void OnLogicValueChanged(object data)
    {
        LogicValueChanged logicValueChanged = (LogicValueChanged)data;

        if (logicValueChanged.portID == PORT_ID)
        {
            LogicCircuitNetwork logicCircuitNetwork = CheckWireState();
            GetComponent <KSelectable>().ToggleStatusItem(infoStatusItem, logicCircuitNetwork != null, this);
        }
    }
        private void OnLogicValueChanged(object data)
        {
            LogicValueChanged logicValueChanged = (LogicValueChanged)data;

            if (!(logicValueChanged.portID != PORT_ID))
            {
                logic_on = (logicValueChanged.newValue != 0);
                UpdateShouldExtend();
            }
        }
Exemplo n.º 7
0
    private void OnLogicValueChanged(object data)
    {
        LogicValueChanged logicValueChanged = (LogicValueChanged)data;

        if (logicValueChanged.portID == PORT_ID)
        {
            hasInputHigh = (logicValueChanged.newValue > 0);
            hasLogicWire = (GetNetwork() != null);
            statusDirty  = true;
        }
    }
    public void OnLogicValueChanged(object data)
    {
        LogicValueChanged logicValueChanged = (LogicValueChanged)data;

        if (!(logicValueChanged.portID != OPEN_CLOSE_PORT_ID))
        {
            int newValue = logicValueChanged.newValue;
            if (changeStateChore != null)
            {
                changeStateChore.Cancel("Change state");
                changeStateChore = null;
            }
            requestedState   = ((newValue == 1) ? ControlState.Opened : ControlState.Locked);
            applyLogicChange = true;
        }
    }
Exemplo n.º 9
0
        protected override void OnLogicValueChanged(LogicValueChanged data)
        {
            if (data.portID == FourBitLogic.DATA)
            {
                return;
            }

            bool read  = (ports.GetInputValue(FourBitLogic.READ) & 0x1) == 0x1;
            bool write = (ports.GetInputValue(FourBitLogic.WRITE) & 0x1) == 0x1;

            int address1 = ports.GetInputValue(FourBitLogic.ADDRESS_1) & 0xf;
            int address2 = ports.GetInputValue(FourBitLogic.ADDRESS_2) & 0xf;
            int address  = address1 | (address2 << 4);

            Log.Spam($"R: {read}, W: {oldWrite} -> {write}, A: {address}");

            int dataOut = read ? memory[address] : 0;

            ports.SendSignal(FourBitLogic.DATA, dataOut);
            Log.Spam($"Read: {dataOut}");

            if (write && !oldWrite)
            {
                int dataIn = DataNetwork.OutputValue & 0xf;
                memory[address] = (byte)dataIn;
                Log.Spam($"Write: {dataIn}");
            }

            oldWrite = write;

            KBatchedAnimController kbac = GetComponent <KBatchedAnimController>();

            if (kbac != null)
            {
                int value = (read ? 1 : 0) | (write ? 2 : 0);
                kbac.Play($"on_{value}");
            }
        }
Exemplo n.º 10
0
        protected override void OnLogicValueChanged(LogicValueChanged data)
        {
            if (data.portID == FourBitLogic.CARRY_OUT || data.portID == FourBitLogic.OUTPUT_1)
            {
                return;
            }

            int carryIn = ports.GetInputValue(FourBitLogic.CARRY_IN) & 0x1;
            int input1  = ports.GetInputValue(FourBitLogic.INPUT_1) & 0xf;
            int input2  = ports.GetInputValue(FourBitLogic.INPUT_2) & 0xf;

            int  newOutput   = carryIn + input1 + input2;
            bool newCarryOut = newOutput > 0xf;

            newOutput &= 0xf;

            if (newOutput != output)
            {
                output = newOutput;
                ports.SendSignal(FourBitLogic.OUTPUT_1, output);
            }

            if (newCarryOut != carryOut)
            {
                carryOut = newCarryOut;
                ports.SendSignal(FourBitLogic.CARRY_OUT, carryOut ? 1 : 0);
            }

            KBatchedAnimController kbac = GetComponent <KBatchedAnimController>();

            if (kbac != null)
            {
                int value = carryIn | (carryOut ? 2 : 0);
                kbac.Play($"on_{value}");
            }
        }
Exemplo n.º 11
0
 protected virtual void OnLogicValueChanged(LogicValueChanged data)
 {
 }