77 else if (!
GetGame().IsMultiplayer())
80 eai.GetOnReleaseLock().Invoke(
eai);
89 else if (!
GetGame().IsMultiplayer())
97 item.GetOnReleaseLock().Invoke(
item);
142 if (
item &&
item.GetInventory() &&
item.GetInventory().GetCurrentInventoryLocation(
src))
144 switch (
src.GetType())
156 Error(
"No inventory location");
172 if (
item &&
item.GetInventory() &&
item.GetInventory().GetCurrentInventoryLocation(
src))
174 switch (
src.GetType())
188 Error(
"No inventory location");
211 r_il.GetParent().GetOnReleaseLock().Invoke(
item);
213 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(
item,
r_il.GetSlot());
244 if (
item.GetInventory().GetCurrentInventoryLocation(
src))
258 Error(
"HumanInventory::TakeEntityToInventory: No inventory location");
268 if (
item.GetInventory().GetCurrentInventoryLocation(
src))
270 switch (
src.GetType())
290 Error(
"HumanInventory::TakeEntityToCargoEx: No inventory location");
297 if (
item.GetInventory().GetCurrentInventoryLocation(
src))
299 switch (
src.GetType())
320 Error(
"HumanInventory::TakeEntityAsAttachmentEx: No inventory location");
330 switch (
src1.GetType())
349 switch (
src2.GetType())
364 Error(
"HumanInventory::SwapEntities: cannot create src1, src2, dst1, dst2");
377 switch (
src1.GetType())
382 e.ReserveInventory();
389 switch (
src2.GetType())
417 Error(
"HumanInventory::ForceSwapEntities: No inventory location");
424 if (
item.GetInventory().GetCurrentInventoryLocation(
src))
426 switch (
src.GetType())
443 Error(
"LocalDestroyEntity: No inventory location");
465 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl Item in hands, event=" +
e.DumpToString());
472 switch (
dst.GetType())
483 Error(
"HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl TODO");
487 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl src has to be hands");
492 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl no dst in event, event=" +
e.DumpToString());
502 switch (
src.GetType())
517 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl src has to be hands");
522 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl No item in hands, event=" +
e.DumpToString());
542 if (
item1.GetInventory().GetCurrentInventoryLocation(
src1) &&
item2.GetInventory().GetCurrentInventoryLocation(
src2))
544 if (
item1.m_OldLocation &&
item1.m_OldLocation.IsValid() && !
item1.m_OldLocation.CollidesWith(
src2) &&
item1.m_OldLocation.GetParent() &&
item1.m_OldLocation.GetParent().GetHierarchyRootPlayer())
548 int count =
item1.GetInventory().GetSlotIdCount();
559 if (!
item1.m_OldLocation.GetParent().GetInventory().LocationCanAddEntity(
item1.m_OldLocation))
591 item.GetOnReleaseLock().Invoke(
item);
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
InventoryValidationResult
void hndDebugPrint(string s)
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
script counterpart to engine's class Inventory
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 CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
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
proto native EntityAI GetInventoryOwner()
Engine native functions.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
Abstracted event, not to be used, only inherited.
represent hand state base
inventory for plain man/human
proto native bool TestAddEntityInHands(EntityAI e, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check)
override bool ReplaceItemWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
proto native void SetUserReservedLocation(notnull EntityAI eai, notnull InventoryLocation dst)
int m_syncClearUserReservationindex
void ClearUserReservedLocationAtIndexSynced(int index)
proto native EntityAI CreateInHands(string typeName)
creates new entity in hands
proto native EntityAI GetEntityInHands()
override bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
bool ProcessHandEvent(HandEventBase e)
proto native void ClearUserReservedLocationForContainer(notnull EntityAI eai)
proto native int GetUserReservedLocationCount()
proto native int FindCollidingUserReservedLocationIndex(notnull EntityAI e, notnull InventoryLocation dst)
proto native bool CanAddEntityInHands(EntityAI e)
alternative for TestAddEntityInHands(e, true, true, true);
bool HandEvent(InventoryMode mode, HandEventBase e)
proto native int FindFirstUserReservedLocationIndexForContainer(notnull EntityAI e)
void ClearUserReservedLocationSynced(notnull EntityAI eai)
void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
void OnEntityInHandsDestroyed(InventoryLocation src)
bool ReplaceItemInHandsWithNewElsewhere(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
proto native bool CanOpenInventory()
void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
bool RedirectToHandEvent(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
bool ReplaceItemElsewhereWithNewInHands(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
bool HasEntityInHands(EntityAI e)
proto native void ClearUserReservedLocation(notnull EntityAI eai)
override EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
void HandleInventoryManipulation()
override bool TakeEntityToInventory(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
proto native int FindUserReservedLocationIndex(notnull EntityAI e)
void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
override bool LocalDestroyEntity(notnull EntityAI item)
override bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
proto native bool CanRemoveEntityInHands()
bool ValidateUserReservationCancel(inout Serializer ctx, InventoryValidation validation)
bool ReplaceItemInHandsWithNewImpl(InventoryMode mode, HandEventBase e)
override bool TakeEntityToCargoEx(InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
Put item into into cargo on specific cargo location.
proto native void GetUserReservedLocation(int index, out notnull InventoryLocation dst)
bool ReplaceItemInHandsWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
proto native bool ClearUserReservedLocationAtIndex(int index)
override bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
bool SwappingToPreviousLocation(EntityAI item1, EntityAI item2, out InventoryLocation dst)
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
bool ReplaceItemInElsewhereWithNewinHandsImpl(InventoryMode mode, HandEventBase e)
void OnEntityInHandsCreated(InventoryLocation src)
proto native bool GetDebugFlag()
bool ThrowEntity(EntityAI item, vector dir, float force)
void Update(float delta_time)
static string DumpToStringNullSafe(InventoryLocation loc)
static bool IsInventoryHFSMLogEnable()
base class for transformation operations (creating one item from another)
Serialization general interface. Serializer API works with:
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.