Exemplo n.º 1
0
        public override bool AddItems(MyFixedPoint amount, MyObjectBuilder_Base objectBuilder, int index = -1)
        {
            Debug.Assert(objectBuilder is MyObjectBuilder_PhysicalObject, "This type of inventory can't add other types than PhysicalObjects!");
            MyObjectBuilder_PhysicalObject physicalObjectBuilder = objectBuilder as MyObjectBuilder_PhysicalObject;

            if (physicalObjectBuilder == null)
            {
                return(false);
            }
            if (amount == 0)
            {
                return(false);
            }
            if (!CanItemsBeAdded(amount, physicalObjectBuilder.GetObjectId()))
            {
                return(false);
            }

            if (Sync.IsServer)
            {
                if (MyPerGameSettings.ConstrainInventory())
                {
                    AffectAddBySurvival(ref amount, physicalObjectBuilder);
                }
                if (amount == 0)
                {
                    return(false);
                }
                AddItemsInternal(amount, physicalObjectBuilder, index);
                SyncObject.SendAddItemsAnnounce(this, amount, physicalObjectBuilder, index);
            }
            else
            {
                SyncObject.SendAddItemsRequest(this, index, amount, physicalObjectBuilder);
            }
            return(true);
        }