Exemplo n.º 1
0
 public CoilDestConfig(ICoilDeviceComponent device, string deviceItem, bool isLampCoil, bool hasDynamicWire)
 {
     Device         = device;
     DeviceItem     = deviceItem;
     IsLampCoil     = isLampCoil;
     HasDynamicWire = hasDynamicWire;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Links a coil device to an existing coil mapping.
        /// </summary>
        /// <param name="tableComponent">Table component for retrieving mappings.</param>
        /// <param name="coilId">The ID of the coil mapping that the coil device will be linked to</param>
        /// <param name="coilDevice">The coil device to be linked</param>
        /// <param name="deviceItem">If set, it's the device item, otherwise the first item of the device.</param>
        protected static void LinkCoil(TableComponent tableComponent, string coilId, ICoilDeviceComponent coilDevice, string deviceItem = null)
        {
            var coilMapping = tableComponent.MappingConfig.Coils.FirstOrDefault(cm => cm.Id == coilId);

            if (coilMapping == null)
            {
                return;
            }
            coilMapping.Device     = coilDevice;
            coilMapping.DeviceItem = deviceItem ?? coilDevice.AvailableCoils.First().Id;
        }
Exemplo n.º 3
0
        public CoilListData(CoilMapping coilMapping)
        {
            Id          = coilMapping.Id;
            Description = coilMapping.Description;
            Destination = coilMapping.Destination;
            Device      = coilMapping.Device;
            if (string.IsNullOrEmpty(coilMapping.DeviceItem) && Device != null && Device.AvailableCoils.Count() == 1)
            {
                DeviceItem = Device.AvailableCoils.First().Id;
            }
            else
            {
                DeviceItem = coilMapping.DeviceItem;
            }

            CoilMapping = coilMapping;
        }
Exemplo n.º 4
0
        private static GamelogicEngineCoil GuessCoilDeviceItem(IGamelogicEngineDeviceItem engineCoil, ICoilDeviceComponent device)
        {
            // if only one device item available, it's the one.
            if (device.AvailableCoils.Count() == 1 && string.IsNullOrEmpty(engineCoil.DeviceItemHint))
            {
                return(device.AvailableCoils.First());
            }

            // no hint, no guess..
            if (string.IsNullOrEmpty(engineCoil.DeviceItemHint))
            {
                return(null);
            }

            // match by regex if hint provided
            foreach (var deviceCoil in device.AvailableCoils)
            {
                var regex = new Regex(engineCoil.DeviceItemHint, RegexOptions.IgnoreCase);
                if (regex.Match(deviceCoil.Id).Success)
                {
                    return(deviceCoil);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
 internal IApiCoil Coil(ICoilDeviceComponent component, string coilItem) => _player.Coil(component, coilItem);
Exemplo n.º 6
0
 /// <summary>
 /// Links a coil device to an existing coil mapping if it matches a given name.
 /// </summary>
 /// <param name="tableComponent">Table component for retrieving mappings.</param>
 /// <param name="elementName">The name that the coil device's GameObject has to match in order to be linked.</param>
 /// <param name="coilId">The ID of the coil mapping that the coil device will be linked to</param>
 /// <param name="coilDevice">The coil device to be linked</param>
 /// <param name="deviceItem">If set, it's the device item, otherwise the first item of the device.</param>
 protected static void LinkCoil(TableComponent tableComponent, string elementName, string coilId, ICoilDeviceComponent coilDevice, string deviceItem = null)
 {
     if (!string.Equals(coilDevice.gameObject.name, elementName, StringComparison.OrdinalIgnoreCase))
     {
         return;
     }
     LinkCoil(tableComponent, coilId, coilDevice, deviceItem);
 }
Exemplo n.º 7
0
 public void ClearDevice()
 {
     Device     = null;
     DeviceItem = null;
     Update();
 }