コード例 #1
0
        public void Save(SerializableShip serializable)
        {
            serializable.ShipCategory   = ShipCategory;
            serializable.Name           = Name;
            serializable.Faction        = FactionId.Id;
            serializable.SizeClass      = SizeClass;
            serializable.IconImage      = IconImage;
            serializable.IconScale      = IconScale.Value;
            serializable.ModelImage     = ModelImage;
            serializable.ModelScale     = ModelScale.Value;
            serializable.EnginePosition = EnginePosition;
            serializable.EngineColor    = Helpers.ColorToString(EngineColor);
            serializable.EngineSize     = EngineSize.Value;

            serializable.EnergyResistance   = EnergyResistance.Value;
            serializable.KineticResistance  = KineticResistance.Value;
            serializable.HeatResistance     = HeatResistance.Value;
            serializable.Regeneration       = Regeneration;
            serializable.BaseWeightModifier = BaseWeightModifier.Value;
            serializable.Layout             = Layout.Data;

            serializable.BuiltinDevices = BuiltinDevices?.Select(device => device.Item.Id).ToArray();
            serializable.Barrels        = Barrels?.Select(item => item.Serialize()).ToArray();
            serializable.Engines        = Engines?.Select(item => new SerializableShip.Engine {
                Position = item.Position, Size = item.Size.Value
            }).ToArray();
        }
コード例 #2
0
        public ShipSerializable Serialize()
        {
            var serializable = new ShipSerializable();

            serializable.Id                 = ItemId.Id;
            serializable.FileName           = ItemId.Name;
            serializable.ItemType           = (int)ItemType.Ship;
            serializable.ShipCategory       = ShipCategory;
            serializable.Name               = Name;
            serializable.Faction            = Faction.Id;
            serializable.SizeClass          = SizeClass;
            serializable.IconImage          = IconImage.ToString();
            serializable.IconScale          = IconScale.Value;
            serializable.ModelImage         = ModelImage.ToString();
            serializable.ModelScale         = ModelScale.Value;
            serializable.EnginePosition     = EnginePosition;
            serializable.EngineColor        = Utils.ColorUtils.ColorToString(EngineColor);
            serializable.EngineSize         = EngineSize.Value;
            serializable.EnergyResistance   = EnergyResistance.Value;
            serializable.KineticResistance  = KineticResistance.Value;
            serializable.HeatResistance     = HeatResistance.Value;
            serializable.Regeneration       = Regeneration;
            serializable.BaseWeightModifier = BaseWeightModifier.Value;
            serializable.BuiltinDevices     = BuiltinDevices?.Select(item => item.Item.Id).ToArray();
            serializable.Layout             = Layout.Data;
            serializable.Barrels            = Barrels?.Select(item => item.Serialize()).ToArray();
            return(serializable);
        }
コード例 #3
0
        public UWPBluetoothManager(IButtplugLogManager aLogManager)
            : base(aLogManager)
        {
            BpLogger.Info("Loading UWP Bluetooth Manager");
            _currentlyConnecting = new List <ulong>();

            // Introspect the ButtplugDevices namespace for all Factory classes, then create
            // instances of all of them.
            _deviceFactories = new List <UWPBluetoothDeviceFactory>();
            BuiltinDevices.ForEach(aDeviceFactory =>
            {
                BpLogger.Debug($"Loading Bluetooth Device Factory: {aDeviceFactory.GetType().Name}");
                _deviceFactories.Add(new UWPBluetoothDeviceFactory(aLogManager, aDeviceFactory));
            });

            _bleWatcher = new BluetoothLEAdvertisementWatcher {
                ScanningMode = BluetoothLEScanningMode.Active
            };

            // We can't filter device advertisements because you can only add one LocalName filter at
            // a time, meaning we would have to set up multiple watchers for multiple devices. We'll
            // handle our own filtering via the factory classes whenever we receive a device.
            _bleWatcher.Received += OnAdvertisementReceived;
            _bleWatcher.Stopped  += OnWatcherStopped;
            var adapterTask = Task.Run(() => BluetoothAdapter.GetDefaultAsync().AsTask());

            adapterTask.Wait();
            var adapter = adapterTask.Result;

            if (adapter == null)
            {
                BpLogger.Warn("No bluetooth adapter available for UWP Bluetooth Manager Connection");
                return;
            }

            if (!adapter.IsLowEnergySupported)
            {
                BpLogger.Warn("Bluetooth adapter available but does not support Bluetooth Low Energy.");
                return;
            }

            BpLogger.Debug("UWP Manager found working Bluetooth LE Adapter");

            // Only run radio information lookup if we're actually logging at the level it will show.
            if (aLogManager.Level >= ButtplugLogLevel.Debug)
            {
                // Do radio lookup in a background task, as the search query is very slow.
                // TODO Should probably try and cancel this if it's still running on object destruction, but the Get() call is uninterruptable?
                _radioTask = Task.Run(() => LogBluetoothRadioInfo());
            }
        }
