30 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);
67 EntityAI newEntity = super.CreateInInventory(type);
68 if (newEntity == null)
77 else if (!
g_Game.IsMultiplayer())
80 eai.GetOnReleaseLock().Invoke(eai);
89 else if (!
g_Game.IsMultiplayer())
97 item.GetOnReleaseLock().Invoke(item);
155 return super.DropEntity(mode, owner, item);
160 Error(
"No inventory location");
172 if (player.NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), null))
185 HandEventThrow throwEvent =
new HandEventThrow(
GetManOwner(), src);
186 throwEvent.SetForce(dir * force);
196 Error(
"No inventory location");
204 Man man_src = Man.Cast(src.GetParent());
220 r_il.
GetParent().GetOnReleaseLock().Invoke(item);
228 man_src.GetHumanInventory().HandEvent(mode,
new HandEventMoveTo(man_src, src, dst));
236 Man man_dst = Man.Cast(dst.GetParent());
237 man_dst.GetHumanInventory().HandEvent(mode,
new HandEventTake(man_dst, src));
250 return super.TakeToDst(mode, src, dst);
256 if (item.GetInventory().GetCurrentInventoryLocation(src))
265 return super.TakeEntityToInventory(mode, flags, item);
270 Error(
"HumanInventory::TakeEntityToInventory: No inventory location");
287 if (inventoryOwner.IsAlive())
297 return super.TakeEntityToCargoEx(mode, item, idx, row, col);
300 return super.TakeEntityToCargoEx(mode, item, idx, row, col);
304 Error(
"HumanInventory::TakeEntityToCargoEx: No inventory location");
311 if (item.GetInventory().GetCurrentInventoryLocation(src))
317 if (inventoryOwner.IsAlive())
327 return super.TakeEntityAsAttachmentEx(mode, item, slot);
330 return super.TakeEntityAsAttachmentEx(mode, item, slot);
334 Error(
"HumanInventory::TakeEntityAsAttachmentEx: No inventory location");
343 bool handled =
false;
373 return super.SwapEntities(mode, item1, item2);
378 Error(
"HumanInventory::SwapEntities: cannot create src1, src2, dst1, dst2");
390 bool handled =
false;
423 bool returnValue =
true;
426 returnValue = super.ForceSwapEntities(mode, item1, item2, item2_dst);
431 Error(
"HumanInventory::ForceSwapEntities: No inventory location");
438 if (item.GetInventory().GetCurrentInventoryLocation(src))
450 return super.LocalDestroyEntity(item);
453 return super.LocalDestroyEntity(item);
457 Error(
"LocalDestroyEntity: No inventory location");
467 return super.ReplaceItemWithNew(mode, lambda);
480 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl Item in hands, event=" + e.
DumpToString());
498 Error(
"HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl TODO");
502 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl src has to be hands");
507 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl no dst in event, event=" + e.
DumpToString());
515 if (itemInHands && itemInHands.GetInventory().GetCurrentInventoryLocation(src))
532 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl src has to be hands");
537 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl No item in hands, event=" + e.
DumpToString());
555 bool SwapToPrevious =
true;
562 if (item1.m_OldLocation && item1.m_OldLocation.IsValid() && !item1.m_OldLocation.CollidesWith(src2) && item1.m_OldLocation.GetParent() && item1.m_OldLocation.GetParent().GetHierarchyRootPlayer())
564 dst.Copy(item1.m_OldLocation);
569 for (
int i = 0; i < count; ++i)
571 int slotID = item1Inventory.
GetSlotId(i);
577 if (!item1.m_OldLocation.GetParent().GetInventory().LocationCanAddEntity(item1.m_OldLocation))
578 SwapToPrevious =
false;
581 SwapToPrevious =
false;
609 item.GetOnReleaseLock().Invoke(item);
619 if (!ctx.Read(index))
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
InventoryValidationResult
script counterpart to engine's class Inventory
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
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
proto native bool GetFlipCargo()
proto native int GetSlotIdCount()
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 bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto native EntityAI GetInventoryOwner()
Engine native functions.
proto native int GetSlotId(int index)
Abstracted event, not to be used, only inherited.
override bool ReserveInventory()
override string DumpToString()
override InventoryLocation GetDst()
represent hand state base
inventory for plain man/human
proto native int GetUserReservedLocationCount()
bool OnInventoryCheck(int userDataType, ParamsReadContext ctx)
bool HasEntityInHands(EntityAI e)
proto native int FindUserReservedLocationIndex(notnull EntityAI e)
override bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
void OnEntityInHandsCreated(InventoryLocation src)
proto native void ClearUserReservedLocation(notnull EntityAI eai)
bool PostDeferredEventTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
proto native bool CanRemoveEntityInHands()
bool SwappingToPreviousLocation(EntityAI item1, EntityAI item2, out InventoryLocation dst)
proto native EntityAI GetEntityInHands()
bool ValidateUserReservationCancel(inout Serializer ctx, InventoryValidation validation)
override EntityAI CreateInInventory(string type)
proto native void GetUserReservedLocation(int index, out notnull InventoryLocation dst)
proto native bool CanOpenInventory()
bool ReplaceItemInHandsWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
override bool TakeEntityToInventory(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
void ClearUserReservedLocationSynced(notnull EntityAI eai)
override bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
bool HandEvent(InventoryMode mode, HandEventBase e)
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
proto native bool CanAddEntityInHands(EntityAI e)
proto native void ClearUserReservedLocationForContainer(notnull EntityAI eai)
bool ReplaceItemInHandsWithNewElsewhere(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
proto native bool GetDebugFlag()
bool ThrowEntity(EntityAI item, vector dir, float force)
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
proto native bool ClearUserReservedLocationAtIndex(int index)
void ClearUserReservedLocationAtIndexSynced(int index)
void HandleInventoryManipulation()
void Update(float delta_time)
bool ReplaceItemInElsewhereWithNewinHandsImpl(InventoryMode mode, HandEventBase e)
void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
proto native int FindCollidingUserReservedLocationIndex(notnull EntityAI e, notnull InventoryLocation dst)
override bool ReplaceItemWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
override bool TakeEntityToCargoEx(InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
Put item into into cargo on specific cargo location.
bool ReplaceItemElsewhereWithNewInHands(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
override bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
proto native void SetUserReservedLocation(notnull EntityAI eai, notnull InventoryLocation dst)
int m_syncClearUserReservationindex
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)
void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
proto native int FindFirstUserReservedLocationIndexForContainer(notnull EntityAI e)
bool ProcessHandEvent(HandEventBase e)
bool ReplaceItemInHandsWithNewImpl(InventoryMode mode, HandEventBase e)
override bool LocalDestroyEntity(notnull EntityAI item)
void OnEntityInHandsDestroyed(InventoryLocation src)
bool RedirectToHandEvent(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
proto native EntityAI CreateInHands(string typeName)
void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetType()
returns type of InventoryLocation
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
proto native EntityAI GetItem()
returns item of current inventory location
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
static string DumpToStringNullSafe(InventoryLocation loc)
InventoryValidationResult m_Result
static bool IsInventoryHFSMLogEnable()
base class for transformation operations (creating one item from another)
Serialization general interface.
proto bool Write(void value_out)
Serializer ParamsReadContext
void Error(string err)
Messagebox with error message.
void hndDebugPrint(string s)
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location