Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
inventorylocation.c
Go to the documentation of this file.
1 //@NOTE: DO NOT EDIT! enum values are overwritten from c++
4 {
8  CARGO,
9  HANDS,
11 };
12 
13 //@NOTE: DO NOT EDIT! enum values are overwritten from c++
16 {
17  ATTACHMENT,
18  CARGO,
19  HANDS,
20  PROXYCARGO,
22  ANY,
24 };
25 
28 {
34  proto native bool IsValid();
41  proto native int GetType();
50  proto native EntityAI GetParent();
60  proto native EntityAI GetItem();
69  proto native int GetSlot();
75  proto native int GetIdx();
81  proto native int GetRow();
87  proto native int GetCol();
93  proto native bool GetFlip();
99  proto native vector GetPos();
105  proto native void GetDir(out float dir[4]);
106 
113  proto native void SetGround(EntityAI e, vector mat[4]);
121  proto native void SetGroundEx(EntityAI e, vector pos, float dir[4]);
129  proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId);
130 
139  proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip);
140 
150  proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip);
163  proto native void SetProxyCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip);
170  proto native void SetHands(notnull EntityAI parent, EntityAI e);
171 
176  proto native void SetParent(notnull EntityAI parent);
181  proto native void SetItem(notnull EntityAI item);
182 
183  // direct set methods
184  proto native void SetSlot(int slotId);
185  proto native void SetIndex(int idx);
186  proto native void SetRow(int row);
187  proto native void SetCol(int col);
188  proto native void SetFlip(bool flip);
189 
193  proto native void Reset();
194 
195  proto native bool CompareLocationOnly(notnull InventoryLocation other);
196 
201  proto native bool CollidesWith(notnull InventoryLocation rhs);
202 
209  proto native InventoryLocation Copy(notnull InventoryLocation rhs);
216  proto native InventoryLocation CopyLocationFrom(notnull InventoryLocation rhs, bool copyFlip);
217 
218  static string DumpToStringNullSafe(InventoryLocation loc)
219  {
220  if (loc)
221  return loc.DumpToString();
222  return "{ null }";
223  }
224 
225  string DumpToString()
226  {
227  string res = "{ type=" + typename.EnumToString(InventoryLocationType, GetType());
228  switch (GetType())
229  {
230  case InventoryLocationType.UNKNOWN:
231  {
232  break;
233  }
234  case InventoryLocationType.GROUND:
235  {
236  res = res + " item=" + Object.GetDebugName(GetItem());
237  vector pos = GetPos();
238  float dir[4];
239  GetDir(dir);
240  res = res + " pos=(" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")";
241  res = res + " dir=(" + dir[0] + ", " + dir[1] + ", " + dir[2] + ", " + dir[3] + ")";
242  break;
243  }
244  case InventoryLocationType.ATTACHMENT:
245  {
246  res = res + " item=" + Object.GetDebugName(GetItem());
247  res = res + " parent=" + Object.GetDebugName(GetParent());
248  res = res + " slot=" + GetSlot();
249  break;
250  }
251  case InventoryLocationType.CARGO:
252  {
253  res = res + " item=" + Object.GetDebugName(GetItem());
254  res = res + " parent=" + Object.GetDebugName(GetParent());
255  res = res + " idx=" + GetIdx() + " row=" + GetRow() + " col=" + GetCol() + " f=" + GetFlip();
256  break;
257  }
258  case InventoryLocationType.HANDS:
259  {
260  res = res + " item=" + Object.GetDebugName(GetItem());
261  res = res + " parent=" + Object.GetDebugName(GetParent());
262  break;
263  }
264  case InventoryLocationType.PROXYCARGO:
265  {
266  res = res + " item=" + Object.GetDebugName(GetItem());
267  res = res + " parent=" + Object.GetDebugName(GetParent());
268  res = res + " idx=" + GetIdx() + " row=" + GetRow() + " col=" + GetCol() + " f=" + GetFlip();
269  break;
270  }
271  default:
272  {
273  res = res + "??";
274  break;
275  }
276  }
277  res = res + " }";
278  return res;
279  }
280 
281  bool ReadFromContext(ParamsReadContext ctx)
282  {
283  EntityAI parent;
284  EntityAI item;
285  int type = 0;
286  int idx = -1;
287  int row = -1;
288  int col = -1;
289  bool flp = false;
290  if (!ctx.Read(type))
291  return false;
292 
293  switch (type)
294  {
295  case InventoryLocationType.UNKNOWN:
296  {
297  break;
298  }
299  case InventoryLocationType.GROUND:
300  {
301  if (!ctx.Read(item))
302  return false;
303  vector pos;
304  if (!ctx.Read(pos))
305  return false;
306 
307  float dir[4];
308  if (!ctx.Read(dir))
309  return false;
310 
311  if (!item)
312  {
313 #ifdef DIAG_DEVELOPER
314 #ifdef SERVER
315  Debug.Log(string.Format("Item=%1 does not exist on server!", Object.GetDebugName(item)), "GROUND" , "n/a", "ReadFromContext", this.ToString() );
316 #endif
317 #endif
318  break; // parent or item is not in bubble
319  }
320 
321  SetGroundEx(item, pos, dir);
322  break;
323  }
324  case InventoryLocationType.ATTACHMENT:
325  {
326  if (!ctx.Read(parent))
327  return false;
328  if (!ctx.Read(item))
329  return false;
330  int slot;
331  if (!ctx.Read(slot))
332  return false;
333 
334  if (!parent || !item)
335  {
336 #ifdef DIAG_DEVELOPER
337 #ifdef SERVER
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() );
339 #endif
340 #endif
341  break; // parent or item is not in bubble
342  }
343 
344  SetAttachment(parent, item, slot);
345  break;
346  }
347  case InventoryLocationType.CARGO:
348  {
349  if (!ctx.Read(parent))
350  return false;
351  if (!ctx.Read(item))
352  return false;
353  if (!ctx.Read(idx))
354  return false;
355  if (!ctx.Read(row))
356  return false;
357  if (!ctx.Read(col))
358  return false;
359  if (!ctx.Read(flp))
360  return false;
361 
362  if (!parent || !item)
363  {
364 #ifdef DIAG_DEVELOPER
365 #ifdef SERVER
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() );
367 #endif
368 #endif
369  break; // parent or item is not in bubble
370  }
371 
372  SetCargo(parent, item, idx, row, col, flp);
373  break;
374  }
375  case InventoryLocationType.HANDS:
376  {
377  if (!ctx.Read(parent))
378  return false;
379  if (!ctx.Read(item))
380  return false;
381 
382  if (!parent || !item)
383  {
384 #ifdef DIAG_DEVELOPER
385 #ifdef SERVER
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() );
387 #endif
388 #endif
389  break; // parent or item is not in bubble
390  }
391 
392  SetHands(parent, item);
393  break;
394  }
395  case InventoryLocationType.PROXYCARGO:
396  {
397  if (!ctx.Read(parent))
398  return false;
399  if (!ctx.Read(item))
400  return false;
401  if (!ctx.Read(idx))
402  return false;
403  if (!ctx.Read(row))
404  return false;
405  if (!ctx.Read(col))
406  return false;
407  if (!ctx.Read(flp))
408  return false;
409 
410  if (!parent || !item)
411  {
412 #ifdef DIAG_DEVELOPER
413 #ifdef SERVER
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() );
415 #endif
416 #endif
417  break; // parent or item is not in bubble
418  }
419 
420  SetProxyCargo(parent, item, idx, row, col, flp);
421  break;
422  }
423  default:
424  {
425  ErrorEx("ReadFromContext - really unknown location type, this should not happen, type=" + type);
426  return false;
427  }
428  }
429  return true;
430  }
431 
432  bool WriteToContext(ParamsWriteContext ctx)
433  {
434  if (!ctx.Write(GetType()))
435  {
436  Error("InventoryLocation::WriteToContext - cannot write to context! failed to write type");
437  return false;
438  }
439 
440  switch (GetType())
441  {
442  case InventoryLocationType.UNKNOWN:
443  {
444  break;
445  }
446  case InventoryLocationType.GROUND:
447  {
448  if (!ctx.Write(GetItem()))
449  {
450  Error("InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=item");
451  return false;
452  }
453 
454  vector pos = GetPos();
455  if (!ctx.Write(pos))
456  {
457  Error("InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=pos");
458  return false;
459  }
460 
461  float dir[4];
462  GetDir(dir);
463  if (!ctx.Write(dir))
464  {
465  Error("InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=dir");
466  return false;
467  }
468 
469  break;
470  }
471  case InventoryLocationType.ATTACHMENT:
472  {
473  if (!ctx.Write(GetParent()))
474  {
475  Error("InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=parent");
476  return false;
477  }
478  if (!ctx.Write(GetItem()))
479  {
480  Error("InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=item");
481  return false;
482  }
483  if (!ctx.Write(GetSlot()))
484  {
485  Error("InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=slot");
486  return false;
487  }
488  break;
489  }
490  case InventoryLocationType.CARGO:
491  {
492  if (!ctx.Write(GetParent()))
493  {
494  Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=parent");
495  return false;
496  }
497  if (!ctx.Write(GetItem()))
498  {
499  Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=item");
500  return false;
501  }
502  if (!ctx.Write(GetIdx()))
503  {
504  Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=idx");
505  return false;
506  }
507  if (!ctx.Write(GetRow()))
508  {
509  Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=row");
510  return false;
511  }
512  if (!ctx.Write(GetCol()))
513  {
514  Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=col");
515  return false;
516  }
517  if (!ctx.Write(GetFlip()))
518  {
519  Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=flp");
520  return false;
521  }
522  break;
523  }
524  case InventoryLocationType.HANDS:
525  {
526  if (!ctx.Write(GetParent()))
527  {
528  Error("InventoryLocation::WriteToContext - cannot write to context! failed HND, arg=parent");
529  return false;
530  }
531  if (!ctx.Write(GetItem()))
532  {
533  Error("InventoryLocation::WriteToContext - cannot write to context! failed HND, arg=item");
534  return false;
535  }
536  break;
537  }
538  case InventoryLocationType.PROXYCARGO:
539  {
540  if (!ctx.Write(GetParent()))
541  {
542  Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=parent");
543  return false;
544  }
545  if (!ctx.Write(GetItem()))
546  {
547  Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=item");
548  return false;
549  }
550  if (!ctx.Write(GetIdx()))
551  {
552  Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=idx");
553  return false;
554  }
555  if (!ctx.Write(GetRow()))
556  {
557  Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=row");
558  return false;
559  }
560  if (!ctx.Write(GetCol()))
561  {
562  Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=col");
563  return false;
564  }
565  if (!ctx.Write(GetFlip()))
566  {
567  Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=flp");
568  return false;
569  }
570 
571  break;
572  }
573  default:
574  {
575  Error("WriteToContext - really unknown location type, this should not happen, type=" + GetType());
576  return false;
577  }
578  }
579  return true;
580  }
581 };
582 
584 {
585  if (loc)
586  {
587  if (!ctx.Write(true))
588  {
589  Error("OptionalLocationWriteToContext - cannot write 1 to context!");
590  return false;
591  }
592  return loc.WriteToContext(ctx);
593  }
594  else
595  {
596  if (!ctx.Write(false))
597  {
598  Error("OptionalLocationWriteToContext - cannot write 0 to context!");
599  return false;
600  }
601  }
602  return true;
603 }
604 
606 {
607  bool present = false;
608  if (!ctx.Read(present))
609  {
610  Error("OptionalLocationReadFromContext - cannot read bool from context!");
611  return false;
612  }
613 
614  if (!present)
615  return true;
616 
617  loc = new InventoryLocation();
618  if (!loc.ReadFromContext(ctx))
619  {
620  Error("OptionalLocationReadFromContext - cannot read (present) inventorylocation from context!");
621  return false;
622  }
623  return true;
624 }
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
UNKNOWN
@ UNKNOWN
unknown, usually freshly created object
Definition: inventorylocation.c:5
NO_SLOT_AUTO_ASSIGN
@ NO_SLOT_AUTO_ASSIGN
skips auto-assign test
Definition: inventorylocation.c:23
GROUND
@ GROUND
Definition: inventorylocation.c:6
OptionalLocationReadFromContext
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
Definition: inventorylocation.c:605
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
GetPos
proto void GetPos(out float x, out float y)
ErrorEx
enum ShapeType ErrorEx
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OptionalLocationWriteToContext
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
Definition: inventorylocation.c:583
vector
Definition: enconvert.c:105
CARGO
@ CARGO
cargo of another entity
Definition: inventorylocation.c:8
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
GetItem
EntityAI GetItem()
Definition: radialquickbarmenu.c:37
CargoBase
represents base for cargo storage for entities
Definition: cargo.c:6
Object
Definition: objecttyped.c:1
PROXYCARGO
@ PROXYCARGO
cargo of a large object (building,...)
Definition: inventorylocation.c:10
ANY_CARGO
@ ANY_CARGO
CGO | PXY.
Definition: inventorylocation.c:21
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
ANY
@ ANY
ATT | CGO | PXY | HND.
Definition: inventorylocation.c:22
Debug
Definition: debug.c:13
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
ATTACHMENT
@ ATTACHMENT
< ground
Definition: inventorylocation.c:7
HANDS
@ HANDS
hands of another entity
Definition: inventorylocation.c:9
EntityAI
Definition: building.c:5
GetType
override int GetType()
Definition: huddebugwincharagents.c:49