C# Class Aura.Channel.World.Inventory.CreatureInventory

Inventory for players
TODO: I'm dirty and unsafe, clean me up.
Exibir arquivo Open project: aura-project/aura

Public Properties

Property Type Description
InvisiblePockets IEnumerable

Public Methods

Method Description
Add ( Item item, Pocket pocket ) : bool

Tries to add item to pocket. Returns false if the pocket doesn't exist or there was no space.

Add ( Item item, bool tempFallback ) : bool

Tries to add item to one of the main inventories, using the temp inv as fallback (if specified to do so). Returns false if there was no space.

Add ( InventoryPocket inventoryPocket ) : void

Adds pocket to inventory.

AddBagPocket ( Item item ) : bool

Adds pocket for item and updates item's linked pocket.

AddGold ( int amount ) : bool

Adds new gold stacks to the inventory until the amount was added, using temp as fallback. Returns false if something went wrong, and not everything could be added.

AddMainInventory ( ) : void

Adds main inventories (inv, personal, VIP). Call after creature's defaults (RaceInfo) have been loaded.

AddProficiency ( Item item, int amount ) : void

Increases item's proficiency and updates client.

ChangeWeaponSet ( WeaponSet set ) : void

Changes weapon set, if necessary, and updates clients.

Count ( bool>.Func predicate ) : int

Returns the amount of items matching the conditions specified.

Count ( int itemId ) : int

Returns the amount of items with this id in the inventory.

Count ( string tag ) : int

Returns the amount of items in the inventory that match the given tag.

CountItemsInPocket ( Pocket pocket ) : int

Returns the number of items in the given pocket. Returns -1 if the pocket doesn't exist.

CreatureInventory ( Creature creature ) : System

Creates new creature inventory instance for creature.

Decrement ( Item item, ushort amount = 1 ) : bool

Reduces item's amount and sends the necessary update packets. Also removes the item, if it's not a sack and its amount reaches 0.

GetAllEquipment ( ) : Item[]

Returns a new list of all items in all equipment pockets.

GetAllEquipment ( bool>.Func predicate ) : Item[]

Returns a new list of all items that match the predicate, in all equipment pockets.

GetAllItemsFrom ( Pocket pocket ) : List

Returns list of all items in pocket. Returns null if the pocket doesn't exist.

GetCastingSpeedMod ( long entityId ) : int

Returns casting speed modificator, based onthe WU upgrades for the given item entity id.

GetChainCastLevel ( SkillId skillId ) : int

Returns the chain cast level for the given skill from the equipped WUUpgrades. Returns 0 if no Chain Cast upgrade could be found.

GetEquipment ( ) : Item[]

Returns a new list of all items in all equipment pockets that aren't hair or face.

GetEquipment ( bool>.Func predicate ) : Item[]

Returns a new list of all items that match the predicate, in all equipment pockets that aren't hair or face.

GetFreePocketId ( ) : Pocket

Returns a free pocket id to be used for item bags.

GetItem ( bool>.Func predicate, StartAt startAt = StartAt.Random ) : Item

Returns first item to match predicate, or null.

GetItem ( long entityId ) : Item

Returns item with the id, or null.

GetItemAt ( Pocket pocket, int x, int y ) : Item

Returns item at the location, or null.

GetItemSafe ( long entityId ) : Item

Returns item or throws security violation exception, if item didn't exist or isn't allowed to be accessed.

GetItems ( ) : Item[]

Returns a new list of all items in the inventory.

GetItems ( bool>.Func predicate, StartAt startAt = StartAt.Random ) : List

Returns a new list of all items that match the predicate.

GetMainEquipment ( ) : Item[]

Returns a new list of all items in all main equipment pockets, meaning no style or inactive weapon pockets.

GetMainEquipment ( bool>.Func predicate ) : Item[]

Returns a new list of all items in all main equipment pockets, meaning no style or inactive weapon pockets, that match the predicate.

GetManaBurnBonus ( ) : float

Returns the ManaBurn bonus from all equipped WUUpgrades.

GetManaUseModificator ( ) : float

Returns the ManaUse modificator from all equipped WUUpgrades.

GetPocket ( Pocket pocket ) : InventoryPocket

Returns given inventory pocket. Warning: Not for general usage, only use this if you know what you're doing.

Has ( Item item ) : bool

Returns true uf the item exists in this inventory.

Has ( Pocket pocket ) : bool

Returns true if pocket exists in this inventory.

Has ( int itemId, int amount = 1 ) : bool

Returns whether inventory contains the item in this amount.

HasGold ( int amount ) : bool

Returns whether inventory contains gold in this amount.

InitAdd ( Item item ) : bool

Adds item to pocket at the position it currently has. Returns false if pocket doesn't exist.

Insert ( Item item, bool tempFallback ) : bool

Tries to add item to one of the main inventories, using temp as fallback. Unlike "Add" the item will be filled into stacks first, if possible, before calling Add.

Insert ( Item item, bool tempFallback, List &changed ) : bool

Tries to add item to one of the main inventories, using temp as fallback. Unlike "Add" the item will be filled into stacks first, if possible, before calling Add.

InsertStacks ( int itemId, int amount ) : bool

Adds new stacks to the inventory until the amount was added, using temp as fallback. Returns false if something went wrong, and not everything could be added.

Move ( Item item, Pocket target, byte targetX, byte targetY ) : bool

Used from MoveItem handler.

The item is the one that's interacted with, the one picked up when taking it, the one being put into a packet when it's one the cursor. Colliding items switch places with it.

MoveItemsToInvFrom ( ) : void

Moves all items creature has in the given pockets to the main inventory.

MovePet ( Creature pet, Item item, Creature other, Pocket target, int targetX, int targetY ) : bool

Moving item between char and pet, used from handler.

PickUp ( Item item ) : bool

Tries to put item into the inventory, by filling stacks and adding it. If it was completely added to the inventory, it's removed from the region the inventory's creature is in.

ReduceDurability ( Item item, int amount ) : void

Reduces durability and updates client.

Checks NoDurabilityLoss option, meaning this method won't reduce the durability if the option is set.

ReduceMaxDurability ( Item item, int amount ) : void

Reduces max durability and updates client.

Remove ( Item item ) : bool

Removes item from inventory, if it is in it, and sends update packets.

Remove ( Pocket pocket ) : bool

Removes pocket from inventory.

Remove ( int itemId, int amount = 1 ) : bool

Removes the amount of items with the id from the inventory. Returns true if the specified amount was removed.

Does not check amount before removing.

RemoveGold ( int amount ) : bool

Removes the amount of gold from the inventory. Returns true if the specified amount was removed.

StartLiveUpdate ( ) : void

Subscribes inventory to events necessary for upgrade effect live updates.

UpdateStatBonuses ( ) : void

Removes all upgrade effect bonuses from current equipment and reapplies them.

Private Methods

Method Description
ApplyDefenseBonuses ( Item item ) : void

Applies non-upgrade Defense and Protection bonuses from the item.

ApplyUpgradeEffects ( Item item ) : void

Applies upgrade effects from item.

ApplyUpgrades ( Item item ) : void

Applies upgrade bonuses from the item.

CheckLeftHand ( Item item, Pocket source, Pocket target ) : void

Unequips item in left hand/magazine, if item in right hand is moved.

CheckRightHand ( Item item, Pocket source, Pocket target ) : void

Makes sure you can't combine invalid equipment, like 2H and shields.

CreatureInventory ( ) : System

Initializes static information.

HandleWUUpgrades ( Item item ) : void

Caches and applies WU upgrades for item.

OnCreatureChangedTitles ( Creature creature ) : void

Raised when inventory's creature changes titles.

OnCreatureConditionsChanged ( Creature creature ) : void

Raised when inventory's creature's conditions change.

OnCreatureLeveledUp ( Creature creature, int levelBefore ) : void

Raised when inventory's creature leveled up.

OnCreatureSkillRankChanged ( Creature creature, Skill skill ) : void

Raised when one of the inventory's creature's skill's rank changes.

OnEquip ( Item item ) : void

