Пример #1
0
        public void OnLogicValueChanged(object data)
        {
            var logicValueChanged = (LogicValueChanged)data;

            //if (logicValueChanged.portID != NotificationTriggerConfig.InputPortId)
            //		return;

            if (LogicCircuitNetwork.IsBitActive(0, logicValueChanged.newValue))
            {
                if (this.wasOn)
                {
                    return;
                }
                //	this.Toggle; ???
                this.wasOn = true;
                if (WillPause && !SpeedControlScreen.Instance.IsPaused)
                {
                    SpeedControlScreen.Instance.Pause(false);
                }

                this.UpdateVisualState();
            }
            else
            {
                if (!this.wasOn)
                {
                    return;
                }
                this.wasOn = false;
                this.UpdateVisualState();
            }
        }
Пример #2
0
    private LogicCircuitNetwork CheckWireState()
    {
        LogicCircuitNetwork network = GetNetwork();
        int num = network?.OutputValue ?? unNetworkedValue;

        GetComponent <Operational>().SetFlag(logicOperationalFlag, num > 0);
        return(network);
    }
Пример #3
0
    public bool IsPortConnected(HashedString port_id)
    {
        int portCell = GetPortCell(port_id);
        LogicCircuitManager logicCircuitManager = Game.Instance.logicCircuitManager;
        LogicCircuitNetwork networkForCell      = logicCircuitManager.GetNetworkForCell(portCell);

        return(networkForCell != null);
    }
Пример #4
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);
        }
    }
Пример #5
0
    public bool GetPortConnected(PortId port)
    {
        if (port == PortId.InputTwo && !base.RequiresTwoInputs)
        {
            return(false);
        }
        int cell = PortCell(port);
        LogicCircuitManager logicCircuitManager = Game.Instance.logicCircuitManager;
        LogicCircuitNetwork networkForCell      = logicCircuitManager.GetNetworkForCell(cell);

        return(networkForCell != null);
    }
Пример #6
0
        private void OnLogicValueChanged(object data)
        {
            var logicValueChanged = (LogicValueChanged)data;

            if (logicValueChanged.portID == OPEN_CLOSE_PORT_ID)
            {
                int newValue = logicValueChanged.newValue;
                if (changeStateChore != null)
                {
                    changeStateChore.Cancel("Automation state change");
                    changeStateChore = null;
                }
                // Bit 0 green: automatic, bit 0 red: lock the door
                requestedState = !LogicCircuitNetwork.IsBitActive(0, newValue);
            }
        }
Пример #7
0
    private void TriggerAudio(int new_value)
    {
        LogicCircuitNetwork networkForCell = Game.Instance.logicCircuitManager.GetNetworkForCell(cell);
        SpeedControlScreen  instance       = SpeedControlScreen.Instance;

        if (networkForCell != null && new_value != value && (UnityEngine.Object)instance != (UnityEngine.Object)null && !instance.IsPaused && (!KPlayerPrefs.HasKey(AudioOptionsScreen.AlwaysPlayAutomation) || KPlayerPrefs.GetInt(AudioOptionsScreen.AlwaysPlayAutomation) == 1 || !(OverlayScreen.Instance.GetMode() != OverlayModes.Logic.ID)))
        {
            string name = "Logic_Building_Toggle";
            if (CameraController.Instance.IsAudibleSound(Grid.CellToPosCCC(cell, Grid.SceneLayer.BuildingFront)))
            {
                EventInstance instance2 = KFMOD.BeginOneShot(GlobalAssets.GetSound(name, false), Grid.CellToPos(cell));
                instance2.setParameterValue("wireCount", (float)(networkForCell.Wires.Count % 24));
                instance2.setParameterValue("enabled", (float)new_value);
                KFMOD.EndOneShot(instance2);
            }
        }
    }
Пример #8
0
 private void OnDelay()
 {
     if (!cleaningUp)
     {
         delayTicksRemaining = 0;
         meter.SetPositionPercent(1f);
         if (outputValue != 0)
         {
             int outputCell = base.OutputCell;
             LogicCircuitNetwork logicCircuitNetwork = Game.Instance.logicCircuitSystem.GetNetworkForCell(outputCell) as LogicCircuitNetwork;
             if (logicCircuitNetwork != null)
             {
                 outputValue = 0;
                 RefreshAnimation();
             }
         }
     }
 }
Пример #9
0
        static bool IsLogicCellActive(int cell, LogicCircuitNetwork networkForCell)
        {
            // If there's only 1 sender on the network then it's impossible for another to be overwriting it
            if (networkForCell.Senders.Count <= 1)
            {
                return(true);
            }

            foreach (var sender in networkForCell.Senders)
            {
                if (sender.GetLogicCell() == cell)
                {
                    if (sender.GetLogicValue() <= 0)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
            return(true);
        }
Пример #10
0
 protected void RefreshAnimation()
 {
     if (!cleaningUp)
     {
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         int outputCell = base.OutputCell;
         LogicCircuitNetwork logicCircuitNetwork = Game.Instance.logicCircuitSystem.GetNetworkForCell(outputCell) as LogicCircuitNetwork;
         if (logicCircuitNetwork == null)
         {
             component.Play("off", KAnim.PlayMode.Once, 1f, 0f);
         }
         else if (base.RequiresTwoInputs)
         {
             component.Play("on_" + (inputOne.Value + inputTwo.Value * 2 + outputValue * 4).ToString(), KAnim.PlayMode.Once, 1f, 0f);
         }
         else
         {
             component.Play("on_" + (inputOne.Value + outputValue * 4).ToString(), KAnim.PlayMode.Once, 1f, 0f);
         }
     }
 }
Пример #11
0
    private bool ShowMissingWireIcon()
    {
        LogicCircuitManager logicCircuitManager = Game.Instance.logicCircuitManager;

        if (outputPortInfo != null)
        {
            for (int i = 0; i < outputPortInfo.Length; i++)
            {
                Port port = outputPortInfo[i];
                if (port.requiresConnection)
                {
                    int portCell = GetPortCell(port.id);
                    LogicCircuitNetwork networkForCell = logicCircuitManager.GetNetworkForCell(portCell);
                    if (networkForCell == null)
                    {
                        return(true);
                    }
                }
            }
        }
        if (inputPortInfo != null)
        {
            for (int j = 0; j < inputPortInfo.Length; j++)
            {
                Port port2 = inputPortInfo[j];
                if (port2.requiresConnection)
                {
                    int portCell2 = GetPortCell(port2.id);
                    LogicCircuitNetwork networkForCell2 = logicCircuitManager.GetNetworkForCell(portCell2);
                    if (networkForCell2 == null)
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Пример #12
0
 static bool IsBitActiveWrapper(LogicCircuitNetwork networkForCell, int bit, int cell) => networkForCell.IsBitActive(bit) && IsLogicCellActive(cell, networkForCell);