221 return loc.DumpToString();
240 res =
res +
" pos=(" + pos[0] +
", " + pos[1] +
", " + pos[2] +
")";
241 res =
res +
" dir=(" + dir[0] +
", " + dir[1] +
", " + dir[2] +
", " + dir[3] +
")";
315 Debug.
Log(
string.Format(
"Item=%1 does not exist on server!",
Object.GetDebugName(
item)),
"GROUND",
"n/a",
"ReadFromContext",
this.ToString());
326 if (!
ctx.Read(parent))
334 if (!parent || !
item)
338 Debug.
Log(
string.Format(
"Parent=%1 or Item=%2 does not exist on server!",
Object.GetDebugName(parent),
Object.GetDebugName(
item)),
"ATTACHMENT",
"n/a",
"ReadFromContext",
this.ToString());
349 if (!
ctx.Read(parent))
362 if (!parent || !
item)
366 Debug.
Log(
string.Format(
"Parent=%1 or Item=%2 does not exist on server!",
Object.GetDebugName(parent),
Object.GetDebugName(
item)),
"CARGO",
"n/a",
"ReadFromContext",
this.ToString());
377 if (!
ctx.Read(parent))
382 if (!parent || !
item)
386 Debug.
Log(
string.Format(
"Parent=%1 or Item=%2 does not exist on server!",
Object.GetDebugName(parent),
Object.GetDebugName(
item)),
"HANDS",
"n/a",
"ReadFromContext",
this.ToString());
397 if (!
ctx.Read(parent))
410 if (!parent || !
item)
414 Debug.
Log(
string.Format(
"Parent=%1 or Item=%2 does not exist on server!",
Object.GetDebugName(parent),
Object.GetDebugName(
item)),
"PROXYCARGO",
"n/a",
"ReadFromContext",
this.ToString());
425 ErrorEx(
"ReadFromContext - really unknown location type, this should not happen, type=" + type);
436 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed to write type");
450 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=item");
457 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=pos");
465 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=dir");
475 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=parent");
480 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=item");
485 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=slot");
494 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=parent");
499 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=item");
504 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=idx");
509 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=row");
514 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=col");
519 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=flp");
528 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed HND, arg=parent");
533 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed HND, arg=item");
542 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=parent");
547 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=item");
552 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=idx");
557 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=row");
562 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=col");
567 Error(
"InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=flp");
575 Error(
"WriteToContext - really unknown location type, this should not happen, type=" +
GetType());
587 if (!
ctx.Write(
true))
589 Error(
"OptionalLocationWriteToContext - cannot write 1 to context!");
592 return loc.WriteToContext(
ctx);
596 if (!
ctx.Write(
false))
598 Error(
"OptionalLocationWriteToContext - cannot write 0 to context!");
610 Error(
"OptionalLocationReadFromContext - cannot read bool from context!");
618 if (!
loc.ReadFromContext(
ctx))
620 Error(
"OptionalLocationReadFromContext - cannot read (present) inventorylocation from context!");
FindInventoryLocationType
flags for searching locations in inventory
@ PROXYCARGO
cargo of a large object (building,...)
@ ANY
ATT | CGO | PXY | HND.
@ HANDS
hands of another entity
@ CARGO
cargo of another entity
@ NO_SLOT_AUTO_ASSIGN
skips auto-assign test
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
InventoryLocationType
types of Inventory Location
@ UNKNOWN
unknown, usually freshly created object
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
represents base for cargo storage for entities
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
proto native void SetCol(int col)
proto native void SetIndex(int idx)
static string DumpToStringNullSafe(InventoryLocation loc)
proto native void SetSlot(int slotId)
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
proto native bool CollidesWith(notnull InventoryLocation rhs)
checks if inventory locations collides each with other
proto native void SetRow(int row)
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetItem()
returns item of current inventory location
proto native void SetParent(notnull EntityAI parent)
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 int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
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 void SetFlip(bool flip)
proto native vector GetPos()
returns position of item in world if type is Ground
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetParent()
returns parent of current inventory location
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
bool WriteToContext(ParamsWriteContext ctx)
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native bool CompareLocationOnly(notnull InventoryLocation other)
proto native void SetItem(notnull EntityAI item)
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively
proto native InventoryLocation CopyLocationFrom(notnull InventoryLocation rhs, bool copyFlip)
copies location to another location without m_item member
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool ReadFromContext(ParamsReadContext ctx)
proto native bool IsValid()
verify current set inventory location
proto native void Reset()
proto native int GetType()
returns type of InventoryLocation
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native void GetDir(out float dir[4])
returns direction of item in world if type is Ground
proto native void SetProxyCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to ProxyCargo with coordinates (idx, row, col) @NOTE: typical us...
Serialization general interface. Serializer API works with:
void Error(string err)
Messagebox with error message.