private void handleCommodityCollectedEvent(CommodityCollectedEvent @event) { if (_handleCommodityCollectedEvent(@event)) { writeInventory(); } }
private void handleCommodityCollectedEvent(CommodityCollectedEvent @event) { if (@event.timestamp > updateDat) { updateDat = @event.timestamp; if (_handleCommodityCollectedEvent(@event)) { writeInventory(); } } }
private bool _handleCommodityCollectedEvent(CommodityCollectedEvent @event) { bool update = false; Cargo cargo = GetCargoWithEDName(@event.commodityDefinition?.edname); if (cargo != null) { if (EDDI.Instance?.Vehicle != Constants.VEHICLE_SHIP) { if (@event.missionid != null) { cargo.haulage++; } else if (@event.stolen) { cargo.stolen++; } else { cargo.owned++; } cargo.CalculateNeed(); update = true; } Haulage haulage = cargo.haulageData.FirstOrDefault(h => h.missionid == @event.missionid); if (haulage != null) { switch (haulage.typeEDName) { case "mining": case "piracy": case "rescue": case "salvage": { haulage.sourcesystem = EDDI.Instance?.CurrentStarSystem?.systemname; haulage.sourcebody = EDDI.Instance?.CurrentStellarBody?.bodyname; update = true; } break; } } } return(update); }
public void _handleCommodityCollectedEvent(CommodityCollectedEvent @event) { Cargo cargo = GetCargoWithEDName(@event.commodityDefinition?.edname); if (cargo != null) { bool handled = false; if (@event.stolen) { cargo.stolen++; } else if (cargo.haulageamounts.Any()) { foreach (HaulageAmount haulageAmount in cargo.haulageamounts) { string type = haulageAmount.name.Split('_').ElementAtOrDefault(1).ToLowerInvariant(); int total = cargo.haulageamounts.Where(ha => ha.name.ToLowerInvariant().Contains(type)).Sum(ha => ha.amount); switch (type) { case "altruism": case "collect": case "collectwing": case "mining": case "piracy": { if (cargo.owned < total) { cargo.owned++; handled = true; } } break; case "rescue": case "salvage": { if (cargo.haulage < total) { cargo.haulage++; handled = true; } } break; } if (handled) { break; } } } else if (!handled) { cargo.owned++; } cargo.CalculateNeed(); } else { Cargo newCargo = new Cargo(@event.commodityDefinition?.edname, 1); newCargo.haulage = 0; if (@event.stolen) { newCargo.stolen = 1; } else { newCargo.owned = 1; } AddCargo(newCargo); } }