DayZ 1.24
Loading...
Searching...
No Matches
GameInventory Class Reference

script counterpart to engine's class Inventory More...

Inheritance diagram for GameInventory:
[legend]
Collaboration diagram for GameInventory:
[legend]

Protected Member Functions

proto native bool GetCurrentInventoryLocation (out notnull InventoryLocation loc)
 returns information about current item location
 
proto native bool FindFreeLocationFor (notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
 FindFreeLocationFor.
 
proto native bool FindFreeLocationForEx (notnull EntityAI item, FindInventoryLocationType flags, notnull InventoryLocation exclude, out notnull InventoryLocation loc)
 FindFreeLocationForEx.
 
proto native bool FindFirstFreeLocationForNewEntity (string item_type, FindInventoryLocationType flags, out notnull InventoryLocation loc)
 FindFirstFreeLocationForNewEntity.
 
proto native int FindFreeLocationsFor (notnull EntityAI item, FindInventoryLocationType flags, out notnull array< ref InventoryLocation > locs)
 searches inventory for suitable location for @item
 
bool IsInCargo ()
 Returns true if this Inventory owner is in cargo of something.
 
bool IsAttachment ()
 Returns true if this Inventory owner is an attachment of something.
 
bool IsCargoInHiearchy ()
 Returns true if inventory owner or his hiearchy parents are in cargo.
 
bool GetCurrentAttachmentSlotInfo (out int slot_id, out string slot_name)
 Returns true if the item is currently attached and outputs attachment slot id and name.
 
proto native bool CanAddSwappedEntity (notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 
void OnInventoryFailure (InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
 
bool TakeEntityToInventory (InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
 Put item anywhere into this entity (as attachment or into cargo, recursively)
 
bool TakeEntityToTargetInventory (InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
 helper that finds location first, then moves the entity into it
 
bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
 move src to dst
 
bool TakeEntityToCargo (InventoryMode mode, notnull EntityAI item)
 moves item to cargo of this intentory
 
bool TakeEntityToTargetCargo (InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
 Put item into into cargo of another entity.
 
bool TakeEntityToCargoEx (InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
 moves item on specific cargo location
 
bool TakeEntityToTargetCargoEx (InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
 Put item into into cargo on specific cargo location of another entity.
 
bool TakeEntityAsAttachmentEx (InventoryMode mode, notnull EntityAI item, int slot)
 
bool TakeEntityAsTargetAttachmentEx (InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
 put item as attachment of target
 
bool TakeEntityAsAttachment (InventoryMode mode, notnull EntityAI item)
 
bool TakeEntityAsTargetAttachment (InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
 
bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
 
bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
 
bool DropEntity (InventoryMode mode, EntityAI owner, notnull EntityAI item)
 
bool DropEntityWithTransform (InventoryMode mode, EntityAI owner, notnull EntityAI item, vector transform[4])
 
bool DropEntityInBounds (InventoryMode mode, EntityAI owner, notnull EntityAI item, vector halfExtents, float angle, float cosAngle, float sinAngle)
 
bool LocalDestroyEntity (notnull EntityAI item)
 
bool ReplaceItemWithNew (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
 
proto native bool GetFlipCargo ()
 
proto native void SetFlipCargo (bool flip)
 
proto native void FlipCargo ()
 
proto native void ResetFlipCargo ()
 
proto native EntityAI GetInventoryOwner ()
 Engine native functions.
 
proto native bool HasEntityInInventory (notnull EntityAI item)
 query inventory if item is somewhere
 
proto native bool EnumerateInventory (InventoryTraversalType tt, out array< EntityAI > items)
 enumerate inventory using traversal type and filling items array
 
proto native int CountInventory ()
 almost identical to EnumerateInventory except it does not return items
 
proto native CargoBase GetCargo ()
 cargo
 
proto native CargoBase GetCargoFromIndex (int index)
 
proto native EntityAI CreateEntityInCargo (string typeName)
 Create Entity of specified type in cargo of entity.
 
proto native EntityAI CreateEntityInCargoEx (string typeName, int idx, int row, int col, bool flip)
 Create Entity of specified type in cargo of entity at coordinates (row, col)
 
proto native bool HasEntityInCargo (notnull EntityAI e)
 
proto native bool HasEntityInCargoEx (notnull EntityAI e, int idx, int row, int col)
 
proto native bool CanAddEntityInCargo (notnull EntityAI e, bool flip)
 
proto native bool CanAddEntityInCargoEx (notnull EntityAI e, int idx, int row, int col, bool flip)
 
proto native bool CanAddEntityInCargoExLoc (InventoryLocation loc)
 
proto native bool TestAddEntityInCargoEx (notnull EntityAI e, int idx, int row, int col, bool flip, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
 
proto native bool TestAddEntityInCargoExLoc (notnull InventoryLocation loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
 
proto native bool CanRemoveEntityInCargo (notnull EntityAI e)
 
proto native bool CanRemoveEntityInCargoEx (notnull EntityAI e, int idx, int row, int col)
 
proto native int GetSlotId (int index)
 attachments
 
proto native int GetSlotIdCount ()
 
proto native int GetAttachmentSlotId (int index)
 
proto native int GetAttachmentSlotsCount ()
 
bool HasAttachmentSlot (int slotId)
 
proto native bool HasInventorySlot (int slotId)
 
proto native int AttachmentCount ()
 Returns count of attachments attached to this item.
 
proto native EntityAI CreateAttachment (string typeName)
 Create Entity of specified type as attachment of entity.
 
proto native EntityAI CreateAttachmentEx (string typeName, int slotId)
 Create Entity of specified type as attachment of entity.
 
proto native EntityAI GetAttachmentFromIndex (int index)
 
proto native EntityAI FindAttachment (int slot)
 Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)
 
proto native EntityAI FindAttachmentByName (string slotName)
 Returns attached entity in slot (you can use EntityAI.GetActionComponentName to get slot id)
 
proto native bool HasAttachment (notnull EntityAI e)
 brief Returns True if entity is attached to this
 
proto native bool HasAttachmentEx (notnull EntityAI e, int slot)
 brief Returns True if entity is attached to this in slot
 
proto native bool CanAddAttachment (notnull EntityAI e)
 Check if attachment can be added to any slot.
 
proto native bool CanAddAttachmentEx (notnull EntityAI e, int slot)
 Check if attachment can be added to slot @NOTE: Note that slot index IS NOT slot ID! Slot ID is defined in DZ/data/config.cpp.
 
proto native bool CanRemoveAttachment (EntityAI attachment)
 
proto native bool CanRemoveAttachmentEx (EntityAI attachment, int slot)
 
proto native EntityAI FindPlaceholderForSlot (int slot)
 Returns placeholder entity for slot (naked arms, legs etc)
 
proto native bool IsPlaceholderEntity (notnull Object e)
 
proto native bool CanLockInventoryWithKey (notnull EntityAI key)
 locks
 
proto native bool CanUnlockInventoryWithKey (notnull EntityAI key)
 
proto native void LockInventoryWithKey (notnull EntityAI key)
 
proto native void UnlockInventoryWithKey (notnull EntityAI key)
 
proto native bool HasKeys ()
 
proto native void LockInventory (int lockType)
 
proto native void UnlockInventory (int lockType)
 
proto native int GetScriptLockCount ()
 
proto native bool IsInventoryUnlocked ()
 
proto native bool IsInventoryLocked ()
 
proto native bool IsInventoryLockedForLockType (int lockType)
 
proto native bool SetSlotLock (int slot, bool locked)
 
proto native bool GetSlotLock (int slot)
 
void Init ()
 script functions
 
bool OnStoreLoad (ParamsReadContext ctx, int version)
 db load hooks
 
void OnAfterStoreLoad ()
 
void OnStoreSave (ParamsWriteContext ctx)
 db store hook
 
void EEInit ()
 
void EEDelete (EntityAI parent)
 
EntityAI CreateInInventory (string type)
 creates entity somewhere in inventory
 
bool CanAddEntityToInventory (notnull EntityAI item, int flag=FindInventoryLocationType.ANY)
 ask inventory if item could be placed somewhere in inventory
 
bool AddEntityToInventory (notnull EntityAI item)
 add entity somewhere in inventory
 
bool CanRemoveEntity ()
 Returns if entity can be removed from its current location.
 
bool CanAddEntityInto (notnull EntityAI item, FindInventoryLocationType flags=FindInventoryLocationType.ANY)
 Asks inventory if item could be placed in inventory, hands, etc.
 
bool CanAddEntityIntoInventory (notnull EntityAI item)
 Test if entity can be put to the inventory (Cargo, ProxyCargo, Attachment)
 
bool CanAddEntityIntoHands (notnull EntityAI item)
 Test if entity can be put into hands.
 
bool OnInputUserDataProcess (ParamsReadContext ctx)
 synchronization
 
bool OnInventoryJunctureFromServer (ParamsReadContext ctx)
 
bool OnInventoryJunctureRepairFromServer (ParamsReadContext ctx)
 
void OnInventoryJunctureFailureFromServer (ParamsReadContext ctx)
 
void OnServerInventoryCommand (ParamsReadContext ctx)
 

Static Protected Member Functions

static proto native EntityAI LocationCreateEntity (notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
 creates new item directly at location
 
static proto native EntityAI LocationCreateLocalEntity (notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
 creates new local item directly at location @NOTE: the item is created localy, i.e. it's not registered to network
 
static proto native bool LocationCanAddEntity (notnull InventoryLocation inv_loc)
 queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/...
 
static bool LocationCanAddEntityEx (notnull InventoryLocation inv_loc)
 
static proto native bool LocationTestAddEntity (notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
 test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/...
 
static proto native bool LocationCanRemoveEntity (notnull InventoryLocation inv_loc)
 queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/...
 
static proto native bool LocationCanMoveEntity (notnull InventoryLocation src, notnull InventoryLocation dst)
 queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthand for CanRemove + CanAdd query
 
static int GetInventoryCheckContext ()
 
static bool LocationCanMoveEntitySyncCheck (notnull InventoryLocation src, notnull InventoryLocation dst)
 
static proto native EntityAI LocationGetEntity (notnull InventoryLocation inv_loc)
 
static void OnServerInventoryCommandStatic (ParamsReadContext ctx)
 
static proto native bool LocationAddEntity (notnull InventoryLocation inv_loc)
 adds item to inventory location
 
static proto native bool LocationRemoveEntity (notnull InventoryLocation inv_loc)
 removes item from inventory location
 
static proto native bool LocationMoveEntity (notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
 removes item from current inventory location and adds it to destination
 
static proto native bool LocationSyncMoveEntity (notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
 synchronously removes item from current inventory location and adds it to destination no anims involved
 
static proto native bool LocationSwap (notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 swaps two entities
 
static proto native bool ServerLocationMoveEntity (notnull EntityAI item, ParamsWriteContext ctx)
 removes item from current inventory location and adds it to destination + sync via inventory command
 
static proto native bool ServerLocationSyncMoveEntity (Man player, notnull EntityAI item, ParamsWriteContext ctx)
 synchronously removes item from current inventory location and adds it to destination + sync via inventory command no anims involved
 
static proto native bool ServerLocationSwap (notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx)
 swaps two entities
 
static proto native bool ServerHandEvent (notnull Man player, notnull EntityAI item, ParamsWriteContext ctx)
 hand event to clients
 
static proto native bool PrepareDropEntityPos (EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
 Finds a transformation for the item to be dropped to If the initial transforation overlaps with another conflicting entity (i.e. car) then the transform will be snapped to the nearest outer edge. If no valid snapping transformation could be found, then the output from 'PlaceOnSurface' is used.
 
static proto native bool TestDropEntityPos (EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
 
static proto native bool CanSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
 test if ordinary swap can be performed.
 
static bool CanSwapEntitiesEx (notnull EntityAI item1, notnull EntityAI item2)
 
static proto native bool CanForceSwapEntities (notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
 test if forced swap can be performed.
 
static bool CanForceSwapEntitiesEx (notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
 
static bool MakeDstForSwap (notnull InventoryLocation src1, notnull InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
 helper function for swap
 
static bool MakeSrcAndDstForSwap (notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
 helper function for swap
 
static bool MakeSrcAndDstForForceSwap (notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
 helper function for ForceSwap
 
static bool SetGroundPosByOwner (EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
 
static bool SetGroundPosByTransform (EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
 
static void SetGroundPosByOwnerBounds (EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
 

Static Protected Attributes

static int m_inventory_check_context = InventoryCheckContext.DEFAULT
 
const int c_InventoryReservationTimeoutMS = 5000
 reservations
 
const int c_InventoryReservationTimeoutShortMS = 3000
 
bool AddInventoryReservationEx (EntityAI item, InventoryLocation dst, int timeout_ms)
 
bool ExtendInventoryReservationEx (EntityAI item, InventoryLocation dst, int timeout_ms)
 
bool ClearInventoryReservationEx (EntityAI item, InventoryLocation dst)
 
proto native int GetAnyInventoryReservationCount ()
 
static proto native bool AddInventoryReservation (EntityAI item, InventoryLocation dst, int timeout_ms)
 
static proto native bool ExtendInventoryReservation (EntityAI item, InventoryLocation dst, int timeout_ms)
 
static proto native bool ClearInventoryReservation (EntityAI item, InventoryLocation dst)
 
static proto native bool HasInventoryReservation (EntityAI item, InventoryLocation dst)
 Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY, FindInventoryReservationMode.LEGACY)
 
static proto native bool HasInventoryReservationCanAdd (EntityAI item, InventoryLocation dst)
 Internally: !HasInventoryReservationEx(item, dst, FindInventoryReservationMode.ITEM, FindInventoryReservationMode.DST)
 
static proto native bool HasInventoryReservationEx (EntityAI item, InventoryLocation dst, FindInventoryReservationMode itemMode, FindInventoryReservationMode parentMode)
 itemMode will iterate over item reservations, parentMode will iterate over parent reservations
 
static proto native bool GetInventoryReservationCount (EntityAI item, InventoryLocation dst)
 
const float c_MaxItemDistanceRadius = 2.5
 anti-cheats
 
static proto native bool CheckRequestSrc (notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
 
static proto native bool CheckDropRequest (notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
 
static proto native bool CheckTakeItemRequest (notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
 
static proto native bool CheckMoveToDstRequest (notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
 
static proto native bool CheckSwapItemsRequest (notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
 
static proto native bool CheckManipulatedObjectsDistances (notnull EntityAI e0, notnull EntityAI e1, float radius)
 

Detailed Description

script counterpart to engine's class Inventory

Definition at line 78 of file Inventory.c.

Member Function Documentation

◆ AddEntityToInventory()

GameInventory::AddEntityToInventory ( notnull EntityAI item)
inlineprotected

add entity somewhere in inventory

All available inventory locations (hands, cargo, attachments, proxycargo, ...) are traversed recursively from root to leafs.

@NOTE: AddEntityToInventory does not perform the checks the CanAddEntityToInventory does (script conditions for example). if not sure, always call CanAddEntityToInventory before AddEntityToInventory.

Parameters
[in]itemitem to be placed in inventory
Returns
true if item can be added, false otherwise

Definition at line 899 of file Inventory.c.

900 {
903 if (result)
904 return LocationAddEntity(il);
905
906 return result;
907 }
FindInventoryLocationType
flags for searching locations in inventory
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc)
adds item to inventory location
InventoryLocation.

References FindFreeLocationFor(), and LocationAddEntity().

◆ AddInventoryReservation()

static proto native bool GameInventory::AddInventoryReservation ( EntityAI item,
InventoryLocation dst,
int timeout_ms )
staticprotected

◆ AddInventoryReservationEx()

bool GameInventory::AddInventoryReservationEx ( EntityAI item,
InventoryLocation dst,
int timeout_ms )
inlineprotected

Definition at line 691 of file Inventory.c.

692 {
693 if (GetGame().IsMultiplayer() && GetGame().IsServer())
694 return true;
695
697#ifdef DEVELOPER
699 {
700 DayZPlayer player = GetGame().GetPlayer();
701 if (player)
702 {
703 if (item)
704 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "AddInventoryReservation", player.ToString());
705 else
706 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "AddInventoryReservation", player.ToString());
707 }
708 }
709#endif
710 return ret_val;
711 }
Definition Debug.c:14
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:163
static proto native bool AddInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
static string DumpToStringNullSafe(InventoryLocation loc)
static bool IsInventoryReservationLogEnable()
Definition Debug.c:739
proto native CGame GetGame()

References AddInventoryReservation(), InventoryLocation::DumpToStringNullSafe(), GetGame(), Debug::InventoryMoveLog(), and LogManager::IsInventoryReservationLogEnable().

◆ AttachmentCount()

GameInventory::AttachmentCount ( )
protected

Returns count of attachments attached to this item.

◆ CanAddAttachment()

GameInventory::CanAddAttachment ( notnull EntityAI e)
protected

Check if attachment can be added to any slot.

Returns
true if entity can be added as attachment

◆ CanAddAttachmentEx()

GameInventory::CanAddAttachmentEx ( notnull EntityAI e,
int slot )
protected

Check if attachment can be added to slot @NOTE: Note that slot index IS NOT slot ID! Slot ID is defined in DZ/data/config.cpp.

◆ CanAddEntityInCargo()

proto native bool GameInventory::CanAddEntityInCargo ( notnull EntityAI e,
bool flip )
protected

◆ CanAddEntityInCargoEx()

proto native bool GameInventory::CanAddEntityInCargoEx ( notnull EntityAI e,
int idx,
int row,
int col,
bool flip )
protected

◆ CanAddEntityInCargoExLoc()

proto native bool GameInventory::CanAddEntityInCargoExLoc ( InventoryLocation loc)
protected

◆ CanAddEntityInto()

GameInventory::CanAddEntityInto ( notnull EntityAI item,
FindInventoryLocationType flags = FindInventoryLocationType.ANY )
inlineprotected

Asks inventory if item could be placed in inventory, hands, etc.

Location is based on the flags parameter. This method is used in methods that are asking for if item can be placed in specific location, like CanAddEntityToInventory, CanAddEntityInHands, etc.

Parameters
[in]itemitem to be placed in inventory
[in]flagsFindInventoryLocationType
Returns
true if item can be added, false otherwise

Definition at line 934 of file Inventory.c.

935 {
937 return FindFreeLocationFor(item, flags, loc) && !item.IsHologram();
938 }

References FindFreeLocationFor().

Referenced by CanAddEntityIntoHands(), and CanAddEntityIntoInventory().

◆ CanAddEntityIntoHands()

bool GameInventory::CanAddEntityIntoHands ( notnull EntityAI item)
inlineprotected

Test if entity can be put into hands.

Definition at line 951 of file Inventory.c.

952 {
954 }
bool CanAddEntityInto(notnull EntityAI item, FindInventoryLocationType flags=FindInventoryLocationType.ANY)
Asks inventory if item could be placed in inventory, hands, etc.
Definition Inventory.c:934

References CanAddEntityInto().

◆ CanAddEntityIntoInventory()

bool GameInventory::CanAddEntityIntoInventory ( notnull EntityAI item)
inlineprotected

Test if entity can be put to the inventory (Cargo, ProxyCargo, Attachment)

Definition at line 943 of file Inventory.c.

944 {
946 }

References CanAddEntityInto().

◆ CanAddEntityToInventory()

GameInventory::CanAddEntityToInventory ( notnull EntityAI item,
int flag = FindInventoryLocationType.ANY )
inlineprotected

ask inventory if item could be placed somewhere in inventory

All available inventory locations (hands, cargo, attachments, proxycargo, ...) are traversed recursively from root to leafs.

Parameters
[in]itemitem to be placed in inventory
Returns
true if item can be added, false otherwise

Definition at line 879 of file Inventory.c.

880 {
883 return result;
884 }

References FindFreeLocationFor().

◆ CanAddSwappedEntity()

proto native bool GameInventory::CanAddSwappedEntity ( notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2 )
protected

◆ CanForceSwapEntities()

GameInventory::CanForceSwapEntities ( notnull EntityAI item1,
InventoryLocation item1_dst,
notnull EntityAI item2,
out InventoryLocation item2_dst )
staticprotected

test if forced swap can be performed.

Parameters
[in]item1is the forced item (primary)
[in]item1_dstoptional destination for item1 (null if item1 goes to place of item2)
[in]item2second item that will be replaced by the item1. (secondary)
[out]item2_dstsecond item's potential destination (if null, search for item_dst2 is ommited). if (NOT null AND IsValid()), then it is tried first, without search to inventory
Returns
true if can be force swapped

Referenced by CanForceSwapEntitiesEx().

◆ CanForceSwapEntitiesEx()

static bool GameInventory::CanForceSwapEntitiesEx ( notnull EntityAI item1,
InventoryLocation item1_dst,
notnull EntityAI item2,
out InventoryLocation item2_dst )
inlinestaticprotected

Definition at line 645 of file Inventory.c.

646 {
648 return false;
649
650 int slot;
652
653 if (!item1.CanBeFSwaped())
654 return false;
655
656 if (item1_dst == null)
657 {
658 item2.GetInventory().GetCurrentInventoryLocation(il);
659 slot = il.GetSlot();
660 }
661 else
662 slot = item1_dst.GetSlot();
663
664 if (item1.GetQuantity() > item1.GetTargetQuantityMax(slot))
665 return false;
666
667 if (item2_dst == null)
668 {
669 item1.GetInventory().GetCurrentInventoryLocation(il);
670 slot = il.GetSlot();
671 }
672 else
673 slot = item2_dst.GetSlot();
674
675 if (!item1.CanSwapEntities(item2, item2_dst, item1_dst) || !item2.CanSwapEntities(item1, item1_dst, item2_dst))
676 return false;
677
678 if (item2.GetQuantity() > item2.GetTargetQuantityMax(slot))
679 return false;
680
681 return true;
682 }
static proto native bool CanForceSwapEntities(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
test if forced swap can be performed.

References CanForceSwapEntities().

Referenced by HandEventBase::CanPerformEvent(), HandEventSwap::CanPerformEvent(), WeaponManager::CanSwapMagazine(), LayoutHolder::CanSwapOrTakeToHandsEx(), Icon::DraggingOverSwap(), ItemManager::GetChosenCombinationFlag(), HandGuardBase::GuardCondition(), ManBase::OnQuickBarSingleUse(), WeaponManager::PrepareInventoryLocationForMagazineSwap(), Icon::Swap(), and ValidateSwap().

◆ CanLockInventoryWithKey()

proto native bool GameInventory::CanLockInventoryWithKey ( notnull EntityAI key)
protected

locks

◆ CanRemoveAttachment()

proto native bool GameInventory::CanRemoveAttachment ( EntityAI attachment)
protected

◆ CanRemoveAttachmentEx()

proto native bool GameInventory::CanRemoveAttachmentEx ( EntityAI attachment,
int slot )
protected

◆ CanRemoveEntity()

bool GameInventory::CanRemoveEntity ( )
inlineprotected

Returns if entity can be removed from its current location.

Definition at line 912 of file Inventory.c.

913 {
917
918 return false;
919 }
static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/....
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location

References GetCurrentInventoryLocation(), and LocationCanRemoveEntity().

◆ CanRemoveEntityInCargo()

proto native bool GameInventory::CanRemoveEntityInCargo ( notnull EntityAI e)
protected

◆ CanRemoveEntityInCargoEx()

proto native bool GameInventory::CanRemoveEntityInCargoEx ( notnull EntityAI e,
int idx,
int row,
int col )
protected

◆ CanSwapEntities()

GameInventory::CanSwapEntities ( notnull EntityAI item1,
notnull EntityAI item2 )
staticprotected

test if ordinary swap can be performed.

Ordinary in the sense that the two items has equal sizes and can be swapped without additional space.

Parameters
[in]item1first item
[in]item2second item
Returns
true if can be swapped

Referenced by CanSwapEntitiesEx().

◆ CanSwapEntitiesEx()

static bool GameInventory::CanSwapEntitiesEx ( notnull EntityAI item1,
notnull EntityAI item2 )
inlinestaticprotected

Definition at line 610 of file Inventory.c.

611 {
612 int slot;
615
616 item2.GetInventory().GetCurrentInventoryLocation(il2);
617 slot = il2.GetSlot();
618
619 if (item1.GetQuantity() > item1.GetTargetQuantityMax(slot))
620 return false;
621
622
623 item1.GetInventory().GetCurrentInventoryLocation(il1);
624 slot = il1.GetSlot();
625
626 if (item2.GetQuantity() > item2.GetTargetQuantityMax(slot))
627 return false;
628
629 if (!item1.CanSwapEntities(item2, il2, il1) || !item2.CanSwapEntities(item1, il1, il2))
630 return false;
631
632 return CanSwapEntities(item1, item2);
633 }
static proto native bool CanSwapEntities(notnull EntityAI item1, notnull EntityAI item2)
test if ordinary swap can be performed.

References CanSwapEntities().

Referenced by WeaponManager::CanSwapMagazine(), LayoutHolder::CanSwapOrTakeToHandsEx(), AttachmentCategoriesRow::Combine(), PlayerContainer::DraggingOver(), HandsContainer::DraggingOverHeader(), AttachmentCategoriesRow::DraggingOverHeader(), ClosableContainer::DraggingOverHeader(), VicinityContainer::DraggingOverIcon(), ItemManager::GetChosenCombinationFlag(), HandsContainer::GetCombinationFlags(), InventoryGridController::GetQuickbarItemColor(), HandGuardBase::GuardCondition(), PlayerContainer::OnDropReceivedFromGhostArea(), AttachmentCategoriesRow::OnDropReceivedFromHeader(), VicinityContainer::OnDropReceivedFromIcon(), ManBase::OnQuickBarSingleUse(), WeaponManager::PrepareInventoryLocationForMagazineSwap(), Attachments::Select(), Container::Select(), HandsPreview::Select(), AttachmentCategoriesRow::Select(), PlayerContainer::Select(), VicinitySlotsContainer::Select(), ZombieContainer::Select(), EntityAI::SwapEntitiesImpl(), HumanInventory::SwappingToPreviousLocation(), HandsContainer::TakeAsAttachment(), and ClosableContainer::TakeAsAttachment().

◆ CanUnlockInventoryWithKey()

proto native bool GameInventory::CanUnlockInventoryWithKey ( notnull EntityAI key)
protected

◆ CheckDropRequest()

static proto native bool GameInventory::CheckDropRequest ( notnull Man requestingPlayer,
notnull InventoryLocation src,
float radius )
staticprotected

◆ CheckManipulatedObjectsDistances()

static proto native bool GameInventory::CheckManipulatedObjectsDistances ( notnull EntityAI e0,
notnull EntityAI e1,
float radius )
staticprotected

◆ CheckMoveToDstRequest()

static proto native bool GameInventory::CheckMoveToDstRequest ( notnull Man requestingPlayer,
notnull InventoryLocation src,
notnull InventoryLocation dst,
float radius )
staticprotected

◆ CheckRequestSrc()

static proto native bool GameInventory::CheckRequestSrc ( notnull Man requestingPlayer,
notnull InventoryLocation src,
float radius )
staticprotected

◆ CheckSwapItemsRequest()

static proto native bool GameInventory::CheckSwapItemsRequest ( notnull Man requestingPlayer,
notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2,
float radius )
staticprotected

◆ CheckTakeItemRequest()

static proto native bool GameInventory::CheckTakeItemRequest ( notnull Man requestingPlayer,
notnull InventoryLocation src,
notnull InventoryLocation dst,
float radius )
staticprotected

◆ ClearInventoryReservation()

static proto native bool GameInventory::ClearInventoryReservation ( EntityAI item,
InventoryLocation dst )
staticprotected

◆ ClearInventoryReservationEx()

bool GameInventory::ClearInventoryReservationEx ( EntityAI item,
InventoryLocation dst )
inlineprotected

Definition at line 737 of file Inventory.c.

738 {
739 if (GetGame().IsMultiplayer() && GetGame().IsServer())
740 return true;
741
743#ifdef DEVELOPER
745 {
746 DayZPlayer player = GetGame().GetPlayer();
747 if (player)
748 {
749 if (item)
750 Debug.InventoryMoveLog("Reservation cleared result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "ClearInventoryReservation", player.ToString());
751 else
752 Debug.InventoryMoveLog("Reservation cleared result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "ClearInventoryReservation", player.ToString());
753 }
754 }
755#endif
756 return ret_val;
757 }
void ClearInventoryReservation()

References ClearInventoryReservation(), InventoryLocation::DumpToStringNullSafe(), GetGame(), Debug::InventoryMoveLog(), and LogManager::IsInventoryReservationLogEnable().

◆ CountInventory()

GameInventory::CountInventory ( )
protected

almost identical to EnumerateInventory except it does not return items

Returns
number of items

◆ CreateAttachment()

GameInventory::CreateAttachment ( string typeName)
protected

Create Entity of specified type as attachment of entity.

◆ CreateAttachmentEx()

GameInventory::CreateAttachmentEx ( string typeName,
int slotId )
protected

Create Entity of specified type as attachment of entity.

Parameters
typeNametype to create
slotIdthe slot to be created in

◆ CreateEntityInCargo()

proto native EntityAI GameInventory::CreateEntityInCargo ( string typeName)
protected

Create Entity of specified type in cargo of entity.

◆ CreateEntityInCargoEx()

proto native EntityAI GameInventory::CreateEntityInCargoEx ( string typeName,
int idx,
int row,
int col,
bool flip )
protected

Create Entity of specified type in cargo of entity at coordinates (row, col)

Parameters
typeNametype to create
rowthe row of cargo to be created at
colthe column of cargo to be created at

◆ CreateInInventory()

GameInventory::CreateInInventory ( string type)
inlineprotected

creates entity somewhere in inventory

Parameters
[in]typeitem type to be placed in inventory
Returns
created entity or null

Definition at line 849 of file Inventory.c.

850 {
853 {
854 switch (loc.GetType())
855 {
856 case InventoryLocationType.ATTACHMENT:
857 return loc.GetParent().GetInventory().CreateAttachmentEx(type, loc.GetSlot());
858 case InventoryLocationType.CARGO:
859 return loc.GetParent().GetInventory().CreateEntityInCargoEx(type, loc.GetIdx(), loc.GetRow(), loc.GetCol(), loc.GetFlip());
860 default:
861 Error("CreateInInventory: unknown location for item");
862 break;
863 }
864 }
865
866 return null;
867 }
InventoryLocationType
types of Inventory Location
proto native bool FindFirstFreeLocationForNewEntity(string item_type, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFirstFreeLocationForNewEntity.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), and FindFirstFreeLocationForNewEntity().

◆ DropEntity()

bool GameInventory::DropEntity ( InventoryMode mode,
EntityAI owner,
notnull EntityAI item )
inlineprotected

Definition at line 1221 of file Inventory.c.

1222 {
1223 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1225 if (item.GetInventory().GetCurrentInventoryLocation(src))
1226 {
1229 {
1231 return false;
1232 }
1233
1234 return TakeToDst(mode, src, dst);
1235 }
1236
1237 Error("DropEntity - No inventory location");
1238 return false;
1239 }
void inventoryDebugPrint(string s)
Definition Debug.c:19
InventoryCommandType
Definition Inventory.c:3
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
InventoryValidationReason
Definition Inventory.c:37
void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
Definition Inventory.c:1212
bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
move src to dst
Definition Inventory.c:1030
static bool IsInventoryMoveLogEnable()
Definition Debug.c:729

References Error(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), OnInventoryFailure(), SetGroundPosByOwner(), and TakeToDst().

◆ DropEntityInBounds()

bool GameInventory::DropEntityInBounds ( InventoryMode mode,
EntityAI owner,
notnull EntityAI item,
vector halfExtents,
float angle,
float cosAngle,
float sinAngle )
inlineprotected

Definition at line 1283 of file Inventory.c.

1284 {
1285 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1286
1288 if (item.GetInventory().GetCurrentInventoryLocation(src))
1289 {
1291
1293
1294 return TakeToDst(mode, src, dst);
1295 }
1296
1297 Error("DropEntityInBounds - No inventory location");
1298 return false;
1299 }
static void SetGroundPosByOwnerBounds(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
Definition Inventory.c:1264

References Error(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), SetGroundPosByOwnerBounds(), and TakeToDst().

◆ DropEntityWithTransform()

bool GameInventory::DropEntityWithTransform ( InventoryMode mode,
EntityAI owner,
notnull EntityAI item,
vector transform[4] )
inlineprotected

Definition at line 1248 of file Inventory.c.

1249 {
1250 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1252 if (item.GetInventory().GetCurrentInventoryLocation(src))
1253 {
1256
1257 return TakeToDst(mode, src, dst);
1258 }
1259
1260 Error("DropEntityWithTransform - No inventory location");
1261 return false;
1262 }
static bool SetGroundPosByTransform(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
Definition Inventory.c:1241

References Error(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), SetGroundPosByTransform(), and TakeToDst().

◆ EEDelete()

void GameInventory::EEDelete ( EntityAI parent)
inlineprotected

Definition at line 835 of file Inventory.c.

836 {
838 Man player = item.GetHierarchyRootPlayer();
839 if (player)
840 player.GetInventory().ClearInventoryReservationEx(item, null);
841 }
proto native EntityAI GetInventoryOwner()
Engine native functions.

References GetInventoryOwner().

◆ EEInit()

void GameInventory::EEInit ( )
inlineprotected

Definition at line 818 of file Inventory.c.

819 {
822 {
823 if (src.GetType() == InventoryLocationType.HANDS)
824 {
825 Man man = Man.Cast(src.GetParent());
826 if (man)
827 {
828 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("Inventory::EEInit - Man=" + man + " item=" + this);
829 man.GetHumanInventory().OnEntityInHandsCreated(src);
830 }
831 }
832 }
833 }

References GetCurrentInventoryLocation(), inventoryDebugPrint(), and LogManager::IsInventoryMoveLogEnable().

◆ EnumerateInventory()

GameInventory::EnumerateInventory ( InventoryTraversalType tt,
out array< EntityAI > items )
protected

enumerate inventory using traversal type and filling items array

Parameters
[in]ttused traversal type
[out]itemsitems in inventory (in order determined by traversal)
Returns
true if found any, false otherwise

◆ ExtendInventoryReservation()

static proto native bool GameInventory::ExtendInventoryReservation ( EntityAI item,
InventoryLocation dst,
int timeout_ms )
staticprotected

◆ ExtendInventoryReservationEx()

bool GameInventory::ExtendInventoryReservationEx ( EntityAI item,
InventoryLocation dst,
int timeout_ms )
inlineprotected

Definition at line 714 of file Inventory.c.

715 {
716 if (GetGame().IsMultiplayer() && GetGame().IsServer())
717 return true;
718
720#ifdef DEVELOPER
722 {
723 DayZPlayer player = GetGame().GetPlayer();
724 if (player)
725 {
726 if (item)
727 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "ExtendInventoryReservation", player.ToString());
728 else
729 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "ExtendInventoryReservation", player.ToString());
730 }
731 }
732#endif
733 return ret_val;
734 }
static proto native bool ExtendInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)

References InventoryLocation::DumpToStringNullSafe(), ExtendInventoryReservation(), GetGame(), Debug::InventoryMoveLog(), and LogManager::IsInventoryReservationLogEnable().

◆ FindAttachment()

proto native EntityAI GameInventory::FindAttachment ( int slot)
protected

Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)

◆ FindAttachmentByName()

proto native EntityAI GameInventory::FindAttachmentByName ( string slotName)
protected

Returns attached entity in slot (you can use EntityAI.GetActionComponentName to get slot id)

◆ FindFirstFreeLocationForNewEntity()

proto native bool GameInventory::FindFirstFreeLocationForNewEntity ( string item_type,
FindInventoryLocationType flags,
out notnull InventoryLocation loc )
protected

FindFirstFreeLocationForNewEntity.

Parameters
[in]item_typeitem type that would be placed in inventory
[out]locthe InventoryLocation the item can be placed to
Returns
true if found any, false otherwise

Referenced by CreateInInventory().

◆ FindFreeLocationFor()

proto native bool GameInventory::FindFreeLocationFor ( notnull EntityAI item,
FindInventoryLocationType flags,
out notnull InventoryLocation loc )
protected

FindFreeLocationFor.

Parameters
[in]itemitem that would be placed in inventory
[out]locthe InventoryLocation the item can be placed to
Returns
true if found any, false otherwise

Referenced by AddEntityToInventory(), CanAddEntityInto(), CanAddEntityToInventory(), HumanInventory::TakeEntityToInventory(), and TakeEntityToInventory().

◆ FindFreeLocationForEx()

proto native bool GameInventory::FindFreeLocationForEx ( notnull EntityAI item,
FindInventoryLocationType flags,
notnull InventoryLocation exclude,
out notnull InventoryLocation loc )
protected

FindFreeLocationForEx.

Parameters
[in]itemitem that would be placed in inventory
[out]locthe InventoryLocation the item can be placed to
Returns
true if found any, false otherwise

◆ FindFreeLocationsFor()

GameInventory::FindFreeLocationsFor ( notnull EntityAI item,
FindInventoryLocationType flags,
out notnull array< ref InventoryLocation > locs )
protected

searches inventory for suitable location for @item

Parameters
[in]itemitem that would be placed in inventory
[in]flagsflags affecting selection (
See also
FindInventoryLocation )
Parameters
[out]locsarray of InventoryLocations the item can be placed to
Returns
number of suitable inventory locations

Example:

Entity bino = GetGame().CreateObject("Binoculars", "3312 0 854");
{
array<ref InventoryLocation> a = new array<ref InventoryLocation>; // 1) allocate memory for array
for (int i = 0; i < 10; ++i)
{
a.Insert(new InventoryLocation); // 2) pre-allocate inventorylocations from script. engine only fills them in, engine does not allocate memory to avoid mixing.
}
int sz = player.FindFreeLocationsFor(bino, FindInventoryLocationType.ANY_CARGO | FindInventoryLocationType.ATTACHMENT, a); // 3) ask engine to fill the locations
if (sz > 0)
{
bino2.GetCurrentInventoryLocation(src); // 5) get current location
InventoryLocation dst = a[0]; // 6) get first (this is only example)
... use src and dst
}
}
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Camera.c:2
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

◆ FindPlaceholderForSlot()

proto native EntityAI GameInventory::FindPlaceholderForSlot ( int slot)
protected

Returns placeholder entity for slot (naked arms, legs etc)

◆ FlipCargo()

proto native void GameInventory::FlipCargo ( )
protected

◆ ForceSwapEntities()

bool GameInventory::ForceSwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2,
notnull InventoryLocation item2_dst )
inlineprotected

Definition at line 1207 of file Inventory.c.

1208 {
1209 return false;
1210 }

◆ GetAnyInventoryReservationCount()

proto native int GameInventory::GetAnyInventoryReservationCount ( )
protected

◆ GetAttachmentFromIndex()

GameInventory::GetAttachmentFromIndex ( int index)
protected
Returns
attached entity by attachment index @NOTE: index is not slot! for getting attachment by slot use FindAttachment

◆ GetAttachmentSlotId()

GameInventory::GetAttachmentSlotId ( int index)
protected
Parameters
indexindex of the slot for attachment (
See also
GetAttachmentSlotsCount)
Returns
slot for attachment

Referenced by HasAttachmentSlot().

◆ GetAttachmentSlotsCount()

GameInventory::GetAttachmentSlotsCount ( )
protected
Returns
number of slots for attachments

Referenced by HasAttachmentSlot().

◆ GetCargo()

proto native CargoBase GameInventory::GetCargo ( )
protected

cargo

◆ GetCargoFromIndex()

proto native CargoBase GameInventory::GetCargoFromIndex ( int index)
protected

◆ GetCurrentAttachmentSlotInfo()

bool GameInventory::GetCurrentAttachmentSlotInfo ( out int slot_id,
out string slot_name )
inlineprotected

Returns true if the item is currently attached and outputs attachment slot id and name.

Definition at line 436 of file Inventory.c.

437 {
439 slot_name = "";
442 if (lcn.GetType() == InventoryLocationType.ATTACHMENT)
443 {
444 slot_id = lcn.GetSlot();
446 return true;
447 }
448 return false;
449 }
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
const int INVALID
Invalid slot (-1)

References GetCurrentInventoryLocation(), InventorySlots::GetSlotName(), and InventorySlots::INVALID.

◆ GetCurrentInventoryLocation()

GameInventory::GetCurrentInventoryLocation ( out notnull InventoryLocation loc)
protected

returns information about current item location

Parameters
[out]loccurrent InventoryLocation
Returns
true if current location retrieved (and is valid)

Referenced by CanRemoveEntity(), EEInit(), GetCurrentAttachmentSlotInfo(), IsAttachment(), and IsInCargo().

◆ GetFlipCargo()

proto native bool GameInventory::GetFlipCargo ( )
protected

◆ GetInventoryCheckContext()

static int GameInventory::GetInventoryCheckContext ( )
inlinestaticprotected

Definition at line 373 of file Inventory.c.

374 {
376 }
static int m_inventory_check_context
Definition Inventory.c:80

References m_inventory_check_context.

Referenced by Container_Base::CanReceiveItemIntoCargo().

◆ GetInventoryOwner()

◆ GetInventoryReservationCount()

static proto native bool GameInventory::GetInventoryReservationCount ( EntityAI item,
InventoryLocation dst )
staticprotected

◆ GetScriptLockCount()

proto native int GameInventory::GetScriptLockCount ( )
protected

◆ GetSlotId()

GameInventory::GetSlotId ( int index)
protected

attachments

Parameters
indexindex into array of configured slots (
See also
GetSlotIdCount)
Returns
slot where this item belongs

◆ GetSlotIdCount()

GameInventory::GetSlotIdCount ( )
protected
Returns
number of slots this item can belong to

◆ GetSlotLock()

proto native bool GameInventory::GetSlotLock ( int slot)
protected

◆ HasAttachment()

GameInventory::HasAttachment ( notnull EntityAI e)
protected

brief Returns True if entity is attached to this

◆ HasAttachmentEx()

GameInventory::HasAttachmentEx ( notnull EntityAI e,
int slot )
protected

brief Returns True if entity is attached to this in slot

◆ HasAttachmentSlot()

GameInventory::HasAttachmentSlot ( int slotId)
inlineprotected
Returns
true if this entity has attachments slot with id=slotId

Definition at line 186 of file Inventory.c.

187 {
189 for (int i = 0; i < count; i++)
190 {
192 return true;
193 }
194 return false;
195 }
proto native int GetAttachmentSlotId(int index)
proto native int GetAttachmentSlotsCount()

References GetAttachmentSlotId(), and GetAttachmentSlotsCount().

◆ HasEntityInCargo()

proto native bool GameInventory::HasEntityInCargo ( notnull EntityAI e)
protected

◆ HasEntityInCargoEx()

proto native bool GameInventory::HasEntityInCargoEx ( notnull EntityAI e,
int idx,
int row,
int col )
protected

◆ HasEntityInInventory()

GameInventory::HasEntityInInventory ( notnull EntityAI item)
protected

query inventory if item is somewhere

All available inventory locations (hands, cargo, attachments, proxycargo, ...) are traversed recursively from root to leafs.

Parameters
[in]itemitem to be found in inventory
Returns
true if found, false otherwise

◆ HasInventoryReservation()

static proto native bool GameInventory::HasInventoryReservation ( EntityAI item,
InventoryLocation dst )
staticprotected

Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY, FindInventoryReservationMode.LEGACY)

Referenced by HandStateEquipped::OnEntry().

◆ HasInventoryReservationCanAdd()

static proto native bool GameInventory::HasInventoryReservationCanAdd ( EntityAI item,
InventoryLocation dst )
staticprotected

Internally: !HasInventoryReservationEx(item, dst, FindInventoryReservationMode.ITEM, FindInventoryReservationMode.DST)

◆ HasInventoryReservationEx()

static proto native bool GameInventory::HasInventoryReservationEx ( EntityAI item,
InventoryLocation dst,
FindInventoryReservationMode itemMode,
FindInventoryReservationMode parentMode )
staticprotected

itemMode will iterate over item reservations, parentMode will iterate over parent reservations

◆ HasInventorySlot()

GameInventory::HasInventorySlot ( int slotId)
protected
Returns
true if this entity has inventory slot with id=slotId

◆ HasKeys()

proto native bool GameInventory::HasKeys ( )
protected

◆ Init()

GameInventory::Init ( )
inlineprotected

script functions

called by engine right after creation of entity

Definition at line 804 of file Inventory.c.

805 {
806 GetInventoryOwner().OnInventoryInit();
807 }

References GetInventoryOwner().

◆ IsAttachment()

bool GameInventory::IsAttachment ( )
inlineprotected

Returns true if this Inventory owner is an attachment of something.

Definition at line 406 of file Inventory.c.

407 {
410 if (lcn.GetType() == InventoryLocationType.ATTACHMENT)
411 return true;
412
413 return false;
414 }

References GetCurrentInventoryLocation().

◆ IsCargoInHiearchy()

bool GameInventory::IsCargoInHiearchy ( )
inlineprotected

Returns true if inventory owner or his hiearchy parents are in cargo.

Definition at line 417 of file Inventory.c.

418 {
421 while (ent)
422 {
423 if (ent.GetInventory().GetCurrentInventoryLocation(lcn) && lcn.IsValid())
424 {
425 if (lcn.GetType() == InventoryLocationType.CARGO || lcn.GetType() == InventoryLocationType.PROXYCARGO)
426 return true;
427 }
428
429 ent = ent.GetHierarchyParent();
430 }
431
432 return false;
433 }

References GetInventoryOwner().

◆ IsInCargo()

bool GameInventory::IsInCargo ( )
inlineprotected

Returns true if this Inventory owner is in cargo of something.

Definition at line 395 of file Inventory.c.

396 {
399 if (lcn.GetType() == InventoryLocationType.CARGO)
400 return true;
401
402 return false;
403 }

References GetCurrentInventoryLocation().

◆ IsInventoryLocked()

proto native bool GameInventory::IsInventoryLocked ( )
protected

◆ IsInventoryLockedForLockType()

proto native bool GameInventory::IsInventoryLockedForLockType ( int lockType)
protected

◆ IsInventoryUnlocked()

proto native bool GameInventory::IsInventoryUnlocked ( )
protected

◆ IsPlaceholderEntity()

proto native bool GameInventory::IsPlaceholderEntity ( notnull Object e)
protected

◆ LocalDestroyEntity()

bool GameInventory::LocalDestroyEntity ( notnull EntityAI item)
inlineprotected

Definition at line 1301 of file Inventory.c.

1302 {
1303 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::LocalDestroyEntity inv item=" + item);
1305 if (item.GetInventory().GetCurrentInventoryLocation(src))
1306 {
1307 if (src.GetType() == InventoryLocationType.HANDS)
1308 Error("[inv] Source location == HANDS, player has to handle this");
1309
1310 GetGame().ObjectDelete(src.GetItem());
1311 return true;
1312 }
1313
1314 Error("LocalDestroyEntity: No inventory location");
1315 return false;
1316 }

References Error(), GetGame(), inventoryDebugPrint(), and LogManager::IsInventoryMoveLogEnable().

◆ LocationAddEntity()

GameInventory::LocationAddEntity ( notnull InventoryLocation inv_loc)
staticprotected

adds item to inventory location

Returns
true if success, false otherwise

Referenced by AddEntityToInventory(), and ReplaceItemWithNewLambdaBase::UndoRemoveOldItemFromLocation().

◆ LocationCanAddEntity()

GameInventory::LocationCanAddEntity ( notnull InventoryLocation inv_loc)
staticprotected

queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/...

query the entity at the specific inventory location

Returns
true if can be added, false otherwise
entity at the location, null otherwise

Referenced by LocationCanAddEntityEx(), and TransferInventory().

◆ LocationCanAddEntityEx()

static bool GameInventory::LocationCanAddEntityEx ( notnull InventoryLocation inv_loc)
inlinestaticprotected

Definition at line 348 of file Inventory.c.

349 {
351 }
static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....

References LocationCanAddEntity().

◆ LocationCanMoveEntity()

GameInventory::LocationCanMoveEntity ( notnull InventoryLocation src,
notnull InventoryLocation dst )
staticprotected

queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthand for CanRemove + CanAdd query

Returns
true if can be moved, false otherwise

Referenced by HandEventBase::CanPerformEvent(), HandEventBase::CanPerformEventEx(), HandGuardBase::GuardCondition(), LocationCanMoveEntitySyncCheck(), WeaponStateBase::OnAbort(), OnAbort(), HandStateBase::OnEntry(), HandStartAction::OnEntry(), WeaponStateBase::OnExit(), and ValidateSyncMove().

◆ LocationCanMoveEntitySyncCheck()

static bool GameInventory::LocationCanMoveEntitySyncCheck ( notnull InventoryLocation src,
notnull InventoryLocation dst )
inlinestaticprotected

Definition at line 378 of file Inventory.c.

379 {
383 return result;
384
385 }
InventoryCheckContext
Definition Inventory.c:58
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...

References LocationCanMoveEntity(), and m_inventory_check_context.

Referenced by ValidateSyncMove().

◆ LocationCanRemoveEntity()

GameInventory::LocationCanRemoveEntity ( notnull InventoryLocation inv_loc)
staticprotected

queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/...

Returns
true if can be added, false otherwise

Referenced by ReplaceItemWithNewLambdaBase::CanExecuteLambda(), CanRemoveEntity(), and ActionDigInStash::OnFinishProgressServer().

◆ LocationCreateEntity()

GameInventory::LocationCreateEntity ( notnull InventoryLocation inv_loc,
string type,
int iSetupFlags,
int iRotation )
staticprotected

creates new item directly at location

Parameters
[in]typeitem type to be placed in inventory
Returns
created entity, null otherwise

Referenced by ReplaceItemWithNewLambdaBase::CreateNewEntity(), SpawnEntity(), InventoryItem::SplitIntoStackMaxToInventoryLocationEx(), InventoryItem::SplitItemToInventoryLocation(), ThrowEntityFromInventory(), and ActionUncoverHeadBase::UncoverHead().

◆ LocationCreateLocalEntity()

GameInventory::LocationCreateLocalEntity ( notnull InventoryLocation inv_loc,
string type,
int iSetupFlags,
int iRotation )
staticprotected

creates new local item directly at location @NOTE: the item is created localy, i.e. it's not registered to network

Parameters
[in]typeitem type to be placed in inventory
Returns
created entity, null otherwise

Referenced by ReplaceItemWithNewLambdaBase::CreateNewEntity().

◆ LocationGetEntity()

static proto native EntityAI GameInventory::LocationGetEntity ( notnull InventoryLocation inv_loc)
staticprotected

◆ LocationMoveEntity()

GameInventory::LocationMoveEntity ( notnull InventoryLocation src_loc,
notnull InventoryLocation dst_loc )
staticprotected

removes item from current inventory location and adds it to destination

Returns
true if success, false otherwise

◆ LocationRemoveEntity()

GameInventory::LocationRemoveEntity ( notnull InventoryLocation inv_loc)
staticprotected

removes item from inventory location

Returns
true if success, false otherwise

Referenced by ReplaceItemWithNewLambdaBase::RemoveOldItemFromLocation().

◆ LocationSwap()

GameInventory::LocationSwap ( notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2 )
staticprotected

swaps two entities

Returns
true if success, false otherwise

Referenced by HandActionBase::Action(), HandStartAction::OnEntry(), and OnServerInventoryCommandStatic().

◆ LocationSyncMoveEntity()

GameInventory::LocationSyncMoveEntity ( notnull InventoryLocation src_loc,
notnull InventoryLocation dst_loc )
staticprotected

synchronously removes item from current inventory location and adds it to destination no anims involved

Returns
true if success, false otherwise

Referenced by HandActionBase::Action(), HandleDropMagazine(), WeaponStateBase::OnAbort(), OnAbort(), HandStateBase::OnEntry(), HandStartAction::OnEntry(), WeaponStateBase::OnEntry(), WeaponStateBase::OnExit(), OnServerInventoryCommandStatic(), and TakeToDst().

◆ LocationTestAddEntity()

GameInventory::LocationTestAddEntity ( notnull InventoryLocation inv_loc,
bool do_resevation_check,
bool do_item_check,
bool do_lock_check,
bool do_occupancy_test,
bool do_script_check,
bool do_script_load_check )
staticprotected

test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/...

Returns
true if can be added, false otherwise

Referenced by HandGuardBase::GuardCondition().

◆ LockInventory()

proto native void GameInventory::LockInventory ( int lockType)
protected

◆ LockInventoryWithKey()

proto native void GameInventory::LockInventoryWithKey ( notnull EntityAI key)
protected

◆ MakeDstForSwap()

static bool GameInventory::MakeDstForSwap ( notnull InventoryLocation src1,
notnull InventoryLocation src2,
out InventoryLocation dst1,
out InventoryLocation dst2 )
inlinestaticprotected

helper function for swap

Definition at line 1147 of file Inventory.c.

1148 {
1149 if (dst1 == null)
1150 dst1 = new InventoryLocation();
1151
1152 dst1.Copy(src1);
1153 dst1.CopyLocationFrom(src2, false);
1154 dst1.SetFlip(src1.GetItem().GetInventory().GetFlipCargo()); // update flip flag from inventory item
1155
1156 if (dst2 == null)
1157 dst2 = new InventoryLocation();
1158
1159 dst2.Copy(src2);
1160 dst2.CopyLocationFrom(src1, false);
1161 dst2.SetFlip(src2.GetItem().GetInventory().GetFlipCargo()); // update flip flag from inventory item
1162 return true;
1163 }

Referenced by MakeSrcAndDstForSwap().

◆ MakeSrcAndDstForForceSwap()

static bool GameInventory::MakeSrcAndDstForForceSwap ( notnull EntityAI item1,
notnull EntityAI item2,
out InventoryLocation src1,
out InventoryLocation src2,
out InventoryLocation dst1,
notnull InventoryLocation dst2 )
inlinestaticprotected

helper function for ForceSwap

Definition at line 1178 of file Inventory.c.

1179 {
1180 if (src1 == null)
1181 src1 = new InventoryLocation();
1182 if (src2 == null)
1183 src2 = new InventoryLocation();
1184
1185 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
1186 {
1187 // src1 -> dst_of(src2)
1188 if (dst1 == null)
1189 dst1 = new InventoryLocation();
1190
1191 dst1.Copy(src1);
1192 dst1.CopyLocationFrom(src2, false);
1193 dst1.SetFlip(dst1.GetItem().GetInventory().GetFlipCargo());
1194
1195 // src2 -> dst2 from user
1196 return true;
1197 }
1198
1199 return false;
1200 }

Referenced by HumanInventory::ForceSwapEntities(), and ForceSwapEntities().

◆ MakeSrcAndDstForSwap()

static bool GameInventory::MakeSrcAndDstForSwap ( notnull EntityAI item1,
notnull EntityAI item2,
out InventoryLocation src1,
out InventoryLocation src2,
out InventoryLocation dst1,
out InventoryLocation dst2 )
inlinestaticprotected

helper function for swap

Definition at line 1166 of file Inventory.c.

1167 {
1168 if (src1 == null)
1169 src1 = new InventoryLocation();
1170 if (src2 == null)
1171 src2 = new InventoryLocation();
1172 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
1173 return MakeDstForSwap(src1, src2, dst1, dst2);
1174 return false;
1175 }
static bool MakeDstForSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
Definition Inventory.c:1147

References MakeDstForSwap().

Referenced by HandleSwapEntities(), HumanInventory::SwapEntities(), and SwapEntities().

◆ OnAfterStoreLoad()

void GameInventory::OnAfterStoreLoad ( )
protected

◆ OnInputUserDataProcess()

bool GameInventory::OnInputUserDataProcess ( ParamsReadContext ctx)
protected

synchronization

◆ OnInventoryFailure()

void GameInventory::OnInventoryFailure ( InventoryCommandType type,
InventoryValidationReason reason,
InventoryLocation src,
InventoryLocation dst )
protected

Referenced by DropEntity().

◆ OnInventoryJunctureFailureFromServer()

void GameInventory::OnInventoryJunctureFailureFromServer ( ParamsReadContext ctx)
protected

◆ OnInventoryJunctureFromServer()

bool GameInventory::OnInventoryJunctureFromServer ( ParamsReadContext ctx)
protected

◆ OnInventoryJunctureRepairFromServer()

bool GameInventory::OnInventoryJunctureRepairFromServer ( ParamsReadContext ctx)
protected

◆ OnServerInventoryCommand()

void GameInventory::OnServerInventoryCommand ( ParamsReadContext ctx)
protected

◆ OnServerInventoryCommandStatic()

static void GameInventory::OnServerInventoryCommandStatic ( ParamsReadContext ctx)
inlinestaticprotected

Definition at line 451 of file Inventory.c.

452 {
453 int tmp = -1;
454 ctx.Read(tmp);
455
456 int type = -1;
457 if (!ctx.Read(type))
458 return;
459
460 switch (type)
461 {
462 case InventoryCommandType.SYNC_MOVE:
463 {
466
467 src.ReadFromContext(ctx);
468 dst.ReadFromContext(ctx);
469 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms ServerInventoryCommand cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
470
471 if (!src.GetItem() || !dst.GetItem())
472 {
473 LogError("[syncinv] ServerInventoryCommand (cmd=SYNC_MOVE) dropped, item not in bubble");
474 break; // not in bubble
475 }
476
478 break;
479 }
480
481 case InventoryCommandType.HAND_EVENT:
482 {
483 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
484 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms ServerInventoryCommand cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
485
486 if (!e.GetSrcEntity())
487 {
488 Error("[syncinv] ServerInventoryCommand (cmd=HAND_EVENT) dropped, item not in bubble");
489 break; // not in bubble
490 }
491 e.m_Player.GetHumanInventory().ProcessHandEvent(e);
492 break;
493 }
494
495 case InventoryCommandType.FORCESWAP:
496 case InventoryCommandType.SWAP:
497 {
502 src1.ReadFromContext(ctx);
503 src2.ReadFromContext(ctx);
504 dst1.ReadFromContext(ctx);
505 dst2.ReadFromContext(ctx);
506
507 if (src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid())
508 {
510
512 }
513 else
514 Error("ServerInventoryCommand - cannot swap, invalid location input: src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
515
516 break;
517 }
518 }
519 }
void syncDebugPrint(string s)
Definition Debug.c:1
void LogError(string message, LogTemplateID template_id=0)
Creates error log (optional) from LogTemplate which are registred.
float GetTime()
static proto native bool LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
swaps two entities
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
Abstracted event, not to be used, only inherited.
static bool IsSyncLogEnable()
Definition Debug.c:759

References InventoryLocation::DumpToStringNullSafe(), Error(), GetGame(), GetTime(), LogManager::IsSyncLogEnable(), LocationSwap(), LocationSyncMoveEntity(), LogError(), and syncDebugPrint().

◆ OnStoreLoad()

bool GameInventory::OnStoreLoad ( ParamsReadContext ctx,
int version )
inlineprotected

db load hooks

Definition at line 810 of file Inventory.c.

811 {
812 return true;
813 }

◆ OnStoreSave()

void GameInventory::OnStoreSave ( ParamsWriteContext ctx)
protected

db store hook

◆ PrepareDropEntityPos()

GameInventory::PrepareDropEntityPos ( EntityAI owner,
notnull EntityAI item,
out vector mat[4],
bool useValuesInMatrix = false,
int conflictCheckDepth = -1 )
staticprotected

Finds a transformation for the item to be dropped to If the initial transforation overlaps with another conflicting entity (i.e. car) then the transform will be snapped to the nearest outer edge. If no valid snapping transformation could be found, then the output from 'PlaceOnSurface' is used.

Parameters
useValuesInMatrixIs ignored if transformation overlaps with possible conflicting entity. If no valid transform is found and this is false then the transform at the owner is used for 'PlaceOnSurface'
conflictCheckDepthIf -1 then no conflict depth check is performed, if 0 then it only checks to see if it conflicts but doesn't perform snapping
Returns
true if valid transformation found near owner

Referenced by DropEquipAndDestroyRootLambda::CopyOldPropertiesToNew(), HandleDropMagazine(), ManBase::PredictiveDropEntity(), SetGroundPosByOwner(), and SetGroundPosByTransform().

◆ ReplaceItemWithNew()

bool GameInventory::ReplaceItemWithNew ( InventoryMode mode,
ReplaceItemWithNewLambdaBase lambda )
inlineprotected

Definition at line 1318 of file Inventory.c.

1319 {
1321 if (lambda.m_OldItem.GetInventory().GetCurrentInventoryLocation(src))
1322 {
1323 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::ReplaceItemWithNew executing lambda=" + lambda + "on old_item=" + lambda.m_OldItem);
1324 lambda.Execute();
1325 return true;
1326 }
1327
1328 Error("[inv] I::ReplaceItemWithNew - no inventory location");
1329 return false;
1330 }

References Error(), inventoryDebugPrint(), and LogManager::IsInventoryMoveLogEnable().

◆ ResetFlipCargo()

proto native void GameInventory::ResetFlipCargo ( )
protected

◆ ServerHandEvent()

GameInventory::ServerHandEvent ( notnull Man player,
notnull EntityAI item,
ParamsWriteContext ctx )
staticprotected

hand event to clients

Returns
true if success, false otherwise

Referenced by InventoryInputUserData::SendServerHandEventViaInventoryCommand().

◆ ServerLocationMoveEntity()

GameInventory::ServerLocationMoveEntity ( notnull EntityAI item,
ParamsWriteContext ctx )
staticprotected

removes item from current inventory location and adds it to destination + sync via inventory command

Returns
true if success, false otherwise

◆ ServerLocationSwap()

GameInventory::ServerLocationSwap ( notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2,
ParamsWriteContext ctx )
staticprotected

swaps two entities

Returns
true if success, false otherwise

Referenced by InventoryInputUserData::SendServerSwap().

◆ ServerLocationSyncMoveEntity()

GameInventory::ServerLocationSyncMoveEntity ( Man player,
notnull EntityAI item,
ParamsWriteContext ctx )
staticprotected

synchronously removes item from current inventory location and adds it to destination + sync via inventory command no anims involved

Returns
true if success, false otherwise

Referenced by InventoryInputUserData::SendServerMove().

◆ SetFlipCargo()

proto native void GameInventory::SetFlipCargo ( bool flip)
protected

◆ SetGroundPosByOwner()

static bool GameInventory::SetGroundPosByOwner ( EntityAI owner,
notnull EntityAI item,
out InventoryLocation ground )
inlinestaticprotected

Definition at line 1212 of file Inventory.c.

1213 {
1214 vector m4[4];
1217 ground.SetGround(item, m4);
1218 return success;
1219 }
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
Finds a transformation for the item to be dropped to If the initial transforation overlaps with anoth...
const int INVENTORY_ENTITY_DROP_OVERLAP_DEPTH
Definition constants.c:908
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233

References GameConstants::INVENTORY_ENTITY_DROP_OVERLAP_DEPTH, Math3D::MatrixIdentity4(), and PrepareDropEntityPos().

Referenced by HandEventRemove::CanPerformEventEx(), HandEventRemove::CheckRequestEx(), DropEntity(), OnEntry(), ActionUnpackGift::OnFinishProgressServer(), and StaticConstructionMethods::SpawnConstructionMaterialPiles().

◆ SetGroundPosByOwnerBounds()

static void GameInventory::SetGroundPosByOwnerBounds ( EntityAI owner,
notnull EntityAI item,
out InventoryLocation ground,
vector halfExtents,
float angle,
float cosAngle,
float sinAngle )
inlinestaticprotected

Definition at line 1264 of file Inventory.c.

1265 {
1266 vector m4[4];
1267 owner.GetTransform(m4);
1268
1271
1272 float dist = randomPos[0] * m4[1][0] + randomPos[1] * m4[1][1] + randomPos[2] * m4[1][2];
1273
1274 m4[3][0] = m4[3][0] + randomPos[0];
1275 m4[3][1] = m4[3][1] - dist + halfExtents[1];
1276 m4[3][2] = m4[3][2] + randomPos[2];
1277
1278 item.PlaceOnSurfaceRotated(m4, Vector(m4[3][0], m4[3][1], m4[3][2]));
1279
1280 ground.SetGround(item, m4);
1281 }
Definition EnMath.c:7
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Definition EnConvert.c:478
static const vector Up
Definition EnConvert.c:107
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].

References Math::RandomFloat(), vector::RotateAroundZero(), vector::Up, and Vector().

Referenced by DropEntityInBounds().

◆ SetGroundPosByTransform()

static bool GameInventory::SetGroundPosByTransform ( EntityAI owner,
notnull EntityAI item,
out InventoryLocation ground,
vector transform[4] )
inlinestaticprotected

◆ SetSlotLock()

proto native bool GameInventory::SetSlotLock ( int slot,
bool locked )
protected

◆ SwapEntities()

bool GameInventory::SwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2 )
inlineprotected

Definition at line 1202 of file Inventory.c.

1203 {
1204 return false;
1205 }

◆ TakeEntityAsAttachment()

bool GameInventory::TakeEntityAsAttachment ( InventoryMode mode,
notnull EntityAI item )
inlineprotected

Definition at line 1134 of file Inventory.c.

1135 {
1136 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Att(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1138 }
bool TakeEntityToInventory(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
Put item anywhere into this entity (as attachment or into cargo, recursively)
Definition Inventory.c:986

References inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeEntityToInventory().

Referenced by EntityAI::TakeEntityAsAttachmentImpl().

◆ TakeEntityAsAttachmentEx()

bool GameInventory::TakeEntityAsAttachmentEx ( InventoryMode mode,
notnull EntityAI item,
int slot )
inlineprotected

Definition at line 1103 of file Inventory.c.

1104 {
1105 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " slot=" + slot);
1107 }
bool TakeEntityAsTargetAttachmentEx(InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
put item as attachment of target
Definition Inventory.c:1110

References GetInventoryOwner(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeEntityAsTargetAttachmentEx().

◆ TakeEntityAsTargetAttachment()

bool GameInventory::TakeEntityAsTargetAttachment ( InventoryMode mode,
notnull EntityAI target,
notnull EntityAI item )
inlineprotected

Definition at line 1140 of file Inventory.c.

1141 {
1142 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1144 }
bool TakeEntityToTargetInventory(InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
helper that finds location first, then moves the entity into it
Definition Inventory.c:1005

References inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeEntityToTargetInventory().

◆ TakeEntityAsTargetAttachmentEx()

bool GameInventory::TakeEntityAsTargetAttachmentEx ( InventoryMode mode,
notnull EntityAI target,
notnull EntityAI item,
int slot )
inlineprotected

put item as attachment of target

Definition at line 1110 of file Inventory.c.

1111 {
1112 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetAttEx(" + typename.EnumToString(InventoryMode, mode) + ") as ATT of target=" + target + " item=" + item + " slot=" + slot);
1114 if (item.GetInventory().GetCurrentInventoryLocation(src))
1115 {
1116
1117 EntityAI att = target.GetInventory().FindAttachment(slot);
1118 if (att)
1119 {
1120 att.CombineItemsClient(item, true);
1121 return true;
1122 }
1123 else
1124 {
1126 dst.SetAttachment(target, item, slot);
1127 return TakeToDst(mode, src, dst);
1128 }
1129 }
1130 Error("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Error - src has no inventory location");
1131 return false;
1132 }

References Error(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeToDst().

Referenced by TakeEntityAsAttachmentEx().

◆ TakeEntityToCargo()

GameInventory::TakeEntityToCargo ( InventoryMode mode,
notnull EntityAI item )
inlineprotected

moves item to cargo of this intentory

Parameters
[in]modeinventory mode
[in]itemitem to be put in this inventory as cargo

Definition at line 1054 of file Inventory.c.

1055 {
1056 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1058 }

References inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeEntityToInventory().

Referenced by EntityAI::TakeEntityToCargoImpl().

◆ TakeEntityToCargoEx()

GameInventory::TakeEntityToCargoEx ( InventoryMode mode,
notnull EntityAI item,
int idx,
int row,
int col )
inlineprotected

moves item on specific cargo location

Parameters
[in]modeinventory mode
[in]itemitem to be put in this inventory as cargo

Definition at line 1072 of file Inventory.c.

1073 {
1074 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " row=" + row + " col=" + col);
1076 if (item.GetInventory().GetCurrentInventoryLocation(src))
1077 {
1079 dst.SetCargo(GetInventoryOwner(), item, idx, row, col, item.GetInventory().GetFlipCargo());
1080
1081 return TakeToDst(mode, src, dst);
1082 }
1083 Error("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " row=" + row + " col=" + col + " Error - src has no inventory location");
1084 return false;
1085 }

References Error(), GetInventoryOwner(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeToDst().

◆ TakeEntityToInventory()

GameInventory::TakeEntityToInventory ( InventoryMode mode,
FindInventoryLocationType flags,
notnull EntityAI item )
inlineprotected

Put item anywhere into this entity (as attachment or into cargo, recursively)

Parameters
[in]modeinventory mode
[in]flagspreferred location,
See also
FindInventoryLocationType
Parameters
[in]itemitem to be taken in inventory
Returns
true on success

@NOTE: Predictive.* / Local.* functions: a) 'Predictive' means that the operation uses Client-Side Prediction, i.e. the action runs the same code on both, client AND server.

b) 'Local' operation executes from where it is run, i.e. the operation from client is NOT sent to server, and only client performs the inventory operation (TakeEntityTo.*) this behaviour is necessary when inventory operations are ALREADY synchronized by another means, like Actions. For example

See also
ActionTakeItemToHands that performs OnCompleteServer and OnCompleteClient with synchronization set to false in order to avoid duplicate synchronization.

Definition at line 986 of file Inventory.c.

987 {
988 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
989
991 if (item.GetInventory().GetCurrentInventoryLocation(src))
992 {
994 if (FindFreeLocationFor(item, flags, dst))
995 return TakeToDst(mode, src, dst);
996
997 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Warning - no room for item");
998 return false;
999 }
1000 Error("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Error - src has no inventory location");
1001 return false;
1002 }

References Error(), FindFreeLocationFor(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeToDst().

Referenced by TakeEntityAsAttachment(), and TakeEntityToCargo().

◆ TakeEntityToTargetCargo()

bool GameInventory::TakeEntityToTargetCargo ( InventoryMode mode,
notnull EntityAI target,
notnull EntityAI item )
inlineprotected

Put item into into cargo of another entity.

Definition at line 1061 of file Inventory.c.

1062 {
1063 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetCgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + target);
1065 }

References inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeEntityToTargetInventory().

◆ TakeEntityToTargetCargoEx()

bool GameInventory::TakeEntityToTargetCargoEx ( InventoryMode mode,
notnull CargoBase cargo,
notnull EntityAI item,
int row,
int col )
inlineprotected

Put item into into cargo on specific cargo location of another entity.

Definition at line 1088 of file Inventory.c.

1089 {
1090 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + cargo.GetCargoOwner() + " row=" + row + " col=" + col);
1092 if (item.GetInventory().GetCurrentInventoryLocation(src))
1093 {
1095 dst.SetCargoAuto(cargo, item, row, col, item.GetInventory().GetFlipCargo());
1096
1097 return TakeToDst(mode, src, dst);
1098 }
1099 Error("[inv] I::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + cargo.GetCargoOwner() + " row=" + row + " col=" + col);
1100 return false;
1101 }

References Error(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeToDst().

◆ TakeEntityToTargetInventory()

bool GameInventory::TakeEntityToTargetInventory ( InventoryMode mode,
notnull EntityAI target,
FindInventoryLocationType flags,
notnull EntityAI item )
inlineprotected

helper that finds location first, then moves the entity into it

Definition at line 1005 of file Inventory.c.

1006 {
1007 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1008
1010 if (item.GetInventory().GetCurrentInventoryLocation(src))
1011 {
1013
1014 if (target.GetInventory().FindFreeLocationFor(item, flags, dst))
1015 return TakeToDst(mode, src, dst);
1016
1017 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") target=" + target + " item=" + item + " Warning - no room for item in target");
1018 return false;
1019 }
1020 Error("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") target=" + target + " item=" + item + " Error - src has no inventory location");
1021 return false;
1022 }

References Error(), inventoryDebugPrint(), LogManager::IsInventoryMoveLogEnable(), and TakeToDst().

Referenced by TakeEntityAsTargetAttachment(), and TakeEntityToTargetCargo().

◆ TakeToDst()

GameInventory::TakeToDst ( InventoryMode mode,
notnull InventoryLocation src,
notnull InventoryLocation dst )
inlineprotected

move src to dst

Parameters
[in]modeinventory mode
[in]srcsource location of the item
[in]dstdestination location of the item

Definition at line 1030 of file Inventory.c.

1031 {
1032 bool ret;
1033 switch (mode)
1034 {
1035 case InventoryMode.SERVER:
1037 if (ret && dst.IsValid())
1039 return ret;
1040 case InventoryMode.LOCAL:
1042 return ret;
1043 default:
1044 return false;
1045 }
1046 return false;
1047 }
static void SendServerMove(Man player, int type, notnull InventoryLocation src, notnull InventoryLocation dst)

References LocationSyncMoveEntity(), and InventoryInputUserData::SendServerMove().

Referenced by DropEntity(), DropEntityInBounds(), DropEntityWithTransform(), TakeEntityAsTargetAttachmentEx(), TakeEntityToCargoEx(), TakeEntityToInventory(), TakeEntityToTargetCargoEx(), and TakeEntityToTargetInventory().

◆ TestAddEntityInCargoEx()

proto native bool GameInventory::TestAddEntityInCargoEx ( notnull EntityAI e,
int idx,
int row,
int col,
bool flip,
bool do_resevation_check,
bool do_item_check,
bool do_lock_check,
bool do_occupancy_test,
bool do_script_check,
bool do_script_load_check )
protected

◆ TestAddEntityInCargoExLoc()

proto native bool GameInventory::TestAddEntityInCargoExLoc ( notnull InventoryLocation loc,
bool do_resevation_check,
bool do_item_check,
bool do_lock_check,
bool do_occupancy_test,
bool do_script_check,
bool do_script_load_check )
protected

◆ TestDropEntityPos()

static proto native bool GameInventory::TestDropEntityPos ( EntityAI owner,
notnull EntityAI item,
out vector mat[4],
bool useValuesInMatrix = false,
int conflictCheckDepth = -1 )
staticprotected

◆ UnlockInventory()

proto native void GameInventory::UnlockInventory ( int lockType)
protected

◆ UnlockInventoryWithKey()

proto native void GameInventory::UnlockInventoryWithKey ( notnull EntityAI key)
protected

Member Data Documentation

◆ c_InventoryReservationTimeoutMS

◆ c_InventoryReservationTimeoutShortMS

◆ c_MaxItemDistanceRadius

const float GameInventory::c_MaxItemDistanceRadius = 2.5
protected

◆ m_inventory_check_context

int GameInventory::m_inventory_check_context = InventoryCheckContext.DEFAULT
staticprotected

Definition at line 80 of file Inventory.c.

Referenced by GetInventoryCheckContext(), and LocationCanMoveEntitySyncCheck().


The documentation for this class was generated from the following file: