public VoxelPlacementDefinition(MyObjectBuilder_VoxelMiningDefinition.MiningDef ob, NamedLogger log) { Material = MyDefinitionManager.Get <MyVoxelMaterialDefinition>(ob.VoxelMaterial); if (Material == null) { log.Warning($"Could not find voxel material definition {ob.VoxelMaterial}"); Material = MyVoxelMaterialDefinition.Default; } Volume = ob.VolumeAttribute; var replacementItems = new Dictionary <MyDefinitionId, int>(); foreach (var item in ob.MinedItems) { MyObjectBuilderType type; try { type = MyObjectBuilderType.Parse(item.Type); } catch { log.Warning($"Can not parse defined builder type {item.Type}"); continue; } var key = new MyDefinitionId(type, MyStringHash.GetOrCompute(item.Subtype)); replacementItems[key] = item.Amount; } Items = replacementItems; }
public void ConnectTo(BluetoothPeripheralParams newPeripheralParams) { if (_peripheralParams.HasValue && newPeripheralParams.Equals(_peripheralParams.Value)) { logger.Warning("Already connected to this peripheral: " + newPeripheralParams); return; } #if UNITY_EDITOR _state = States.None; _connected = true; if (OnConnect != null) { OnConnect(); } return; #endif ResetState(() => { _peripheralParams = newPeripheralParams; BluetoothLEHardwareInterface.Initialize(true, false, () => { logger.DebugLog("Initialized bluetooth hardware interface."); SetState(States.Scan, 0.1f); }, (error) => { logger.Error("Error initializing bluetooth hardware interface: " + error); }); }); }