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 (!
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))
152 return super.DropEntity(mode, owner, item);
156 Error(
"No inventory location");
168 if (player.NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), null))
172 if (item && item.GetInventory() && item.GetInventory().GetCurrentInventoryLocation(src))
178 HandEventThrow throwEvent =
new HandEventThrow(
GetManOwner(), src);
179 throwEvent.SetForce(dir * force);
188 Error(
"No inventory location");
196 Man man_src = Man.Cast(src.GetParent());
212 r_il.
GetParent().GetOnReleaseLock().Invoke(item);
220 man_src.GetHumanInventory().HandEvent(mode,
new HandEventMoveTo(man_src, src, dst));
228 Man man_dst = Man.Cast(dst.GetParent());
229 man_dst.GetHumanInventory().HandEvent(mode,
new HandEventTake(man_dst, src));
242 return super.TakeToDst(mode, src, dst);
248 if (item.GetInventory().GetCurrentInventoryLocation(src))
257 return super.TakeEntityToInventory(mode, flags, item);
262 Error(
"HumanInventory::TakeEntityToInventory: No inventory location");
272 if (item.GetInventory().GetCurrentInventoryLocation(src))
287 return super.TakeEntityToCargoEx(mode, item, idx, row, col);
290 return super.TakeEntityToCargoEx(mode, item, idx, row, col);
294 Error(
"HumanInventory::TakeEntityToCargoEx: No inventory location");
301 if (item.GetInventory().GetCurrentInventoryLocation(src))
317 return super.TakeEntityAsAttachmentEx(mode, item, slot);
320 return super.TakeEntityAsAttachmentEx(mode, item, slot);
324 Error(
"HumanInventory::TakeEntityAsAttachmentEx: No inventory location");
333 bool handled =
false;
363 return super.SwapEntities(mode, item1, item2);
368 Error(
"HumanInventory::SwapEntities: cannot create src1, src2, dst1, dst2");
380 bool handled =
false;
413 bool returnValue =
true;
416 returnValue = super.ForceSwapEntities(mode, item1, item2, item2_dst);
421 Error(
"HumanInventory::ForceSwapEntities: No inventory location");
428 if (item.GetInventory().GetCurrentInventoryLocation(src))
440 return super.LocalDestroyEntity(item);
443 return super.LocalDestroyEntity(item);
447 Error(
"LocalDestroyEntity: No inventory location");
457 return super.ReplaceItemWithNew(mode, lambda);
469 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl Item in hands, event=" + e.
DumpToString());
487 Error(
"HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl TODO");
491 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl src has to be hands");
496 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl no dst in event, event=" + e.
DumpToString());
504 if (itemInHands && itemInHands.GetInventory().GetCurrentInventoryLocation(src))
521 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl src has to be hands");
526 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl No item in hands, event=" + e.
DumpToString());
542 bool SwapToPrevious =
true;
546 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
548 if (item1.m_OldLocation && item1.m_OldLocation.IsValid() && !item1.m_OldLocation.CollidesWith(src2) && item1.m_OldLocation.GetParent() && item1.m_OldLocation.GetParent().GetHierarchyRootPlayer())
550 dst.Copy(item1.m_OldLocation);
552 int count = item1.GetInventory().GetSlotIdCount();
555 for (
int i = 0; i < count; i++)
557 int slotID = item1.GetInventory().GetSlotId(i);
563 if (!item1.m_OldLocation.GetParent().GetInventory().LocationCanAddEntity(item1.m_OldLocation))
564 SwapToPrevious =
false;
567 SwapToPrevious =
false;
595 item.GetOnReleaseLock().Invoke(item);
605 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
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.
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()
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:
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.