Called when an item is equipped, or becomes "active". Calls and sets the appropriate events and stat bonuses. Does not update the client.

Before this is called, the references should be updated, so the subscribers see the character as he is *after* equipping the item. For example, to check the equipment for custom set bonuses. Afterwards the equip stats should be updated, so the client displays the changes. Both of these things aren't done inside this method, because there are cases where we have to equip/unequip multiple items, and we don't want to spam the client. You also have to take care of the visual equipment updates, for similar reasons.

OnHoursTimeTick ( ErinnTime now ) : void

Raised once ever RL hour.

OnItemEntersInventory ( Item item ) : void

Handles events that need to happen when an item "enters" the inventory.

Only called when an item is actually new to the inventory.

OnItemLeavesInventory ( Item item ) : void

Handles events that need to happen when an item "leaves" the inventory.

Only called when an item is completely removed from the inventory.

OnUnequip ( Item item ) : void

Called when an item is unequipped, or becomes "inactive". Calls and removes the appropriate events and stat bonuses. Does not update the client.

Before this is called, the references should be updated, so the subscribers see the character as he is *after* unequipping the item. For example, to check the equipment for custom set bonuses. Afterwards the equip stats should be updated, so the client displays the changes. Both of these things aren't done inside this method, because there are cases where we have to equip/unequip multiple items, and we don't want to spam the client. You also have to take care of the visual equipment updates, for similar reasons.

PrepareBags ( Item item ) : void

Adds bag pocket to inventory and sets it for the item if item is a bag. Call before ItemNew, otherwise the bag won't open until relog.

TryAutoAdd ( Item item, bool tempFallback ) : bool

Tries to add item to one of the main invs or bags, wherever free space is available. Returns whether it was successful.

UnequipIfCantBeTouched ( Item item ) : void

Moves item to inventory if it can't be touched.

UpdateChangedItems ( IEnumerable items ) : void

Sends amount update or remove packets for all items, depending on their amount.

UpdateEquipReferences ( ) : void

Updates quick access equipment refernces.

UpdateEquipStats ( ) : void

Sends private stat update for all equipment relevant stats.

Method Details

Add() public method

Tries to add item to pocket. Returns false if the pocket doesn't exist or there was no space.
public Add ( Item item, Pocket pocket ) : bool
item Item
pocket Pocket
return bool

Add() public method

Tries to add item to one of the main inventories, using the temp inv as fallback (if specified to do so). Returns false if there was no space.
public Add ( Item item, bool tempFallback ) : bool
item Item
tempFallback bool
return bool

Add() public method

Adds pocket to inventory.
public Add ( InventoryPocket inventoryPocket ) : void
inventoryPocket InventoryPocket
return void

AddBagPocket() public method

Adds pocket for item and updates item's linked pocket.
public AddBagPocket ( Item item ) : bool
item Item
return bool

AddGold() public method

Adds new gold stacks to the inventory until the amount was added, using temp as fallback. Returns false if something went wrong, and not everything could be added.
public AddGold ( int amount ) : bool
amount int
return bool

AddMainInventory() public method

Adds main inventories (inv, personal, VIP). Call after creature's defaults (RaceInfo) have been loaded.
public AddMainInventory ( ) : void
return void

AddProficiency() public method

Increases item's proficiency and updates client.
public AddProficiency ( Item item, int amount ) : void
item Item
amount int
return void

ChangeWeaponSet() public method

Changes weapon set, if necessary, and updates clients.
public ChangeWeaponSet ( WeaponSet set ) : void
set WeaponSet
return void

Count() public method

Returns the amount of items matching the conditions specified.
public Count ( bool>.Func predicate ) : int
predicate bool>.Func
return int

Count() public method

Returns the amount of items with this id in the inventory.
public Count ( int itemId ) : int
itemId int
return int

Count() public method

Returns the amount of items in the inventory that match the given tag.
public Count ( string tag ) : int
tag string
return int

CountItemsInPocket() public method

Returns the number of items in the given pocket. Returns -1 if the pocket doesn't exist.
public CountItemsInPocket ( Pocket pocket ) : int
pocket Pocket
return int

CreatureInventory() public method

