示例#1
0
        public void StartPurchase(UISoldShip ship, Closure callback)
        {
            session.RpcServer.GetShipPackage(ship.Server.PackageCRC).ContinueWith(task =>
            {
                if (task.Result != null)
                {
                    selectedHullPrice = ship.Server.HullPrice;
                }
                else
                {
                    return;
                }

                selectedCrc  = ship.Server.PackageCRC;
                selectedShip = ship.Ship;
                var hplookup = new HardpointLookup(ship.Ship.ModelFile.LoadFile(session.Game.ResourceManager));
                playerItems  = new List <ShipTradeItem>();
                dealerItems  = new List <ShipTradeItem>();
                for (int i = 0; i < task.Result.Included.Length; i++)
                {
                    var item = task.Result.Included[i];
                    var eq   = session.Game.GameData.GetEquipment(item.EquipCRC);
                    playerItems.Add(new ShipTradeItem()
                    {
                        Show      = eq.Good != null,
                        Hardpoint = hplookup.GetHardpoint(item.HardpointCRC),
                        Include   = new ResolvedInclude()
                        {
                            ID        = i,
                            Equipment = eq,
                            Amount    = item.Amount
                        },
                        Amount = item.Amount
                    });
                }
                foreach (var item in session.Items)
                {
                    if (item.Equipment.Good != null)
                    {
                        string hp = null;
                        if (item.Hardpoint != null && CanMount(item.Equipment.HpType, item.Hardpoint))
                        {
                            hp = item.Hardpoint;
                        }
                        playerItems.Add(new ShipTradeItem()
                        {
                            Cargo = item, Hardpoint = hp, Amount = item.Count
                        });
                    }
                }
                session.EnqueueAction(() => callback.Call());
            });
        }
示例#2
0
        void SetSelfLoadout(NetShipLoadout ld)
        {
            var sh = Game.GameData.GetShip((int)ld.ShipCRC);

            PlayerShip = sh.Nickname;
            var hplookup = new HardpointLookup(sh.ModelFile.LoadFile(Game.ResourceManager));

            Items = new List <NetCargo>(ld.Items.Count);
            foreach (var cg in ld.Items)
            {
                var equip = Game.GameData.GetEquipment(cg.EquipCRC);
                Items.Add(new NetCargo(cg.ID)
                {
                    Equipment = equip,
                    Hardpoint = hplookup.GetHardpoint(cg.HardpointCRC),
                    Health    = cg.Health / 255f,
                    Count     = cg.Count
                });
            }
        }