Upload from upload_mods.ps1
This commit is contained in:
28
Scripts/Dialog/DialogRequirementPlayerHasItemRebirth.cs
Normal file
28
Scripts/Dialog/DialogRequirementPlayerHasItemRebirth.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
public class DialogRequirementPlayerHasItemRebirth : BaseDialogRequirement
|
||||
{
|
||||
public override bool CheckRequirement(EntityPlayer player, EntityNPC talkingTo)
|
||||
{
|
||||
var count = 0;
|
||||
|
||||
if (string.IsNullOrEmpty(Value))
|
||||
Value = "1";
|
||||
|
||||
float.TryParse(Value, out var flValue);
|
||||
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
|
||||
var playerInventory = uiforPlayer.xui.PlayerInventory;
|
||||
var item = ItemClass.GetItem(ID);
|
||||
if (item != null)
|
||||
{
|
||||
count = playerInventory.Backpack.GetItemCount(item, -1, -1, false);
|
||||
count += playerInventory.Toolbelt.GetItemCount(item, false, -1, -1);
|
||||
if (flValue <= count)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user