BinhlEmul.World.SetPortValue C# (CSharp) Method

SetPortValue() public method

public SetPortValue ( string portName, bool value ) : void
portName string
value bool
return void
        public void SetPortValue(string portName, bool value)
        {
            foreach (IoPort port in inPorts.Where(port => port.Name == portName))
            {
                port.Value = value;
                if (value)
                {
                    _objectMatrix[port.X, port.Y, port.Z].RedValue = 15;
                    _objectMatrix[port.X, port.Y, port.Z].IsActivated = true;
                }
                else
                {
                    _objectMatrix[port.X, port.Y, port.Z].RedValue = 0;
                    _objectMatrix[port.X, port.Y, port.Z].IsActivated = false;
                }
            }
        }

Usage Example

示例#1
0
 private static void FSet(World world, string str)
 {
     string[] fargs = Regex.Match(str, @"\(.*?\)").Value.Replace("(", "").Replace(")", "").Trim().Split(',');
     string port = fargs[0].Trim();
     bool value = Convert.ToInt32(fargs[1].Trim()) == 1;
     world.SetPortValue(port, value);
 }