mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-07-23 02:56:02 +02:00
Renamed Type7Param to ItemRefParam. Changed a lot of "inventoryType" names to "itemPackage". Moved inventory code to Character class for easier use and auto-choosing the correct package.
This commit is contained in:
parent
3850860440
commit
bbac4b0fce
6 changed files with 227 additions and 77 deletions
|
@ -1,9 +1,12 @@
|
|||
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.actors.chara.player;
|
||||
using FFXIVClassic_Map_Server.actors.group;
|
||||
using FFXIVClassic_Map_Server.Actors.Chara;
|
||||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.utils;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
|
@ -56,6 +59,10 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
public Group currentParty = null;
|
||||
public ContentGroup currentContentGroup = null;
|
||||
|
||||
//Inventory
|
||||
protected Dictionary<ushort, Inventory> itemPackages = new Dictionary<ushort, Inventory>();
|
||||
private Equipment equipment;
|
||||
|
||||
public Character(uint actorID) : base(actorID)
|
||||
{
|
||||
//Init timer array to "notimer"
|
||||
|
@ -114,6 +121,162 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
else
|
||||
zone.BroadcastPacketAroundActor(this, PlayAnimationOnActorPacket.BuildPacket(actorId, animId));
|
||||
}
|
||||
|
||||
#region Inventory
|
||||
|
||||
public void AddItem(uint catalogID)
|
||||
{
|
||||
AddItem(catalogID, 1);
|
||||
}
|
||||
|
||||
public void AddItem(uint catalogID, int quantity)
|
||||
{
|
||||
AddItem(catalogID, quantity, 1);
|
||||
}
|
||||
|
||||
public void AddItem(uint catalogID, int quantity, byte quality)
|
||||
{
|
||||
ushort itemPackage = GetPackageForItem(catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
InventoryItem item = Server.GetWorldManager().CreateItem(catalogID, quantity, quality);
|
||||
itemPackages[itemPackage].AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddItem(InventoryItem item)
|
||||
{
|
||||
ushort itemPackage = GetPackageForItem(item.GetItemData().catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
itemPackages[itemPackage].AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetItem(InventoryItem item, ushort itemPackage, ushort slot)
|
||||
{
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
itemPackages[itemPackage].AddItemSpecial(slot, item);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveItem(InventoryItem item, ushort destinationPackage)
|
||||
{
|
||||
ushort sourcePackage = item.itemPackage;
|
||||
|
||||
if (!itemPackages.ContainsKey(sourcePackage) && !itemPackages.ContainsKey(destinationPackage))
|
||||
return;
|
||||
|
||||
itemPackages[sourcePackage].RemoveItem(item);
|
||||
itemPackages[destinationPackage].AddItem(item);
|
||||
}
|
||||
|
||||
public void RemoveItem(uint catalogID)
|
||||
{
|
||||
RemoveItem(catalogID, 1);
|
||||
}
|
||||
|
||||
public void RemoveItem(uint catalogID, int quantity)
|
||||
{
|
||||
RemoveItem(catalogID, quantity, 1);
|
||||
}
|
||||
|
||||
public void RemoveItem(uint catalogID, int quantity, byte quality)
|
||||
{
|
||||
ushort itemPackage = GetPackageForItem(catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
itemPackages[itemPackage].RemoveItem(catalogID, quantity, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveItemAtSlot(ushort itemPackage, ushort slot)
|
||||
{
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
itemPackages[itemPackage].RemoveItemAtSlot(slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveItem(InventoryItem item)
|
||||
{
|
||||
RemoveItem(item, 1);
|
||||
}
|
||||
|
||||
public void RemoveItem(InventoryItem item, int quantity)
|
||||
{
|
||||
if (itemPackages.ContainsKey(item.itemPackage))
|
||||
{
|
||||
itemPackages[item.itemPackage].RemoveItem(item, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasItem(uint catalogID)
|
||||
{
|
||||
return HasItem(catalogID, 1);
|
||||
}
|
||||
|
||||
public bool HasItem(uint catalogID, int minQuantity)
|
||||
{
|
||||
return HasItem(catalogID, minQuantity, 1);
|
||||
}
|
||||
|
||||
public bool HasItem(uint catalogID, int minQuantity, byte quality)
|
||||
{
|
||||
ushort itemPackage = GetPackageForItem(catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
itemPackages[itemPackage].HasItem(catalogID, minQuantity, quality);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasItem(InventoryItem item)
|
||||
{
|
||||
ushort itemPackage = GetPackageForItem(item.GetItemData().catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
//return itemPackages[itemPackage].HasItem(item);
|
||||
return false; //TODO FIX
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public InventoryItem GetItem(LuaUtils.ItemRefParam reference)
|
||||
{
|
||||
if (reference.actorId != actorId)
|
||||
return null;
|
||||
if (itemPackages.ContainsKey(reference.itemPackage))
|
||||
{
|
||||
return itemPackages[reference.itemPackage].GetItemAtSlot(reference.slot);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ushort GetPackageForItem(uint catalogID)
|
||||
{
|
||||
ItemData data = Server.GetItemGamedata(catalogID);
|
||||
|
||||
if (data == null)
|
||||
return Inventory.NORMAL;
|
||||
else
|
||||
{
|
||||
if (data.IsMoney())
|
||||
return Inventory.CURRENCY_CRYSTALS;
|
||||
else if (data.IsImportant())
|
||||
return Inventory.KEYITEMS;
|
||||
else
|
||||
return Inventory.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//public void removeItem(byUniqueId)
|
||||
//public void removeItem(byUniqueId, quantity)
|
||||
//public void removeItem(slot)
|
||||
//public void removeItem(slot, quantity)
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue