public int DoSplash(ItemDefinition splashType, int amount) { int iAmount; if (this.HasLiquidItem()) { Item liquidItem = this.GetLiquidItem(); int amount1 = liquidItem.amount; ItemDefinition template = WaterResource.Merge(splashType, liquidItem.info); if (Object.op_Inequality((Object)liquidItem.info, (Object)template)) { liquidItem.Remove(0.0f); liquidItem = ItemManager.Create(template, amount1, 0UL); if (!liquidItem.MoveToContainer(this.inventory, -1, true)) { liquidItem.Remove(0.0f); return(0); } } iAmount = Mathf.Min(this.maxStackSize - amount1, amount); liquidItem.amount += iAmount; } else { iAmount = Mathf.Min(amount, this.maxStackSize); Item obj = ItemManager.Create(splashType, iAmount, 0UL); if (obj != null && !obj.MoveToContainer(this.inventory, -1, true)) { obj.Remove(0.0f); } } return(iAmount); }
public int DoSplash(ItemDefinition splashType, int amount) { int num = 0; if (!this.HasLiquidItem()) { num = Mathf.Min(amount, this.maxStackSize); Item item = ItemManager.Create(splashType, num, (ulong)0); if (item != null && !item.MoveToContainer(this.inventory, -1, true)) { item.Remove(0f); } } else { Item liquidItem = this.GetLiquidItem(); int num1 = liquidItem.amount; ItemDefinition itemDefinition = WaterResource.Merge(splashType, liquidItem.info); if (liquidItem.info != itemDefinition) { liquidItem.Remove(0f); liquidItem = ItemManager.Create(itemDefinition, num1, (ulong)0); if (!liquidItem.MoveToContainer(this.inventory, -1, true)) { liquidItem.Remove(0f); return(0); } } num = Mathf.Min(this.maxStackSize - num1, amount); liquidItem.amount += num; } return(num); }
public void AddLiquid(ItemDefinition liquidType, int amount) { if (amount <= 0) { return; } Item item = GetItem(); Item item2 = item.contents.GetSlot(0); ItemModContainer component = item.info.GetComponent <ItemModContainer>(); if (item2 == null) { ItemManager.Create(liquidType, amount, 0uL)?.MoveToContainer(item.contents); return; } int num = Mathf.Clamp(item2.amount + amount, 0, component.maxStackSize); ItemDefinition itemDefinition = WaterResource.Merge(item2.info, liquidType); if (itemDefinition != item2.info) { item2.Remove(); item2 = ItemManager.Create(itemDefinition, num, 0uL); item2.MoveToContainer(item.contents); } else { item2.amount = num; } item2.MarkDirty(); SendNetworkUpdateImmediate(); }
public void AddLiquid(ItemDefinition liquidType, int amount) { if (amount <= 0) { return; } Item obj = this.GetItem(); Item slot = obj.contents.GetSlot(0); ItemModContainer component = (ItemModContainer)((Component)obj.info).GetComponent <ItemModContainer>(); if (slot == null) { ItemManager.Create(liquidType, amount, 0UL)?.MoveToContainer(obj.contents, -1, true); } else { int iAmount = Mathf.Clamp(slot.amount + amount, 0, component.maxStackSize); ItemDefinition template = WaterResource.Merge(slot.info, liquidType); if (Object.op_Inequality((Object)template, (Object)slot.info)) { slot.Remove(0.0f); slot = ItemManager.Create(template, iAmount, 0UL); slot.MoveToContainer(obj.contents, -1, true); } else { slot.amount = iAmount; } slot.MarkDirty(); this.SendNetworkUpdateImmediate(false); } }
public void AddLiquid(ItemDefinition liquidType, int amount) { if (amount <= 0) { return; } Item item = this.GetItem(); Item slot = item.contents.GetSlot(0); ItemModContainer component = item.info.GetComponent <ItemModContainer>(); if (slot != null) { int num = Mathf.Clamp(slot.amount + amount, 0, component.maxStackSize); ItemDefinition itemDefinition = WaterResource.Merge(slot.info, liquidType); if (itemDefinition == slot.info) { slot.amount = num; } else { slot.Remove(0f); slot = ItemManager.Create(itemDefinition, num, (ulong)0); slot.MoveToContainer(item.contents, -1, true); } slot.MarkDirty(); base.SendNetworkUpdateImmediate(false); } else { Item item1 = ItemManager.Create(liquidType, amount, (ulong)0); if (item1 != null) { item1.MoveToContainer(item.contents, -1, true); return; } } }