public void RemoveItemsOfType(MyFixedPoint amount, MyObjectBuilder_PhysicalObject objectBuilder, bool spawn = false)
 {
     TransferOrRemove(this, amount, objectBuilder.GetObjectId(), objectBuilder.Flags, null, spawn);
 }
 private void AffectAddBySurvival(ref MyFixedPoint amount, MyObjectBuilder_PhysicalObject objectBuilder)
 {
     Debug.Assert(Sync.IsServer);
     MyFixedPoint space = ComputeAmountThatFits(objectBuilder.GetObjectId());
     if (space < amount)
     {
         if (Owner.InventoryOwnerType == MyInventoryOwnerTypeEnum.Character)
         {
             MyCharacter c = (Owner as MyCharacter);
             Matrix m = c.GetHeadMatrix(true);
             MyEntity entity = MyFloatingObjects.Spawn(new MyInventoryItem(amount - space, objectBuilder), m.Translation, m.Forward, m.Up, c.Physics);
             entity.Physics.ApplyImpulse(m.Forward.Cross(m.Up), c.PositionComp.GetPosition());
         }
         amount = space;
     }
 }
 public bool ContainItems(MyFixedPoint amount, MyObjectBuilder_PhysicalObject ob)
 {
     return ContainItems(amount, ob.GetObjectId());
 }
        public void AddItems(MyFixedPoint amount, MyObjectBuilder_PhysicalObject objectBuilder, int index = -1)
        {
            if (amount == 0) return;
            if (!CanItemsBeAdded(amount, objectBuilder.GetObjectId())) return;

            if (Sync.IsServer)
            {
                if (MyPerGameSettings.ConstrainInventory())
                    AffectAddBySurvival(ref amount, objectBuilder);
                if (amount == 0)
                    return;
                AddItemsInternal(amount, objectBuilder, index);
                SyncObject.SendAddItemsAnnounce(this, amount, objectBuilder, index);
            }
            else
                SyncObject.SendAddItemsRequest(this, index, amount, objectBuilder);
        }
Example #5
0
 public bool ContainItems(MyFixedPoint amount, MyObjectBuilder_PhysicalObject ob)
 {
     if (ob == null) return false;
     return ContainItems(amount, ob.GetObjectId());
 }