protected override DereferenceResult Perform(Inventory reference, FieldInfo field, List <ReferenceWrapper> objects) { if (Matches(reference, "mItems", field, objects)) { InventoryItem item = Find <InventoryItem>(objects); if (item != null) { if (Performing) { InventoryStack stack = Find <InventoryStack>(objects); if (stack != null) { try { reference.RemoveInternal(item, false, stack); } catch (Exception e) { Common.DebugException(item.Object, e); } } } return(DereferenceResult.End); } } if (Matches(reference, "Owner", field, objects)) { Remove(ref reference.Owner); return(DereferenceResult.End); } return(DereferenceResult.Failure); }
public static bool GetIfEquipped(Player player, InventoryStack stack) { if (!(stack.TopItem is IEquipableItem equipable)) { return(false); } return(player.Equipment.IsEquiped(equipable)); }
/// <inheritdoc /> public void Collect(InventoryStack stack) { if (stack.IsEmpty) { return; } var remainder = _player.Inventory.AddToStorage(stack); // TODO do something with the remainder }
public void Fill_in_non_empty_other_slot_returns_the_original() { var contentsOfSlotZero = new InventoryStack(_model3, 30); Assert.AreEqual(contentsOfSlotZero, Get(0)); var remaining = _container.Fill(_container.GetCursor(0), new InventoryStack(_model1, 5)); Assert.AreEqual(contentsOfSlotZero, Get(0)); // put value is returned Assert.AreEqual(new InventoryStack(_model1, 5), remaining); }
public void Put_in_a_non_empty_slot_returns_the_original_amount() { var contentsOfSlotZero = new InventoryStack(_model3, 30); Assert.Equal(contentsOfSlotZero, Get(0)); var remaining = _container.Put(_container.GetCursor(0), new InventoryStack(_model1, 5)); Assert.Equal(contentsOfSlotZero, Get(0)); // put value is returned Assert.Equal(new InventoryStack(_model1, 5), remaining); }
private static bool AddInternal(Inventory ths, IGameObject obj, uint stackNumber, bool testPurge) { InventoryStack stack = ths.GetStack(ref stackNumber); try { return(ths.AddInternal(obj, stackNumber, stack, testPurge) != null); } catch (Exception e) { Common.Exception(ths.Owner, obj, e); return(false); } }
private static string GetEquippedText(Player player, InventoryStack stack) { if (!(stack.TopItem is IEquipableItem equipable)) { return(null); } if (!player.Equipment.IsEquiped(equipable)) { return(null); } if (!(equipable is IHoldableItem holdableItem)) { return(EquippedText); } if (player.Equipment.LeftHandItem.Equals(holdableItem)) { return(EquippedLeftText); } return(EquippedRightText); }
protected InventoryStackItem(InventoryStack stack) { Stack = stack; }
protected abstract InventoryStackItem CreateListBoxItem(InventoryStack stack);
public PlayerInventoryItem(InventoryStack itemStack, Player player) : base(itemStack) { this.player = player; }
protected override InventoryStackItem CreateListBoxItem(InventoryStack stack) { return(new PlayerInventoryItem(stack, Player)); }
public CustomInventoryItem(InventoryStack itemStack) : base(itemStack) { }