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
void hndDebugPrint(string s)
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
proto native bool GetFlipCargo()
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
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 int GetSlotId(int index)
attachments
proto native int GetSlotIdCount()
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
script counterpart to engine's class Inventory
override InventoryLocation GetDst()
override bool ReserveInventory()
override string DumpToString()
Abstracted event, not to be used, only inherited.
represent hand state base
override bool ReplaceItemWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
proto native void SetUserReservedLocation(notnull EntityAI eai, notnull InventoryLocation dst)
int m_syncClearUserReservationindex
void ClearUserReservedLocationAtIndexSynced(int index)
override bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
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)
bool ProcessHandEvent(HandEventBase e)
proto native void ClearUserReservedLocationForContainer(notnull EntityAI eai)
proto native int GetUserReservedLocationCount()
bool OnInventoryCheck(int userDataType, ParamsReadContext ctx)
proto native int FindCollidingUserReservedLocationIndex(notnull EntityAI e, notnull InventoryLocation dst)
bool HandEvent(InventoryMode mode, HandEventBase e)
proto native EntityAI CreateInHands(string typeName)
creates new entity in hands
proto native int FindFirstUserReservedLocationIndexForContainer(notnull EntityAI e)
override EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
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()
bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
proto native EntityAI GetEntityInHands()
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)
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 CanAddEntityInHands(EntityAI e)
alternative for TestAddEntityInHands(e, true, true, true);
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)
proto native bool CanRemoveEntityInHands()
bool PostDeferredEventTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
inventory for plain man/human
proto native EntityAI GetParent()
returns parent of current inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>
proto native int GetSlot()
returns slot id if current type is Attachment
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
proto native int GetType()
returns type of InventoryLocation
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native EntityAI GetItem()
returns item of current inventory location
InventoryValidationResult m_Result
static bool IsInventoryHFSMLogEnable()
base class for transformation operations (creating one item from another)
proto bool Write(void value_out)
Serialization general interface. Serializer API works with:
Serializer ParamsReadContext
void Error(string err)
Messagebox with error message.