Inheritance: ModelBase
Exemplo n.º 1
0
 internal void InstallReinforcementExpansion()
 {
     r_ExtraEquipmentID = -1;
     ExtraSlot          = new ShipSlot(Equipment.Dummy, 0, 0);
 }
Exemplo n.º 2
0
        void UpdateSlots()
        {
            var rUpdateList = false;

            if (Slots == null || Slots.Count != RawData.SlotCount)
            {
                Slots = Enumerable.Range(0, RawData.SlotCount).Select(r => new ShipSlot(Info.PlaneCountInSlot[r], RawData.PlaneCountInSlot[r])).ToArray();
            }

            if (r_EquipmentIDs == null || !r_EquipmentIDs.SequenceEqual(RawData.Equipment))
            {
                r_EquipmentIDs = RawData.Equipment;

                for (var i = 0; i < Slots.Count; i++)
                {
                    Equipment rEquipment;
                    var       rID = r_EquipmentIDs[i];
                    if (rID == -1)
                    {
                        rEquipment = Equipment.Dummy;
                    }
                    else if (!r_Port.Equipment.TryGetValue(rID, out rEquipment))
                    {
                        rEquipment = new Equipment(new RawEquipment()
                        {
                            ID = rID, EquipmentID = -1
                        });
                        r_Port.AddEquipment(rEquipment);
                    }

                    Slots[i].Equipment = rEquipment;
                }

                rUpdateList = true;
            }

            for (var i = 0; i < Slots.Count; i++)
            {
                Slots[i].PlaneCount = RawData.PlaneCountInSlot[i];
            }

            if (RawData.ExtraEquipment != 0)
            {
                if (ExtraSlot == null)
                {
                    ExtraSlot = new ShipSlot(0, 0);
                }

                if (r_ExtraEquipmentID != RawData.ExtraEquipment)
                {
                    r_ExtraEquipmentID  = RawData.ExtraEquipment;
                    ExtraSlot.Equipment = r_ExtraEquipmentID == -1 ? Equipment.Dummy : r_Port.Equipment[r_ExtraEquipmentID];

                    rUpdateList = true;
                }
            }

            if (rUpdateList)
            {
                var rList = Slots.Where(r => r.HasEquipment).Select(r => r.Equipment);
                if (ExtraSlot != null && ExtraSlot.HasEquipment)
                {
                    rList = rList.Concat(new[] { ExtraSlot.Equipment });
                }

                EquipedEquipment = rList.ToArray();
                rUpdateList      = false;
            }
        }