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);
136 if (item && item.GetInventory() && item.GetInventory().GetCurrentInventoryLocation(src))
145 default:
return super.DropEntity(mode, owner, item);
148 Error(
"No inventory location");
160 if ( player.NeedInventoryJunctureFromServer( item, item.GetHierarchyParent(), null) )
164 if (item && item.GetInventory() && item.GetInventory().GetCurrentInventoryLocation(src))
169 hndDebugPrint(
"[inv] HumanInventory::ThrowEntity item=" + item);
170 HandEventThrow throwEvent =
new HandEventThrow(
GetManOwner(), src);
171 throwEvent.SetForce(dir * force);
181 Error(
"No inventory location");
189 Man man_src = Man.Cast(src.GetParent());
190 hndDebugPrint(
"[inv] HI::RedirectToHandEvent - source location == HANDS, player has to handle this");
205 r_il.
GetParent().GetOnReleaseLock().Invoke( item );
209 r_il.
GetParent().GetOnAttachmentReleaseLock().Invoke( item, r_il.
GetSlot() );
219 hndDebugPrint(
"[inv] HI::RedirectToHandEvent - dst location == HANDS, player has to handle this");
221 Man man_dst = Man.Cast(dst.GetParent());
222 man_dst.GetHumanInventory().HandEvent(mode,
new HandEventTake(man_dst, src));
235 return super.TakeToDst(mode, src, dst);
241 if (item.GetInventory().GetCurrentInventoryLocation(src))
250 return super.TakeEntityToInventory(mode, flags, item);
258 Error(
"HumanInventory::TakeEntityToInventory: No inventory location");
268 if (item.GetInventory().GetCurrentInventoryLocation(src))
276 hndDebugPrint(
"[inv] HumanInventory::Take2Cgo(" +
typename.EnumToString(
InventoryMode, mode) +
") item=" + item +
" row=" + row +
" col=" + col);
283 return super.TakeEntityToCargoEx(mode, item, idx, row, col);
285 default:
return super.TakeEntityToCargoEx(mode, item, idx, row, col);
288 Error(
"HumanInventory::TakeEntityToCargoEx: No inventory location");
295 if (item.GetInventory().GetCurrentInventoryLocation(src))
303 hndDebugPrint(
"[inv] HumanInventory::Take2Att(" +
typename.EnumToString(
InventoryMode, mode) +
") item=" + item +
" slot=" + slot);
311 return super.TakeEntityAsAttachmentEx(mode, item, slot);
313 default:
return super.TakeEntityAsAttachmentEx(mode, item, slot);
316 Error(
"HumanInventory::TakeEntityAsAttachmentEx: No inventory location");
325 bool handled =
false;
359 return super.SwapEntities(mode, item1, item2);
362 Error(
"HumanInventory::SwapEntities: cannot create src1, src2, dst1, dst2");
374 bool handled =
false;
409 bool returnValue =
true;
412 returnValue = super.ForceSwapEntities(mode, item1, item2, item2_dst);
416 Error(
"HumanInventory::ForceSwapEntities: No inventory location");
423 if (item.GetInventory().GetCurrentInventoryLocation(src))
431 hndDebugPrint(
"[inv] HumanInventory::LocalDestroy inv item=" + item);
435 return super.LocalDestroyEntity(item);
437 default:
return super.LocalDestroyEntity(item);
440 Error(
"LocalDestroyEntity: No inventory location");
449 return super.ReplaceItemWithNew(mode, lambda);
461 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl Item in hands, event=" + e.
DumpToString());
474 hndDebugPrint(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl event=" + e);
480 Error(
"HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl TODO");
484 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl src has to be hands");
488 Error(
"[inv] HumanInventory::ReplaceItemInElsewhereWithNewinHandsImpl no dst in event, event=" + e.
DumpToString());
496 if (itemInHands && itemInHands.GetInventory().GetCurrentInventoryLocation(src))
504 hndDebugPrint(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl event=" + e);
515 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl src has to be hands");
519 Error(
"[inv] HumanInventory::ReplaceItemInHandsWithNewImpl No item in hands, event=" + e.
DumpToString());
535 bool SwapToPrevious =
true;
539 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
541 if (item1.m_OldLocation && item1.m_OldLocation.IsValid() && !item1.m_OldLocation.CollidesWith(src2) && item1.m_OldLocation.GetParent() && item1.m_OldLocation.GetParent().GetHierarchyRootPlayer())
543 dst.
Copy(item1.m_OldLocation);
545 int count = item1.GetInventory().GetSlotIdCount();
549 for (
int i = 0; i < count; i++)
551 int slotID = item1.GetInventory().GetSlotId(i);
560 if ( !item1.m_OldLocation.GetParent().GetInventory().LocationCanAddEntity(item1.m_OldLocation) )
563 SwapToPrevious =
false;
567 SwapToPrevious =
false;
571 if ( SwapToPrevious )
598 item.GetOnReleaseLock().Invoke(item);
614 if (!ctx.Read(index))
InventoryValidationResult
void hndDebugPrint(string s)
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
HumanInventory GetHumanInventory()
inventory
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 bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto native EntityAI GetInventoryOwner()
Engine native functions.
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()
override EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
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 SwappingToPreviousLocation(EntityAI item1, EntityAI item2, out InventoryLocation dst)
bool ValidateUserReservationCancel(inout Serializer ctx, InventoryValidation validation)
proto native void GetUserReservedLocation(int index, out notnull InventoryLocation dst)
proto native bool CanOpenInventory()
proto native bool CanAddEntityInHands(EntityAI e)
alternative for TestAddEntityInHands(e, true, true, true);
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 void ClearUserReservedLocationForContainer(notnull EntityAI eai)
bool ReplaceItemInHandsWithNewElsewhere(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
proto native bool GetDebugFlag()
proto native EntityAI CreateInHands(string typeName)
creates new entity in hands
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)
protected bool ReplaceItemInElsewhereWithNewinHandsImpl(InventoryMode mode, HandEventBase e)
void ClearUserReservedLocationAtIndexSynced(int index)
void HandleInventoryManipulation()
void Update(float delta_time)
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.
proto native EntityAI GetEntityInHands()
bool ReplaceItemElsewhereWithNewInHands(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
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 CanRemoveEntityInHands()
void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
proto native int FindFirstUserReservedLocationIndexForContainer(notnull EntityAI e)
bool ProcessHandEvent(HandEventBase e)
override bool LocalDestroyEntity(notnull EntityAI item)
void OnEntityInHandsDestroyed(InventoryLocation src)
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 RedirectToHandEvent(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
protected bool ReplaceItemInHandsWithNewImpl(InventoryMode mode, HandEventBase e)
void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
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 InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
proto native EntityAI GetParent()
returns parent of current inventory location
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 EntityAI GetItem()
returns item of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
static string DumpToStringNullSafe(InventoryLocation loc)
InventoryValidationResult m_Result
base class for transformation operations (creating one item from another)
Serialization general interface. Serializer API works with:
proto bool Write(void value_out)
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.