Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
inventorylocation.c
Go to the documentation of this file.
1//@NOTE: DO NOT EDIT! enum values are overwritten from c++
14
15//@NOTE: DO NOT EDIT! enum values are overwritten from c++
27
30{
36 proto native bool IsValid();
43 proto native int GetType();
52 proto native EntityAI GetParent();
62 proto native EntityAI GetItem();
71 proto native int GetSlot();
77 proto native int GetIdx();
83 proto native int GetRow();
89 proto native int GetCol();
95 proto native bool GetFlip();
101 proto native vector GetPos();
107 proto native void GetDir(out float dir[4]);
108
115 proto native void SetGround(EntityAI e, vector mat[4]);
123 proto native void SetGroundEx(EntityAI e, vector pos, float dir[4]);
131 proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId);
132
141 proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip);
142
152 proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip);
165 proto native void SetProxyCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip);
172 proto native void SetHands(notnull EntityAI parent, EntityAI e);
173
179 proto native void SetVehicle(notnull EntityAI parent, EntityAI e, int idx);
180
185 proto native void SetTemporary(notnull EntityAI parent, EntityAI e);
186
191 proto native void SetParent(notnull EntityAI parent);
196 proto native void SetItem(notnull EntityAI item);
197
198 // direct set methods
199 proto native void SetSlot(int slotId);
200 proto native void SetIndex(int idx);
201 proto native void SetRow(int row);
202 proto native void SetCol(int col);
203 proto native void SetFlip(bool flip);
204
208 proto native void Reset();
209
210 proto native bool CompareLocationOnly(notnull InventoryLocation other);
211
216 proto native bool CollidesWith(notnull InventoryLocation rhs);
217
224 proto native InventoryLocation Copy(notnull InventoryLocation rhs);
231 proto native InventoryLocation CopyLocationFrom(notnull InventoryLocation rhs, bool copyFlip);
232
233 static string DumpToStringNullSafe(InventoryLocation loc)
234 {
235 if (loc)
236 return loc.DumpToString();
237 return "{ null }";
238 }
239
240 string DumpToString()
241 {
242 string res = "{ type=" + typename.EnumToString(InventoryLocationType, GetType());
243 switch (GetType())
244 {
245 case InventoryLocationType.UNKNOWN:
246 {
247 break;
248 }
249 case InventoryLocationType.GROUND:
250 {
251 res = res + " item=" + Object.GetDebugName(GetItem());
252 vector pos = GetPos();
253 float dir[4];
254 GetDir(dir);
255 res = res + " pos=(" + pos[0] + ", " + pos[1] + ", " + pos[2] + ")";
256 res = res + " dir=(" + dir[0] + ", " + dir[1] + ", " + dir[2] + ", " + dir[3] + ")";
257 break;
258 }
259 case InventoryLocationType.ATTACHMENT:
260 {
261 res = res + " item=" + Object.GetDebugName(GetItem());
262 res = res + " parent=" + Object.GetDebugName(GetParent());
263 res = res + " slot=" + GetSlot();
264 break;
265 }
266 case InventoryLocationType.CARGO:
267 {
268 res = res + " item=" + Object.GetDebugName(GetItem());
269 res = res + " parent=" + Object.GetDebugName(GetParent());
270 res = res + " idx=" + GetIdx() + " row=" + GetRow() + " col=" + GetCol() + " f=" + GetFlip();
271 break;
272 }
273 case InventoryLocationType.HANDS:
274 {
275 res = res + " item=" + Object.GetDebugName(GetItem());
276 res = res + " parent=" + Object.GetDebugName(GetParent());
277 break;
278 }
279 case InventoryLocationType.PROXYCARGO:
280 {
281 res = res + " item=" + Object.GetDebugName(GetItem());
282 res = res + " parent=" + Object.GetDebugName(GetParent());
283 res = res + " idx=" + GetIdx() + " row=" + GetRow() + " col=" + GetCol() + " f=" + GetFlip();
284 break;
285 }
286 case InventoryLocationType.VEHICLE:
287 {
288 res = res + " item=" + Object.GetDebugName(GetItem());
289 res = res + " parent=" + Object.GetDebugName(GetParent());
290 res = res + " idx=" + GetIdx();
291 break;
292 }
293
294 case InventoryLocationType.TEMP:
295 {
296 res = res + " item=" + Object.GetDebugName(GetItem());
297 res = res + " parent=" + Object.GetDebugName(GetParent());
298 break;
299 }
300 default:
301 {
302 res = res + "??";
303 break;
304 }
305 }
306 res = res + " }";
307 return res;
308 }
309
310 bool ReadFromContext(ParamsReadContext ctx)
311 {
312 EntityAI parent;
313 EntityAI item;
314 int type = 0;
315 int idx = -1;
316 int row = -1;
317 int col = -1;
318 bool flp = false;
319 if (!ctx.Read(type))
320 return false;
321
322 switch (type)
323 {
324 case InventoryLocationType.UNKNOWN:
325 {
326 break;
327 }
328 case InventoryLocationType.GROUND:
329 {
330 if (!ctx.Read(item))
331 return false;
332 vector pos;
333 if (!ctx.Read(pos))
334 return false;
335
336 float dir[4];
337 if (!ctx.Read(dir))
338 return false;
339
340 if (!item)
341 {
342#ifdef ENABLE_LOGGING
343#ifdef SERVER
344 Debug.Log(string.Format("Item=%1 does not exist on server!", Object.GetDebugName(item)), "GROUND" , "n/a", "ReadFromContext", this.ToString() );
345#endif
346#endif
347 break; // parent or item is possibly not spawned in bubble yet
348 }
349
350 SetGroundEx(item, pos, dir);
351 break;
352 }
353 case InventoryLocationType.ATTACHMENT:
354 {
355 if (!ctx.Read(parent))
356 return false;
357 if (!ctx.Read(item))
358 return false;
359 int slot;
360 if (!ctx.Read(slot))
361 return false;
362
363 if (!parent || !item)
364 {
365#ifdef ENABLE_LOGGING
366#ifdef SERVER
367 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() );
368#endif
369#endif
370 break; // parent or item is possibly not spawned in bubble yet
371 }
372
373 SetAttachment(parent, item, slot);
374 break;
375 }
376 case InventoryLocationType.CARGO:
377 {
378 if (!ctx.Read(parent))
379 return false;
380 if (!ctx.Read(item))
381 return false;
382 if (!ctx.Read(idx))
383 return false;
384 if (!ctx.Read(row))
385 return false;
386 if (!ctx.Read(col))
387 return false;
388 if (!ctx.Read(flp))
389 return false;
390
391 if (!parent || !item)
392 {
393#ifdef ENABLE_LOGGING
394#ifdef SERVER
395 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() );
396#endif
397#endif
398 break; // parent or item is possibly not spawned in bubble yet
399 }
400
401 SetCargo(parent, item, idx, row, col, flp);
402 break;
403 }
404 case InventoryLocationType.HANDS:
405 {
406 if (!ctx.Read(parent))
407 return false;
408 if (!ctx.Read(item))
409 return false;
410
411 if (!parent || !item)
412 {
413#ifdef ENABLE_LOGGING
414#ifdef SERVER
415 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() );
416#endif
417#endif
418 break; // parent or item is possibly not spawned in bubble yet
419 }
420
421 SetHands(parent, item);
422 break;
423 }
424 case InventoryLocationType.PROXYCARGO:
425 {
426 if (!ctx.Read(parent))
427 return false;
428 if (!ctx.Read(item))
429 return false;
430 if (!ctx.Read(idx))
431 return false;
432 if (!ctx.Read(row))
433 return false;
434 if (!ctx.Read(col))
435 return false;
436 if (!ctx.Read(flp))
437 return false;
438
439 if (!parent || !item)
440 {
441#ifdef ENABLE_LOGGING
442#ifdef SERVER
443 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() );
444#endif
445#endif
446 break; // parent or item is possibly not spawned in bubble yet
447 }
448
449 SetProxyCargo(parent, item, idx, row, col, flp);
450 break;
451 }
452 case InventoryLocationType.VEHICLE:
453 {
454 if (!ctx.Read(parent))
455 return false;
456 if (!ctx.Read(item))
457 return false;
458 if (!ctx.Read(idx))
459 return false;
460
461 if (!parent || !item)
462 {
463#ifdef ENABLE_LOGGING
464#ifdef SERVER
465 Debug.Log(string.Format("Parent=%1 or Item=%2 does not exist on server!", Object.GetDebugName(parent), Object.GetDebugName(item)), "VEHICLE" , "n/a", "ReadFromContext", this.ToString() );
466#endif
467#endif
468 break; // parent or item is possibly not spawned in bubble yet
469 }
470
471 SetVehicle(parent, item, idx);
472 break;
473 }
474
475 case InventoryLocationType.TEMP:
476 {
477 if (!ctx.Read(parent))
478 return false;
479 if (!ctx.Read(item))
480 return false;
481
482 int tmp;
483 if (!ctx.Read(tmp))
484 return false;
485
486 if (!parent || !item)
487 {
488#ifdef ENABLE_LOGGING
489#ifdef SERVER
490 Debug.Log(string.Format("Parent=%1 or Item=%2 does not exist on server!", Object.GetDebugName(parent), Object.GetDebugName(item)), "TEMP" , "n/a", "ReadFromContext", this.ToString() );
491#endif
492#endif
493 break;
494 }
495 SetAttachment(parent, item, -1);
496 //SetTemporary(parent, item);
497 }
498 default:
499 {
500 ErrorEx("ReadFromContext - really unknown location type, this should not happen, type=" + type);
501 return false;
502 }
503 }
504 return true;
505 }
506
507 bool WriteToContext(ParamsWriteContext ctx)
508 {
509 if (GetType() == InventoryLocationType.TEMP)
510 {
511 int type = InventoryLocationType.ATTACHMENT;
512 if (!ctx.Write(type))
513 {
514 Error("InventoryLocation::WriteToContext - cannot write to context! failed to write temp type");
515 return false;
516 }
517 }
518 else if (!ctx.Write(GetType()))
519 {
520 Error("InventoryLocation::WriteToContext - cannot write to context! failed to write type");
521 return false;
522 }
523
524 switch (GetType())
525 {
526 case InventoryLocationType.UNKNOWN:
527 {
528 break;
529 }
530 case InventoryLocationType.GROUND:
531 {
532 if (!ctx.Write(GetItem()))
533 {
534 Error("InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=item");
535 return false;
536 }
537
538 vector pos = GetPos();
539 if (!ctx.Write(pos))
540 {
541 Error("InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=pos");
542 return false;
543 }
544
545 float dir[4];
546 GetDir(dir);
547 if (!ctx.Write(dir))
548 {
549 Error("InventoryLocation::WriteToContext - cannot write to context! failed GND, arg=dir");
550 return false;
551 }
552
553 break;
554 }
555 case InventoryLocationType.ATTACHMENT:
556 {
557 if (!ctx.Write(GetParent()))
558 {
559 Error("InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=parent");
560 return false;
561 }
562 if (!ctx.Write(GetItem()))
563 {
564 Error("InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=item");
565 return false;
566 }
567 if (!ctx.Write(GetSlot()))
568 {
569 Error("InventoryLocation::WriteToContext - cannot write to context! failed ATT, arg=slot");
570 return false;
571 }
572 break;
573 }
574 case InventoryLocationType.CARGO:
575 {
576 if (!ctx.Write(GetParent()))
577 {
578 Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=parent");
579 return false;
580 }
581 if (!ctx.Write(GetItem()))
582 {
583 Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=item");
584 return false;
585 }
586 if (!ctx.Write(GetIdx()))
587 {
588 Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=idx");
589 return false;
590 }
591 if (!ctx.Write(GetRow()))
592 {
593 Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=row");
594 return false;
595 }
596 if (!ctx.Write(GetCol()))
597 {
598 Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=col");
599 return false;
600 }
601 if (!ctx.Write(GetFlip()))
602 {
603 Error("InventoryLocation::WriteToContext - cannot write to context! failed CGO, arg=flp");
604 return false;
605 }
606 break;
607 }
608 case InventoryLocationType.HANDS:
609 {
610 if (!ctx.Write(GetParent()))
611 {
612 Error("InventoryLocation::WriteToContext - cannot write to context! failed HND, arg=parent");
613 return false;
614 }
615 if (!ctx.Write(GetItem()))
616 {
617 Error("InventoryLocation::WriteToContext - cannot write to context! failed HND, arg=item");
618 return false;
619 }
620 break;
621 }
622 case InventoryLocationType.PROXYCARGO:
623 {
624 if (!ctx.Write(GetParent()))
625 {
626 Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=parent");
627 return false;
628 }
629 if (!ctx.Write(GetItem()))
630 {
631 Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=item");
632 return false;
633 }
634 if (!ctx.Write(GetIdx()))
635 {
636 Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=idx");
637 return false;
638 }
639 if (!ctx.Write(GetRow()))
640 {
641 Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=row");
642 return false;
643 }
644 if (!ctx.Write(GetCol()))
645 {
646 Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=col");
647 return false;
648 }
649 if (!ctx.Write(GetFlip()))
650 {
651 Error("InventoryLocation::WriteToContext - cannot write to context! failed PXY, arg=flp");
652 return false;
653 }
654
655 break;
656 }
657
658 case InventoryLocationType.VEHICLE:
659 {
660 if (!ctx.Write(GetParent()))
661 {
662 Error("InventoryLocation::WriteToContext - cannot write to context! failed VHC, arg=parent");
663 return false;
664 }
665 if (!ctx.Write(GetItem()))
666 {
667 Error("InventoryLocation::WriteToContext - cannot write to context! failed VHC, arg=item");
668 return false;
669 }
670 if (!ctx.Write(GetIdx()))
671 {
672 Error("InventoryLocation::WriteToContext - cannot write to context! failed VHC, arg=idx");
673 return false;
674 }
675 break;
676 }
677
678 case InventoryLocationType.TEMP:
679 {
680 if (!ctx.Write(GetParent()))
681 {
682 Error("InventoryLocation::WriteToContext - cannot write to context! failed TMP, arg=parent");
683 return false;
684 }
685
686 if (!ctx.Write(GetItem()))
687 {
688 Error("InventoryLocation::WriteToContext - cannot write to context! failed TMP, arg=item");
689 return false;
690 }
691
692 if (!ctx.Write(-1))
693 {
694 Error("InventoryLocation::WriteToContext - cannot write to context! failed TMP, idx=-1");
695 return false;
696 }
697
698 break;
699 }
700 default:
701 {
702 Error("WriteToContext - really unknown location type, this should not happen, type=" + GetType());
703 return false;
704 }
705 }
706 return true;
707 }
708};
709
711{
712 if (loc)
713 {
714 if (!ctx.Write(true))
715 {
716 Error("OptionalLocationWriteToContext - cannot write 1 to context!");
717 return false;
718 }
719 return loc.WriteToContext(ctx);
720 }
721 else
722 {
723 if (!ctx.Write(false))
724 {
725 Error("OptionalLocationWriteToContext - cannot write 0 to context!");
726 return false;
727 }
728 }
729 return true;
730}
731
733{
734 bool present = false;
735 if (!ctx.Read(present))
736 {
737 Error("OptionalLocationReadFromContext - cannot read bool from context!");
738 return false;
739 }
740
741 if (!present)
742 return true;
743
744 loc = new InventoryLocation();
745 if (!loc.ReadFromContext(ctx))
746 {
747 Error("OptionalLocationReadFromContext - cannot read (present) inventorylocation from context!");
748 return false;
749 }
750 return true;
751}
proto bool IsValid()
Checks if the ScriptCaller is valid.
eBleedingSourceType GetType()
void Reset()
Definition inventory.c:1209
@ UNKNOWN
24 - Any other error. Can be returned from any call.
represents base for cargo storage for entities
Definition cargo.c:7
Definition debug.c:2
InventoryLocation.
proto native vector GetPos()
@ TEMP
Definition dayzphysics.c:42
@ VEHICLE
Definition dayzphysics.c:8
@ ATTACHMENT
ATT.
Serializer ParamsReadContext
Definition gameplay.c:15
Serializer ParamsWriteContext
Definition gameplay.c:16
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
enum ShapeType ErrorEx
Object GetParent()
Get parent of the Effect.
Definition effect.c:422
string DumpToString()
FindInventoryLocationType
flags for searching locations in inventory
@ PROXYCARGO
cargo of a large object (building,...)
@ ANY_CARGO
CGO | PXY.
@ HANDS
hands of another entity
@ NO_SLOT_AUTO_ASSIGN
skips auto-assign test
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
InventoryLocationType
types of Inventory Location
@ GROUND
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
EntityAI GetItem()