コード例 #4
0
ファイル: Ship.cs プロジェクト: CH017CK/EventHorizon-Editor
 public void Save(ShipSerializable serializable)
 {
     serializable.ShipCategory   = ShipCategory;
     serializable.Name           = Name;
     serializable.Faction        = Faction.Value;
     serializable.SizeClass      = SizeClass;
     serializable.IconImage      = IconImage;
     serializable.IconScale      = IconScale.Value;
     serializable.ModelImage     = ModelImage;
     serializable.ModelScale     = ModelScale.Value;
     serializable.EnginePosition = EnginePosition;
     serializable.EngineColor    = Helpers.ColorToString(EngineColor);
     serializable.EngineSize     = EngineSize.Value;
     if (Engines == null || Engines.Length == 0)
     {
         serializable.Engines = null;
     }
     else
     {
         serializable.Engines = Engines.Select(item => item.Serialize()).ToArray();
     }
     serializable.EnergyResistance   = EnergyResistance.Value;
     serializable.KineticResistance  = KineticResistance.Value;
     serializable.HeatResistance     = HeatResistance.Value;
     serializable.Regeneration       = Regeneration;
     serializable.BaseWeightModifier = BaseWeightModifier.Value;
     if (BuiltinDevices == null || BuiltinDevices.Length == 0)
     {
         serializable.BuiltinDevices = null;
     }
     else
     {
         serializable.BuiltinDevices = BuiltinDevices.Select(wrapper => wrapper.Item.Value).ToArray();
     }
     serializable.Layout = Layout.Data;
     if (Barrels == null || Barrels.Length == 0)
     {
         serializable.Barrels = null;
     }
     else
     {
         serializable.Barrels = Barrels.Select(item => item.Serialize()).ToArray();
     }
     OnDataSerialized(ref serializable);
 }
コード例 #5
0
        public UWPBluetoothManager(IButtplugLogManager aLogManager)
            : base(aLogManager)
        {
            BpLogger.Info("Loading UWP Bluetooth Manager");
            _currentlyConnecting = new List <ulong>();

            // Introspect the ButtplugDevices namespace for all Factory classes, then create instances of all of them.
            _deviceFactories = new List <UWPBluetoothDeviceFactory>();
            BuiltinDevices.ForEach(aDeviceFactory =>
            {
                BpLogger.Debug($"Loading Bluetooth Device Factory: {aDeviceFactory.GetType().Name}");
                _deviceFactories.Add(new UWPBluetoothDeviceFactory(aLogManager, aDeviceFactory));
            });

            _bleWatcher = new BluetoothLEAdvertisementWatcher {
                ScanningMode = BluetoothLEScanningMode.Active
            };

            // We can't filter device advertisements because you can only add one LocalName filter at a time, meaning we
            // would have to set up multiple watchers for multiple devices. We'll handle our own filtering via the factory
            // classes whenever we receive a device.
            _bleWatcher.Received += OnAdvertisementReceived;
            _bleWatcher.Stopped  += OnWatcherStopped;
            var adapterTask = Task.Run(() => BluetoothAdapter.GetDefaultAsync().AsTask());

            adapterTask.Wait();
            var adapter = adapterTask.Result;

            if (adapter == null)
            {
                BpLogger.Warn("No bluetooth adapter available for UWP Bluetooth Manager Connection");
                return;
            }

            if (!adapter.IsLowEnergySupported)
            {
                BpLogger.Warn("Bluetooth adapter available but does not support Bluetooth Low Energy.");
                return;
            }

            BpLogger.Debug("UWP Manager found working Bluetooth LE Adapter");
        }
コード例 #6
0
        public UWPBluetoothManager(IButtplugLogManager aLogManager)
            : base(aLogManager)
        {
            BpLogger.Debug("Loading UWP Bluetooth Manager");
            _currentlyConnecting = new List <ulong>();

            // Introspect the ButtplugDevices namespace for all Factory classes, then create instances of all of them.
            _deviceFactories = new List <UWPBluetoothDeviceFactory>();
            BuiltinDevices.ForEach(aDeviceFactory =>
            {
                BpLogger.Debug($"Loading Bluetooth Device Factory: {aDeviceFactory.GetType().Name}");
                _deviceFactories.Add(new UWPBluetoothDeviceFactory(aLogManager, aDeviceFactory));
            });

            _bleWatcher = new BluetoothLEAdvertisementWatcher {
                ScanningMode = BluetoothLEScanningMode.Active
            };

            // We can't filter device advertisements because you can only add one LocalName filter at a time, meaning we
            // would have to set up multiple watchers for multiple devices. We'll handle our own filtering via the factory
            // classes whenever we receive a device.
            _bleWatcher.Received += OnAdvertisementReceived;
            _bleWatcher.Stopped  += OnWatcherStopped;
        }