コード例 #1
0
ファイル: ShipMonitor.cs プロジェクト: pekwalker/EDDI
        private void handleShipLoadoutEvent(ShipLoadoutEvent @event)
        {
            Ship ship = ParseShipLoadoutEvent(@event);

            // Update the global variable
            EDDI.Instance.CurrentShip = ship;

            AddShip(ship);
            writeShips();
        }
コード例 #2
0
        private void handleShipLoadoutEvent(ShipLoadoutEvent @event)
        {
            if (!inFighter(@event.ship) && !inBuggy(@event.ship))
            {
                Ship ship = ParseShipLoadoutEvent(@event);

                // Update the global variable
                EDDI.Instance.CurrentShip = ship;

                AddShip(ship);
                writeShips();
            }
        }
コード例 #3
0
ファイル: ShipMonitor.cs プロジェクト: pekwalker/EDDI
 private void posthandleShipLoadoutEvent(ShipLoadoutEvent @event)
 {
     /// The ship may have Frontier API specific data, request a profile refresh from the Frontier API a minute after switching
     refreshProfileDelayed(@event.shipid, currentProfileId).GetAwaiter().GetResult();
 }
コード例 #4
0
ファイル: ShipMonitor.cs プロジェクト: pekwalker/EDDI
        private Ship ParseShipLoadoutEvent(ShipLoadoutEvent @event)
        {
            // Obtain the ship to which this loadout refers
            Logging.Debug("Current Ship Id is: " + currentShipId + ", Loadout Ship Id is " + @event.shipid);
            Ship ship = GetShip(@event.shipid);

            if (ship == null)
            {
                // The ship is unknown - create it
                Logging.Debug("Unknown ship ID " + @event.shipid);
                ship         = ShipDefinitions.FromEDModel(@event.ship);
                ship.LocalId = (int)@event.shipid;
                ship.Role    = Role.MultiPurpose;
            }

            // Save a copy of the raw event so that we can send it to other 3rd party apps
            ship.raw = @event.raw;

            // Update model (in case it was solely from the edname), name, ident & paintjob if required
            ship.model = @event.ship;
            setShipName(ship, @event.shipname);
            setShipIdent(ship, @event.shipident);
            ship.paintjob = @event.paintjob;

            // Write ship value, if given by the loadout event
            if (@event.value != null)
            {
                ship.value = (long)@event.value;
            }

            ship.rebuy = @event.rebuy;

            // Set the standard modules
            Compartment compartment = @event.compartments.FirstOrDefault(c => c.name == "Armour");

            if (compartment != null)
            {
                ship.bulkheads = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "ShipCockpit");
            if (compartment != null)
            {
                ship.canopy = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "PowerPlant");
            if (compartment != null)
            {
                ship.powerplant = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "MainEngines");
            if (compartment != null)
            {
                ship.thrusters = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "PowerDistributor");
            if (compartment != null)
            {
                ship.powerdistributor = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "FrameShiftDrive");
            if (compartment != null)
            {
                ship.frameshiftdrive = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "LifeSupport");
            if (compartment != null)
            {
                ship.lifesupport = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "Radar");
            if (compartment != null)
            {
                ship.sensors = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "FuelTank");
            if (compartment != null)
            {
                ship.fueltank = compartment.module;
            }
            if (ship.fueltank != null)
            {
                ship.fueltankcapacity = (decimal)Math.Pow(2, ship.fueltank.@class);
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "CargoHatch");
            if (compartment != null)
            {
                ship.cargohatch = compartment.module;
            }

            // Internal + restricted modules
            ship.compartments = @event.compartments.Where(c => c.name.StartsWith("Slot") || c.name.StartsWith("Military")).ToList();

            // Hardpoints
            ship.hardpoints = @event.hardpoints;

            // total fuel tank capacity
            ship.fueltanktotalcapacity = ship.fueltankcapacity + (int)ship.compartments.Where(c => c.module != null && c.module.basename.Equals("FuelTank")).Sum(c => Math.Pow(2, c.module.@class));

            // Cargo capacity
            ship.cargocapacity = (int)ship.compartments.Where(c => c.module != null && c.module.basename.Contains("CargoRack")).Sum(c => Math.Pow(2, c.module.@class));
            return(ship);
        }
コード例 #5
0
        private void handleShipLoadoutEvent(ShipLoadoutEvent @event)
        {
            // Obtain the ship to which this loadout refers
            Logging.Debug("Current Ship Id is: " + currentShipId + ", Loadout Ship Id is " + @event.shipid);
            Ship ship = GetShip(@event.shipid);

            if (ship == null)
            {
                // The ship is unknown - create it
                Logging.Debug("Unknown ship ID " + @event.shipid);
                ship         = ShipDefinitions.FromEDModel(@event.ship);
                ship.LocalId = (int)@event.shipid;
                ship.role    = Role.MultiPurpose;
            }

            // Update name, ident & paintjob if required
            setShipName(ship, @event.shipname);
            setShipIdent(ship, @event.shipident);
            ship.paintjob = @event.paintjob;

            // Set the standard modules
            Compartment compartment = @event.compartments.FirstOrDefault(c => c.name == "Armour");

            if (compartment != null)
            {
                ship.bulkheads = compartment.module;
                // We take ship overall health from here
                ship.health = compartment.module.health;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "ShipCockpit");
            if (compartment != null)
            {
                ship.canopy = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "PowerPlant");
            if (compartment != null)
            {
                ship.powerplant = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "MainEngines");
            if (compartment != null)
            {
                ship.thrusters = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "PowerDistributor");
            if (compartment != null)
            {
                ship.powerdistributor = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "FrameShiftDrive");
            if (compartment != null)
            {
                ship.frameshiftdrive = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "LifeSupport");
            if (compartment != null)
            {
                ship.lifesupport = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "Radar");
            if (compartment != null)
            {
                ship.sensors = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "FuelTank");
            if (compartment != null)
            {
                ship.fueltank = compartment.module;
            }
            if (ship.fueltank != null)
            {
                ship.fueltankcapacity = (decimal)Math.Pow(2, ship.fueltank.@class);
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "CargoHatch");
            if (compartment != null)
            {
                ship.cargohatch = compartment.module;
            }

            // Internal + restricted modules
            ship.compartments = @event.compartments.Where(c => c.name.StartsWith("Slot") || c.name.StartsWith("Military")).ToList();

            // Hardpoints
            ship.hardpoints = @event.hardpoints;

            // total fuel tank capacity
            ship.fueltanktotalcapacity = ship.fueltankcapacity + (int)ship.compartments.Where(c => c.module != null && c.module.name.EndsWith("Fuel Tank")).Sum(c => Math.Pow(2, c.module.@class));

            // Cargo capacity
            ship.cargocapacity = (int)ship.compartments.Where(c => c.module != null && c.module.name.EndsWith("Cargo Rack")).Sum(c => Math.Pow(2, c.module.@class));

            // Update the global variable
            EDDI.Instance.CurrentShip = ship;

            AddShip(ship);
            writeShips();
        }
コード例 #6
0
 private void posthandleShipLoadoutEvent(ShipLoadoutEvent @event)
 {
     /// The ship may have engineering data, request a profile refresh from the Frontier API a minute after switching
     refreshProfileDelayed(@event.shipid, currentProfileId);
 }