Creates new creature inventory instance for creature.
public CreatureInventory ( Creature creature ) : System
creature Aura.Channel.World.Entities.Creature
return System

Decrement() public method

Reduces item's amount and sends the necessary update packets. Also removes the item, if it's not a sack and its amount reaches 0.
public Decrement ( Item item, ushort amount = 1 ) : bool
item Item
amount ushort
return bool

GetAllEquipment() public method

Returns a new list of all items in all equipment pockets.
public GetAllEquipment ( ) : Item[]
return Item[]

GetAllEquipment() public method

Returns a new list of all items that match the predicate, in all equipment pockets.
public GetAllEquipment ( bool>.Func predicate ) : Item[]
predicate bool>.Func
return Item[]

GetAllItemsFrom() public method

Returns list of all items in pocket. Returns null if the pocket doesn't exist.
public GetAllItemsFrom ( Pocket pocket ) : List
pocket Pocket
return List

GetCastingSpeedMod() public method

Returns casting speed modificator, based onthe WU upgrades for the given item entity id.
public GetCastingSpeedMod ( long entityId ) : int
entityId long
return int

GetChainCastLevel() public method

Returns the chain cast level for the given skill from the equipped WUUpgrades. Returns 0 if no Chain Cast upgrade could be found.
public GetChainCastLevel ( SkillId skillId ) : int
skillId SkillId
return int

GetEquipment() public method

Returns a new list of all items in all equipment pockets that aren't hair or face.
public GetEquipment ( ) : Item[]
return Item[]

GetEquipment() public method

Returns a new list of all items that match the predicate, in all equipment pockets that aren't hair or face.
public GetEquipment ( bool>.Func predicate ) : Item[]
predicate bool>.Func
return Item[]

GetFreePocketId() public method

Returns a free pocket id to be used for item bags.
public GetFreePocketId ( ) : Pocket
return Pocket

GetItem() public method

Returns first item to match predicate, or null.
public GetItem ( bool>.Func predicate, StartAt startAt = StartAt.Random ) : Item
predicate bool>.Func
startAt StartAt /// Affects the order of the returned items, based on their position in /// the inventory. ///
return Item

GetItem() public method

Returns item with the id, or null.
public GetItem ( long entityId ) : Item
entityId long
return Item

GetItemAt() public method

Returns item at the location, or null.
public GetItemAt ( Pocket pocket, int x, int y ) : Item
pocket Pocket
x int
y int
return Item

GetItemSafe() public method

Returns item or throws security violation exception, if item didn't exist or isn't allowed to be accessed.
public GetItemSafe ( long entityId ) : Item
entityId long
return Item

GetItems() public method

Returns a new list of all items in the inventory.
public GetItems ( ) : Item[]
return Item[]

GetItems() public method

Returns a new list of all items that match the predicate.
public GetItems ( bool>.Func predicate, StartAt startAt = StartAt.Random ) : List
predicate bool>.Func
startAt StartAt /// Affects the order of the returned items, based on their position in /// the inventory. ///
return List

GetMainEquipment() public method

Returns a new list of all items in all main equipment pockets, meaning no style or inactive weapon pockets.
public GetMainEquipment ( ) : Item[]
return Item[]

GetMainEquipment() public method

Returns a new list of all items in all main equipment pockets, meaning no style or inactive weapon pockets, that match the predicate.
public GetMainEquipment ( bool>.Func predicate ) : Item[]
predicate bool>.Func
return Item[]

GetManaBurnBonus() public method

Returns the ManaBurn bonus from all equipped WUUpgrades.
public GetManaBurnBonus ( ) : float
return float

GetManaUseModificator() public method

Returns the ManaUse modificator from all equipped WUUpgrades.
public GetManaUseModificator ( ) : float
return float

GetPocket() public method

Returns given inventory pocket. Warning: Not for general usage, only use this if you know what you're doing.
public GetPocket ( Pocket pocket ) : InventoryPocket
pocket Pocket
return InventoryPocket

Has() public method

Returns true uf the item exists in this inventory.
public Has ( Item item ) : bool
item Item
return bool

Has() public method

