private static void Reload(IMyInventoryOwner gun, SerializableDefinitionId ammo, bool reactor = false)
        {
            var cGun = gun;
            Sandbox.ModAPI.IMyInventory inv = (Sandbox.ModAPI.IMyInventory)cGun.GetInventory(0);
            VRage.MyFixedPoint point = inv.GetItemAmount(ammo, MyItemFlags.None | MyItemFlags.Damaged);
            Util.GetInstance().Log(ammo.SubtypeName + " [ReloadGuns] Amount " + point.RawValue, "ItemManager.txt");
            if (point.RawValue > 1000000)
                return;
            //inv.Clear();
            VRage.MyFixedPoint amount = new VRage.MyFixedPoint();
            amount.RawValue = 2000000;

            MyObjectBuilder_InventoryItem ii;
            if (reactor)
            {
                ii = new MyObjectBuilder_InventoryItem()
                {
                    Amount = 10,
                    Content = new MyObjectBuilder_Ingot() { SubtypeName = ammo.SubtypeName }
                };
            }
            else
            {
                ii = new MyObjectBuilder_InventoryItem()
                {
                    Amount = 4,
                    Content = new MyObjectBuilder_AmmoMagazine() { SubtypeName = ammo.SubtypeName }
                };
            }
            inv.AddItems(amount, ii.PhysicalContent);

            point = inv.GetItemAmount(ammo, MyItemFlags.None | MyItemFlags.Damaged);
            Util.GetInstance().Log(ammo.SubtypeName + " [ReloadGuns] Amount " + point.RawValue, "ItemManager.txt");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Used for type remapping when overriding definition types
        /// </summary>
        internal static void RemapType(ref SerializableDefinitionId id, Dictionary <string, string> typeOverrideMap)
        {
            string overrideType;
            bool   found = typeOverrideMap.TryGetValue(id.TypeIdString, out overrideType);

            if (!found)
            {
                if (id.TypeIdString.StartsWith(LEGACY_TYPE_PREFIX))
                {
                    found = typeOverrideMap.TryGetValue(id.TypeIdString.Substring(LEGACY_TYPE_PREFIX.Length), out overrideType);
                }
            }

            if (!found)
            {
                return;
            }

            id.TypeIdString = overrideType;
        }
Exemplo n.º 3
0
 void VRage.Game.ModAPI.IMyInventory.RemoveItemsOfType(VRage.MyFixedPoint amount, SerializableDefinitionId contentId, MyItemFlags flags, bool spawn)
 {
     RemoveItemsOfType(amount, contentId, flags, spawn);
 }
Exemplo n.º 4
0
 bool IMyInventory.CanItemsBeAdded(VRage.MyFixedPoint amount, SerializableDefinitionId contentId)
 {
     return CanItemsBeAdded(amount, contentId);
 }
        private void RemoveItemToProduce_Implementation(MyFixedPoint amount, SerializableDefinitionId blueprintId, int itemId = -1)
        {
            System.Diagnostics.Debug.Assert(amount > 0, "Removing zero or negative amount!");

            MyBlueprintDefinitionBase blueprint = MyDefinitionManager.Static.GetBlueprintDefinition(blueprintId);

            if (blueprint == null)
            {
                System.Diagnostics.Debug.Fail("Couldn't find blueprint definition for: " + blueprintId);
                return;
            }

            MyBlueprintToProduce removingItem;
            MyBlueprintToProduce currentItem = GetCurrentItemInProduction();

            if (m_itemsToProduce.IsValidIndex(itemId))
            {
                removingItem = m_itemsToProduce[itemId];
                System.Diagnostics.Debug.Assert(removingItem.Blueprint == blueprint, "The item was retrieved with index, but the passed blueprint don't match items blueprint!");
            }
            else
            {
                removingItem = m_itemsToProduce.Find(x => x.Blueprint == blueprint);
            }

            if (removingItem != null)
            {                
                System.Diagnostics.Debug.Assert(removingItem.Amount - amount >= 0, "Trying to remove more amount, than was set to be produced!");
                
                removingItem.Amount = removingItem.Amount - amount;

                if (removingItem.Amount <= 0)
                {                    
                    m_itemsToProduce.Remove(removingItem);
                }

                if (currentItem == removingItem && (m_currentItemStatus >= 1.0f || removingItem.Amount == 0))
                {
                    SelectItemToProduction();
                }

                var handler = ProductionChanged;
                if (handler != null)
                {
                    handler(this, removingItem);
                }
            }
            else
            {
                // On MP it can easily happen that we are removing an item that was already produced on the server, so don't assert in that case
                System.Diagnostics.Debug.Assert(Sync.Clients.Count != 0, "Trying to remove item from production, but item wasn't found!");
            }            
        }
        private void AddItemToRepair_Implementation(MyFixedPoint amount, SerializableDefinitionId blueprintId, uint inventoryItemId, MyObjectBuilderType inventoryItemType, MyStringHash inventoryItemSubtypeId)
        {
            System.Diagnostics.Debug.Assert(amount > 0, "Adding zero or negative amount!");

            MyBlueprintDefinitionBase blueprint = MyDefinitionManager.Static.GetBlueprintDefinition(blueprintId);

            if (blueprint == null)
            {
                System.Diagnostics.Debug.Fail("Couldn't find blueprint definition for: " + blueprintId);
                return;
            }

            Predicate<MyBlueprintToProduce> condition = x => (x is MyRepairBlueprintToProduce) && 
                                                             (x as MyRepairBlueprintToProduce).Blueprint == blueprint &&
                                                             (x as MyRepairBlueprintToProduce).InventoryItemId == inventoryItemId &&
                                                             (x as MyRepairBlueprintToProduce).InventoryItemType == inventoryItemType &&
                                                             (x as MyRepairBlueprintToProduce).InventoryItemSubtypeId == inventoryItemSubtypeId;
            MyRepairBlueprintToProduce itemToProduce = m_itemsToProduce.Find(condition) as MyRepairBlueprintToProduce;
            if (itemToProduce != null)
            {
                itemToProduce.Amount = itemToProduce.Amount + amount;
            }
            else
            {
                itemToProduce = new MyRepairBlueprintToProduce(amount, blueprint, inventoryItemId, inventoryItemType, inventoryItemSubtypeId);
                m_itemsToProduce.Add(itemToProduce);                
            }

            var handler = ProductionChanged;
            if (handler != null)
            {
                handler(this, itemToProduce);
            }
        }
        private void AddItemToProduce_Implementation(MyFixedPoint amount, SerializableDefinitionId blueprintId)
        {
            System.Diagnostics.Debug.Assert(amount > 0, "Adding zero or negative amount!");

            MyBlueprintDefinitionBase blueprint = MyDefinitionManager.Static.GetBlueprintDefinition(blueprintId);

            if (blueprint == null)
            {
                System.Diagnostics.Debug.Fail("Couldn't find blueprint definition for: " + blueprintId);
                return;
            }
            
            MyBlueprintToProduce itemToProduce = m_itemsToProduce.Find(x => x.Blueprint == blueprint);
            if (itemToProduce != null)
            {
                itemToProduce.Amount = itemToProduce.Amount + amount;
            }
            else
            {
                itemToProduce = new MyBlueprintToProduce(amount, blueprint);
                m_itemsToProduce.Add(itemToProduce);
            }

            var handler = ProductionChanged;
            if (handler != null)
            {
                handler(this, itemToProduce);
            }
        }
        private void MissingRequiredItem_Implementation(SerializableDefinitionId blueprintId, SerializableDefinitionId missingItemId)
        {
            MyBlueprintDefinitionBase.Item missingItem = default(MyBlueprintDefinitionBase.Item);
            MyDefinitionId definitionId = missingItemId;
            bool found = false;

            MyBlueprintDefinitionBase blueprint = MyDefinitionManager.Static.GetBlueprintDefinition(blueprintId);

            if (blueprint == null)
            {
                System.Diagnostics.Debug.Fail("Couldn't find blueprint definition for: " + blueprintId);
                return;
            }

            foreach (var requiredItem in blueprint.Prerequisites)
            {
                if (requiredItem.Id == definitionId)
                {
                    missingItem = requiredItem;
                    found = true;
                }
            }

            if (!found)
            {
                System.Diagnostics.Debug.Fail("Item " + definitionId + " wasn't found in blueprint " + blueprint);
            }

            var handler = MissingRequiredItem;

            if (handler != null && found)
            {
                handler(this, blueprint, missingItem);
            }
        }
Exemplo n.º 9
0
 private void OnAddQueueItemSuccess(int idx, SerializableDefinitionId defId, MyFixedPoint ammount)
 {
     this.InsertQueueItem(idx, MyDefinitionManager.Static.GetBlueprintDefinition(defId), ammount);
 }
        private static void UnlockResearchFailed(SerializableDefinitionId id)
        {
            MyDefinitionBase definition;
            if (!MyDefinitionManager.Static.TryGetDefinition(id, out definition))
            {
                Debug.Assert(false, "Stooooooopid Definition is not here!");
                return;
            }

            Static.m_knownResearchNotification.SetTextFormatArguments(definition.DisplayNameText);
            MyHud.Notifications.Add(Static.m_knownResearchNotification);
        }
        private static void UnlockResearchSuccess(long identityId, SerializableDefinitionId id)
        {
            MyDefinitionBase definition;
            if (!MyDefinitionManager.Static.TryGetDefinition(id, out definition))
            {
                Debug.Assert(false, "Stooooooopid Definition is not here!");
                return;
            }

            HashSet<MyDefinitionId> unlockedItems;
            if (!Static.m_unlockedResearch.TryGetValue(identityId, out unlockedItems) || unlockedItems == null)
                unlockedItems = new HashSet<MyDefinitionId>();

            var research = definition as MyResearchDefinition;
            if (research != null)
            {
                foreach (var entry in research.Entries)
                    unlockedItems.Add(entry);
            }
            unlockedItems.Add(definition.Id);
            Static.m_unlockedResearch[identityId] = unlockedItems;

            if (MySession.Static.LocalCharacter != null && MySession.Static.LocalCharacter.GetPlayerIdentityId() == identityId)
            {
                Static.m_unlockedResearchNotification.SetTextFormatArguments(definition.DisplayNameText);
                MyHud.Notifications.Add(Static.m_unlockedResearchNotification);
            }
        }
Exemplo n.º 12
0
        void DoChangeListId(SerializableDefinitionId id, bool add)
        {
            if (add)
                m_inventoryConstraint.Add(id);
            else
                m_inventoryConstraint.Remove(id);

            // Recompute because of new sorter settings
            CubeGrid.GridSystems.ConveyorSystem.FlagForRecomputation();

            if (m_allowCurrentListUpdate)
                currentList.UpdateVisual();
        }
Exemplo n.º 13
0
 void ChangeListId(SerializableDefinitionId id, bool wasAdded)
 {
     MyMultiplayer.RaiseEvent(this, x => x.DoChangeListId, id, wasAdded);
 }
        private void InventoryConsumeItem_Implementation(MyFixedPoint amount, SerializableDefinitionId itemId, long consumerEntityId)
        {
            if ((consumerEntityId != 0 && !MyEntities.EntityExists(consumerEntityId)))
            {
                return;
            }

            var existingAmount = GetItemAmount(itemId);
            if (existingAmount < amount)
                amount = existingAmount;

            MyEntity entity = null;
            if (consumerEntityId != 0)
            {
                entity = MyEntities.GetEntityById(consumerEntityId);
                if (entity == null)
                    return;
            }

            bool removeItem = true;

            if (entity.Components != null)
            {
                var definition = MyDefinitionManager.Static.GetDefinition(itemId) as MyUsableItemDefinition;
                if (definition != null)
                {
                    var character = entity as MyCharacter;
                    if (character != null)
                        character.SoundComp.StartSecondarySound(definition.UseSound, true);

                    var consumableDef = definition as MyConsumableItemDefinition;
                    if (consumableDef != null)
                    {
                        var statComp = entity.Components.Get<MyEntityStatComponent>() as MyCharacterStatComponent;
                        if (statComp != null)
                        {
                            statComp.Consume(amount, consumableDef);
                        }
                    }

                    var schematicDef = definition as MySchematicItemDefinition;
                    if (schematicDef != null)
                        removeItem &= MySessionComponentResearch.Static.UnlockResearch(character, schematicDef.Research);
                }
            }

            if (removeItem)
                RemoveItemsOfType(amount, itemId);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Retreive items.
        /// </summary>
        private void Shop()
        {
            float allowedVolume = maxTransfer; // volume is in m³ not l

            var component = m_shoppingList.FirstPair();
            //m_logger.debugLog("shopping for " + component.Key, "Move()");
            SerializableDefinitionId defId = new SerializableDefinitionId(typeof(MyObjectBuilder_Component), component.Key);
            float oneVol = MyDefinitionManager.Static.GetPhysicalItemDefinition(defId).Volume;
            foreach (IMyInventory source in m_sourceInventory)
            {
                //m_logger.debugLog("source: " + (source.Owner as IMyEntity).getBestName(), "Move()");

                int amountToMove, sourceIndex;
                GetComponentInInventory(source, defId, out amountToMove, out sourceIndex);
                if (amountToMove < 1)
                    continue;
                //m_logger.debugLog("found: " + component.Key + ", count: " + amountToMove, "Move()");
                if (amountToMove > component.Value)
                {
                    //m_logger.debugLog("reducing amountToMove to " + component.Value, "Move()");
                    amountToMove = component.Value;
                }

                foreach (IMyInventory destination in m_destInventory)
                {
                    if (amountToMove < 1)
                        break;

                    //m_logger.debugLog("destination: " + (destination.Owner as IMyEntity).getBestName(), "Move()");

                    int allowedAmount = (int)(allowedVolume / oneVol);
                    if (allowedAmount < 1)
                    {
                        m_logger.debugLog("allowed amount less than 1");
                        return;
                    }
                    if (allowedAmount < amountToMove)
                    {
                        //m_logger.debugLog("allowedAmount(" + allowedAmount + ") < amountToMove(" + amountToMove + ")", "Move()");
                        amountToMove = allowedAmount;
                    }

                    MyFixedPoint amountInDest = destination.GetItemAmount(defId);
                    if (destination.TransferItemFrom(source, sourceIndex, amount: amountToMove))
                    {
                        MyFixedPoint amountNow = destination.GetItemAmount(defId);
                        if (amountNow == amountInDest)
                        {
                            m_logger.debugLog("no transfer took place");
                        }
                        else
                        {
                            int transferred = (int)(amountNow - amountInDest);
                            m_shoppingList[component.Key] -= transferred;
                            allowedVolume -= transferred * oneVol;
                            amountToMove -= transferred;
                            //m_logger.debugLog("transfered: " + transferred + ", remaining volume: " + allowedVolume + " remaining amount: " + amountToMove, "Move()");
                            component = m_shoppingList.FirstPair();
                            if (amountToMove < 1)
                            {
                                if (component.Value < 1)
                                {
                                    m_logger.debugLog("final transfer for " + component.Key);
                                    m_shoppingList.Remove(component.Key);
                                }
                                return;
                            }
                        }
                    }
                    else
                        m_logger.debugLog("transfer failed", Logger.severity.WARNING);
                }
            }

            if (allowedVolume == maxTransfer)
            {
                m_logger.debugLog("no items were transferred, dropping item from list: " + component.Key, Logger.severity.DEBUG);
                m_shoppingList.Remove(component.Key);
            }
            else
                m_logger.debugLog("value: " + m_shoppingList[component.Key], Logger.severity.DEBUG);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Puts components back
        /// </summary>
        private void Return()
        {
            float allowedVolume = maxTransfer; // volume is in m³ not l

            foreach (IMyInventory sourceInv in m_destInventory)
                if (sourceInv.CurrentVolume > MyFixedPoint.Zero)
                {
                    var items = sourceInv.GetItems();
                    for (int i = 0; i < items.Count; i++)
                    {
                        MyObjectBuilderType baseType = items[i].Content.GetType();
                        if (baseType != typeof(MyObjectBuilder_Component))
                            continue;

                        SerializableDefinitionId defId = new SerializableDefinitionId(baseType, items[i].Content.SubtypeName);
                        float oneVol = MyDefinitionManager.Static.GetPhysicalItemDefinition(defId).Volume;

                        foreach (IMyInventory destInv in m_sourceInventory)
                            if (destInv.CurrentVolume < destInv.MaxVolume - 1 && sourceInv.IsConnectedTo(destInv))
                            {
                                int allowedAmount = (int)(allowedVolume / oneVol);
                                if (allowedAmount <= 0)
                                {
                                    m_logger.debugLog(allowedAmount < 0, "allowedAmount < 0", Logger.severity.FATAL);
                                    m_logger.debugLog("reached max transfer for this update", Logger.severity.DEBUG);
                                    return;
                                }

                                int invSpace = (int)((float)(destInv.MaxVolume - destInv.CurrentVolume) / oneVol);
                                MyFixedPoint transferAmount = Math.Min(allowedAmount, invSpace);
                                if (transferAmount > items[i].Amount)
                                    transferAmount = items[i].Amount;

                                if (transferAmount > invSpace)
                                    transferAmount = invSpace;

                                MyFixedPoint volumeBefore = destInv.CurrentVolume;
                                if (destInv.TransferItemFrom(sourceInv, 0, stackIfPossible: true, amount: transferAmount))
                                {
                                    //m_logger.debugLog("transfered item from " + (sourceInv.Owner as IMyEntity).getBestName() + " to " + (destInv.Owner as IMyEntity).getBestName() +
                                    //	", amount: " + transferAmount + ", volume: " + (destInv.CurrentVolume - volumeBefore), "Return()");
                                    allowedVolume += (float)(volumeBefore - destInv.CurrentVolume);
                                }
                            }
                    }
                }

            m_logger.debugLog("finished emptying inventories", Logger.severity.INFO);
            m_currentTask = Shop;
        }
Exemplo n.º 17
0
 private void OnAddQueueItemRequest(int idx, SerializableDefinitionId defId, MyFixedPoint ammount)
 {
     var blueprint = MyDefinitionManager.Static.GetBlueprintDefinition(defId);
     Debug.Assert(blueprint != null, "Blueprint not present in the dictionary.");
     if (blueprint != null)
     {
         this.InsertQueueItem(idx, blueprint, ammount);
         MyMultiplayer.RaiseEvent(this, x => x.OnAddQueueItemSuccess, idx, defId, ammount);
         
     }
 }
Exemplo n.º 18
0
        Sandbox.ModAPI.Interfaces.IMyInventoryItem Sandbox.ModAPI.Interfaces.IMyInventory.FindItem(SerializableDefinitionId contentId)
        {
            MyPhysicalInventoryItem? item = FindItem(contentId);

            if (item != null)
            {
                return item.Value;
            }
            return null;
        }
 public static MyObjectBuilder_Base CreateNewObject(SerializableDefinitionId id)
 {
     return(CreateNewObject(id.TypeId, id.SubtypeId));
 }
Exemplo n.º 20
0
 bool Sandbox.ModAPI.Interfaces.IMyInventory.CanItemsBeAdded(VRage.MyFixedPoint amount, SerializableDefinitionId contentId)
 {
     return CanItemsBeAdded(amount, contentId);
 }
        private void OnBlueprintProduced_Implementation(SerializableDefinitionId blueprintId, MyFixedPoint amount)
        {
            MyBlueprintDefinitionBase blueprint = MyDefinitionManager.Static.GetBlueprintDefinition(blueprintId);

            if (blueprint == null)
            {
                System.Diagnostics.Debug.Fail("Couldn't find blueprint definition for: " + blueprintId);
                return;
            }

            var handler = BlueprintProduced;

            if (handler != null)
            {
                handler(this, blueprint, amount);
            }
        }
Exemplo n.º 22
0
 VRage.MyFixedPoint Sandbox.ModAPI.Interfaces.IMyInventory.GetItemAmount(SerializableDefinitionId contentId, MyItemFlags flags)
 {
     return GetItemAmount(contentId,flags);
 }
        private void AddItemToRepair_Request(MyFixedPoint amount, SerializableDefinitionId blueprintId, long senderEntityId, uint inventoryItemId, MyObjectBuilderType inventoryItemType, MyStringHash inventoryItemSubtypeId)
        {
            if (IsLocked && senderEntityId != m_lockedByEntityId)
                return;

            MyMultiplayer.RaiseEvent(this, x => x.AddItemToRepair_Implementation, amount, blueprintId, inventoryItemId, inventoryItemType, inventoryItemSubtypeId);
        }
Exemplo n.º 24
0
        void SwitchToWeaponMessage(SerializableDefinitionId? weapon, [Serialize(MyObjectFlags.Dynamic | MyObjectFlags.Nullable, DynamicSerializerType = typeof(MyObjectBuilderDynamicSerializer))] MyObjectBuilder_EntityBase weaponObjectBuilder, long weaponEntityId)
        {
            if(CanSwitchToWeapon(weapon) == false)
            {
                if (MyEventContext.Current.IsLocallyInvoked)
                {
                    OnSwitchToWeaponFailure(weapon, weaponObjectBuilder, weaponEntityId);
                }
                else
                {
                    MyMultiplayer.RaiseEvent(this, x => x.OnSwitchToWeaponFailure, weapon, weaponObjectBuilder, weaponEntityId, MyEventContext.Current.Sender);
                }
                return;
            }

            if (weaponObjectBuilder != null && weaponObjectBuilder.EntityId == 0)
            {
                weaponObjectBuilder = (MyObjectBuilder_EntityBase)weaponObjectBuilder.Clone();
                weaponObjectBuilder.EntityId = weaponEntityId == 0 ? MyEntityIdentifier.AllocateId() : weaponEntityId;
            }
            OnSwitchToWeaponSuccess(weapon, weaponObjectBuilder, weaponEntityId);

            MyMultiplayer.RaiseEvent(this, x => x.OnSwitchToWeaponSuccess, weapon, weaponObjectBuilder, weaponEntityId);

        }
 private void RemoveItemToProduce_Request(MyFixedPoint amount, SerializableDefinitionId blueprintId, long senderEntityId, int itemId = -1)
 {
     if (IsLocked && senderEntityId != m_lockedByEntityId)
         return;            
     MyMultiplayer.RaiseEvent(this, x => x.RemoveItemToProduce_Implementation, amount, blueprintId, itemId);
 }
Exemplo n.º 26
0
 void OnSwitchToWeaponFailure(SerializableDefinitionId? weapon, [Serialize(MyObjectFlags.Dynamic | MyObjectFlags.Nullable, DynamicSerializerType = typeof(MyObjectBuilderDynamicSerializer))] MyObjectBuilder_EntityBase weaponObjectBuilder, long weaponEntityId)
 {
     if (!Sync.IsServer)
     {
         m_switchWeaponCounter--;
     }
 }
Exemplo n.º 27
0
        IMyInventoryItem IMyInventory.FindItem(SerializableDefinitionId contentId)
        {
            MyPhysicalInventoryItem? item = FindItem(contentId);

            if (item != null)
            {
                return item.Value;
            }
            return null;
        }
Exemplo n.º 28
0
        void OnSwitchToWeaponSuccess(SerializableDefinitionId? weapon, [Serialize(MyObjectFlags.Dynamic | MyObjectFlags.Nullable, DynamicSerializerType = typeof(MyObjectBuilderDynamicSerializer))] MyObjectBuilder_EntityBase weaponObjectBuilder, long weaponEntityId)
        {
            if (!Sync.IsServer)
            {
                // Update the counter only if we are waiting for it
                if (m_switchWeaponCounter > 0)
                {
                    m_switchWeaponCounter--;
                }
            }

            SwitchToWeaponSuccess(weapon, weaponObjectBuilder, weaponEntityId);
        }
Exemplo n.º 29
0
 VRage.MyFixedPoint IMyInventory.GetItemAmount(SerializableDefinitionId contentId, MyItemFlags flags)
 {
     return GetItemAmount(contentId,flags);
 }
		public ProductionQueueItem( decimal amount, SerializableDefinitionId id, uint itemId )
		{
			Amount = amount;
			Id = id;
			ItemId = itemId;
		}
Exemplo n.º 31
0
        static void CreateNewPlaceArea(SerializableDefinitionId id, MyPositionAndOrientation positionAndOrientation)
        {
            MyObjectBuilder_AreaMarker objectBuilder = (MyObjectBuilder_AreaMarker)MyObjectBuilderSerializer.CreateNewObject(id);
            objectBuilder.PersistentFlags = MyPersistentEntityFlags2.Enabled | MyPersistentEntityFlags2.InScene;
            objectBuilder.PositionAndOrientation = positionAndOrientation;

            MyEntities.CreateFromObjectBuilderAndAdd(objectBuilder);
        }
		public ProductionQueueItem( MyObjectBuilder_ProductionBlock.QueueItem q )
		{
			Amount = (decimal)q.Amount;
			Id = q.Id;
			ItemId = q.ItemId.GetValueOrDefault( 0 );
		}