public void Handle(Event theEvent) { if (EDDI.Instance.inCQC) { // We don't do anything whilst in CQC return; } if (EDDI.Instance.inBeta) { // We don't send data whilst in beta return; } if (starMapService != null) { // We could receive either or both of JumpingEvent and JumpedEvent. Send EDSM update as soon as possible, // but don't send it twice if (theEvent is JumpingEvent) { JumpingEvent jumpingEvent = (JumpingEvent)theEvent; if (jumpingEvent.system != system) { Logging.Debug("Sending jump data to EDSM (jumping)"); starMapService.sendStarMapLog(jumpingEvent.timestamp, jumpingEvent.system, jumpingEvent.x, jumpingEvent.y, jumpingEvent.z); system = jumpingEvent.system; } } else if (theEvent is JumpedEvent) { JumpedEvent jumpedEvent = (JumpedEvent)theEvent; if (jumpedEvent.system != system) { Logging.Debug("Sending jump data to EDSM (jumped)"); starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z); system = jumpedEvent.system; } } else if (theEvent is CommanderContinuedEvent) { CommanderContinuedEvent continuedEvent = (CommanderContinuedEvent)theEvent; starMapService.sendCredits(continuedEvent.credits, continuedEvent.loan); } else if (theEvent is CommanderProgressEvent) { CommanderProgressEvent progressEvent = (CommanderProgressEvent)theEvent; if (EDDI.Instance.Cmdr != null && EDDI.Instance.Cmdr.federationrating != null) { starMapService.sendRanks(EDDI.Instance.Cmdr.combatrating.rank, (int)progressEvent.combat, EDDI.Instance.Cmdr.traderating.rank, (int)progressEvent.trade, EDDI.Instance.Cmdr.explorationrating.rank, (int)progressEvent.exploration, EDDI.Instance.Cmdr.cqcrating.rank, (int)progressEvent.cqc, EDDI.Instance.Cmdr.federationrating.rank, (int)progressEvent.federation, EDDI.Instance.Cmdr.empirerating.rank, (int)progressEvent.empire); } } } }
public void Handle(Event theEvent) { if (EDDI.Instance.inCQC) { // We don't do anything whilst in CQC return; } if (EDDI.Instance.inCrew) { // We don't do anything whilst in multicrew return; } if (EDDI.Instance.inBeta) { // We don't send data whilst in beta return; } if (starMapService != null) { if (theEvent is JumpedEvent) { JumpedEvent jumpedEvent = (JumpedEvent)theEvent; if (jumpedEvent.system != system) { Logging.Debug("Sending jump data to EDSM (jumped)"); starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z); system = jumpedEvent.system; } } else if (theEvent is CommanderContinuedEvent) { CommanderContinuedEvent continuedEvent = (CommanderContinuedEvent)theEvent; starMapService.sendCredits(continuedEvent.credits, continuedEvent.loan); } else if (theEvent is MaterialInventoryEvent) { MaterialInventoryEvent materialInventoryEvent = (MaterialInventoryEvent)theEvent; Dictionary <string, int> materials = new Dictionary <string, int>(); Dictionary <string, int> data = new Dictionary <string, int>(); foreach (MaterialAmount ma in materialInventoryEvent.inventory) { Material material = Material.FromEDName(ma.edname); if (material.category == "Element" || material.category == "Manufactured") { materials.Add(material.EDName, ma.amount); } else { data.Add(material.EDName, ma.amount); } } starMapService.sendMaterials(materials); starMapService.sendData(data); } else if (theEvent is ShipLoadoutEvent) { ShipLoadoutEvent shipLoadoutEvent = (ShipLoadoutEvent)theEvent; Ship ship = ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor")).GetShip(shipLoadoutEvent.shipid); starMapService.sendShip(ship); } else if (theEvent is ShipSwappedEvent) { ShipSwappedEvent shipSwappedEvent = (ShipSwappedEvent)theEvent; if (shipSwappedEvent.shipid.HasValue) { starMapService.sendShipSwapped((int)shipSwappedEvent.shipid); } } else if (theEvent is ShipSoldEvent) { ShipSoldEvent shipSoldEvent = (ShipSoldEvent)theEvent; if (shipSoldEvent.shipid.HasValue) { starMapService.sendShipSold((int)shipSoldEvent.shipid); } } else if (theEvent is ShipDeliveredEvent) { ShipDeliveredEvent shipDeliveredEvent = (ShipDeliveredEvent)theEvent; if (shipDeliveredEvent.shipid.HasValue) { starMapService.sendShipSwapped((int)shipDeliveredEvent.shipid); } } else if (theEvent is CommanderProgressEvent) { CommanderProgressEvent progressEvent = (CommanderProgressEvent)theEvent; if (EDDI.Instance.Cmdr != null && EDDI.Instance.Cmdr.federationrating != null) { starMapService.sendRanks(EDDI.Instance.Cmdr.combatrating.rank, (int)progressEvent.combat, EDDI.Instance.Cmdr.traderating.rank, (int)progressEvent.trade, EDDI.Instance.Cmdr.explorationrating.rank, (int)progressEvent.exploration, EDDI.Instance.Cmdr.cqcrating.rank, (int)progressEvent.cqc, EDDI.Instance.Cmdr.federationrating.rank, (int)progressEvent.federation, EDDI.Instance.Cmdr.empirerating.rank, (int)progressEvent.empire); } } } }