Returns true if pocket exists in this inventory.
public Has ( Pocket pocket ) : bool
pocket Pocket
return bool

Has() public method

Returns whether inventory contains the item in this amount.
public Has ( int itemId, int amount = 1 ) : bool
itemId int
amount int
return bool

HasGold() public method

Returns whether inventory contains gold in this amount.
public HasGold ( int amount ) : bool
amount int
return bool

InitAdd() public method

Adds item to pocket at the position it currently has. Returns false if pocket doesn't exist.
public InitAdd ( Item item ) : bool
item Item
return bool

Insert() public method

Tries to add item to one of the main inventories, using temp as fallback. Unlike "Add" the item will be filled into stacks first, if possible, before calling Add.
public Insert ( Item item, bool tempFallback ) : bool
item Item
tempFallback bool Add to temp inv when all other pockets are full?
return bool

Insert() public method

Tries to add item to one of the main inventories, using temp as fallback. Unlike "Add" the item will be filled into stacks first, if possible, before calling Add.
public Insert ( Item item, bool tempFallback, List &changed ) : bool
item Item
tempFallback bool Add to temp inv when all other pockets are full?
changed List List of stacks that items were inserted into.
return bool

InsertStacks() public method

Adds new stacks to the inventory until the amount was added, using temp as fallback. Returns false if something went wrong, and not everything could be added.
public InsertStacks ( int itemId, int amount ) : bool
itemId int Id of the item to add.
amount int Amount to add, value affects the amount of stacks.
return bool

Move() public method

Used from MoveItem handler.
The item is the one that's interacted with, the one picked up when taking it, the one being put into a packet when it's one the cursor. Colliding items switch places with it.
public Move ( Item item, Pocket target, byte targetX, byte targetY ) : bool
item Item Item to move
target Pocket Pocket to move it to
targetX byte
targetY byte
return bool

MoveItemsToInvFrom() public method

Moves all items creature has in the given pockets to the main inventory.
public MoveItemsToInvFrom ( ) : void
return void

MovePet() public method

Moving item between char and pet, used from handler.
public MovePet ( Creature pet, Item item, Creature other, Pocket target, int targetX, int targetY ) : bool
pet Aura.Channel.World.Entities.Creature Always the pet
item Item
other Aura.Channel.World.Entities.Creature The "other" creature, player when taking out, pet when putting in.
target Pocket
targetX int
targetY int
return bool

PickUp() public method

Tries to put item into the inventory, by filling stacks and adding it. If it was completely added to the inventory, it's removed from the region the inventory's creature is in.
public PickUp ( Item item ) : bool
item Item
return bool

ReduceDurability() public method

Reduces durability and updates client.
Checks NoDurabilityLoss option, meaning this method won't reduce the durability if the option is set.
public ReduceDurability ( Item item, int amount ) : void
item Item
amount int
return void

ReduceMaxDurability() public method

Reduces max durability and updates client.
public ReduceMaxDurability ( Item item, int amount ) : void
item Item
amount int
return void

Remove() public method

Removes item from inventory, if it is in it, and sends update packets.
public Remove ( Item item ) : bool
item Item
return bool

Remove() public method

Removes pocket from inventory.
public Remove ( Pocket pocket ) : bool
pocket Pocket
return bool

Remove() public method

Removes the amount of items with the id from the inventory. Returns true if the specified amount was removed.
Does not check amount before removing.
public Remove ( int itemId, int amount = 1 ) : bool
itemId int
amount int
return bool

RemoveGold() public method

Removes the amount of gold from the inventory. Returns true if the specified amount was removed.
public RemoveGold ( int amount ) : bool
amount int
return bool

StartLiveUpdate() public method

Subscribes inventory to events necessary for upgrade effect live updates.
public StartLiveUpdate ( ) : void
return void

UpdateStatBonuses() public method

Removes all upgrade effect bonuses from current equipment and reapplies them.
public UpdateStatBonuses ( ) : void
return void

Property Details

InvisiblePockets public_oe static_oe property

These pockets aren't checked by the Count() method
public static IEnumerable InvisiblePockets
return IEnumerable