File size: 34,345 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 |
class Man extends EntityAI
{
//! Returns player's input interface
proto native UAInterface GetInputInterface();
//! Returns player's identity
proto native PlayerIdentity GetIdentity();
//! Returns vehicle which this Man object is driving. If this Man object isn't as driver of any vehicle it will return NULL.
proto native EntityAI GetDrivingVehicle();
proto native owned string GetCurrentWeaponMode();
//! Set speech restriction
proto native void SetSpeechRestricted(bool state);
//! Check if player has resctricted speech
proto native bool IsSpeechRestricted();
//! Texture that is used on the Man's face and hands
proto native void SetFaceTexture(string texture_name);
//! Material that is used on the Man's face and hands
proto native void SetFaceMaterial(string material_name);
proto native bool IsSoundInsideBuilding();
proto native bool IsCameraInsideVehicle();
proto native owned string GetMasterAttenuation();
proto native void SetMasterAttenuation(string masterAttenuation);
void Man()
{
SetFlags(EntityFlags.TOUCHTRIGGERS, false);
}
override bool IsMan()
{
return true;
}
override bool IsHealthVisible()
{
return false;
}
override bool HasFixedActionTargetCursorPosition()
{
return true;
}
bool IsUnconscious();
int GetPlayerState()
{
if (IsAlive())
return EPlayerStates.ALIVE;
return EPlayerStates.DEAD;
}
void AddItemToDelete(EntityAI item);
///@{ inventory
HumanInventory GetHumanInventory()
{
HumanInventory i = HumanInventory.Cast(GetInventory());
return i;
}
//Called when an item is removed from the cargo of this item
protected ref ScriptInvoker m_OnItemAddedToHands;
//Called when an item is moved around in the cargo of this item
protected ref ScriptInvoker m_OnItemRemovedFromHands;
ScriptInvoker GetOnItemAddedToHands()
{
if (!m_OnItemAddedToHands)
m_OnItemAddedToHands = new ScriptInvoker();
return m_OnItemAddedToHands;
}
ScriptInvoker GetOnItemRemovedFromHands()
{
if( !m_OnItemRemovedFromHands )
m_OnItemRemovedFromHands = new ScriptInvoker;
return m_OnItemRemovedFromHands;
}
void EEItemIntoHands(EntityAI item)
{
SetWeightDirty();
if( m_OnItemAddedToHands )
m_OnItemAddedToHands.Invoke( item, this );
}
void EEItemOutOfHands(EntityAI item)
{
SetWeightDirty();
if( m_OnItemRemovedFromHands )
m_OnItemRemovedFromHands.Invoke( item, this );
}
///@{ drop juncture
bool JunctureDropEntity (notnull EntityAI item)
{
return DropEntityImpl(InventoryMode.JUNCTURE, this, item);
}
override bool PredictiveDropEntity (notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveDropEntity input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
return JunctureDropEntity(item);
else
return DropEntityImpl(InventoryMode.PREDICTIVE, this, item);
}
override bool LocalDropEntity (notnull EntityAI item)
{
return DropEntityImpl(InventoryMode.LOCAL, this, item);
}
override bool ServerDropEntity (notnull EntityAI item)
{
return DropEntityImpl(InventoryMode.SERVER, this, item);
}
protected bool DropEntityImpl (InventoryMode mode, notnull EntityAI owner, notnull EntityAI item)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::DropEntity(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetHumanInventory().DropEntity(mode, owner, item);
UpdateInventoryMenu();
return code;
}
///@} drop juncture
override bool CanDropEntity (notnull EntityAI item) { return true; }
void OnItemInHandsChanged () { }
bool NeedInventoryJunctureFromServer (notnull EntityAI item, EntityAI currParent, EntityAI newParent) { return false; }
///@{ hand juncture
void JunctureTakeEntityToHands (notnull EntityAI item)
{
TakeEntityToHandsImpl(InventoryMode.JUNCTURE, item);
}
void PredictiveTakeEntityToHands (EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToHands input data not sent yet, cannot allow another input action");
return;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
JunctureTakeEntityToHands(item);
else
TakeEntityToHandsImpl(InventoryMode.PREDICTIVE, item);
}
void LocalTakeEntityToHands (EntityAI item)
{
TakeEntityToHandsImpl(InventoryMode.LOCAL, item);
}
void ServerTakeEntityToHands (EntityAI item)
{
TakeEntityToHandsImpl(InventoryMode.SERVER, item);
}
void TakeEntityToHandsImpl (InventoryMode mode, EntityAI item)
{
if (!GetGame().IsDedicatedServer() )
{
InventoryLocation il = new InventoryLocation;
il.SetHands(this, item);
//GetInventory().AddInventoryReservationEx(item, il ,GameInventory.c_InventoryReservationTimeoutShortMS);
}
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Hands(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
EntityAI itemInHands = GetHumanInventory().GetEntityInHands();
InventoryLocation src_item = new InventoryLocation;
if (item.GetInventory().GetCurrentInventoryLocation(src_item))
{
if (itemInHands == null)
{
InventoryLocation hand_dst = new InventoryLocation;
hand_dst.SetHands(this, item);
GetHumanInventory().TakeToDst(mode, src_item, hand_dst);
}
else if (GetHumanInventory().CanSwapEntitiesEx(itemInHands, item))
GetInventory().SwapEntities(mode, itemInHands, item);
UpdateInventoryMenu();
}
}
///@} hand juncture
void LocalDestroyEntityInHands ()
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Destroy IH=" + GetHumanInventory().GetEntityInHands());
GetHumanInventory().LocalDestroyEntity(GetHumanInventory().GetEntityInHands());
UpdateInventoryMenu();
}
void PredictiveMoveItemFromHandsToInventory ()
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Stash IH=" + GetHumanInventory().GetEntityInHands());
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] PredictiveMoveItemFromHandsToInventory input data not sent yet, cannot allow another input action");
return;
}
InventoryMode invMode = InventoryMode.PREDICTIVE;
if (NeedInventoryJunctureFromServer( GetHumanInventory().GetEntityInHands(), this, this))
invMode = InventoryMode.JUNCTURE;
//! returns item to previous location, if available
if (GetHumanInventory().GetEntityInHands().m_OldLocation && GetHumanInventory().GetEntityInHands().m_OldLocation.IsValid())
{
InventoryLocation invLoc = new InventoryLocation;
GetHumanInventory().GetEntityInHands().GetInventory().GetCurrentInventoryLocation(invLoc);
//old location is somewhere on player
if (GetHumanInventory().GetEntityInHands().m_OldLocation.GetParent() && GetHumanInventory().GetEntityInHands().m_OldLocation.GetParent().GetHierarchyRootPlayer())
{
if (GetHumanInventory().LocationCanMoveEntity(invLoc, GetHumanInventory().GetEntityInHands().m_OldLocation))
{
if (GetHumanInventory().TakeToDst(invMode, invLoc,GetHumanInventory().GetEntityInHands().m_OldLocation))
{
UpdateInventoryMenu();
return;
}
}
}
}
GetHumanInventory().TakeEntityToInventory(invMode, FindInventoryLocationType.ATTACHMENT | FindInventoryLocationType.CARGO, GetHumanInventory().GetEntityInHands());
UpdateInventoryMenu();
}
///@{ !hand -> !hand replace
protected bool ReplaceItemWithNewImpl(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace !HND lambda=" + lambda.DumpToString());
bool code = GetHumanInventory().ReplaceItemWithNew(mode, lambda);
UpdateInventoryMenu();
return code;
}
bool LocalReplaceItemWithNew(ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemWithNewImpl(InventoryMode.LOCAL, lambda);
}
bool ServerReplaceItemWithNew(ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemWithNewImpl(InventoryMode.SERVER, lambda);
}
///@} !hand -> !hand replace
///@{ !hand replace -> hand
protected bool ReplaceItemElsewhereWithNewInHandsImpl (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace !HND->HND lambda=" + lambda.DumpToString());
bool code = GetHumanInventory().ReplaceItemElsewhereWithNewInHands(mode, lambda);
UpdateInventoryMenu();
return code;
}
bool LocalReplaceItemElsewhereWithNewInHands (ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemElsewhereWithNewInHandsImpl(InventoryMode.LOCAL, lambda);
}
bool ServerReplaceItemElsewhereWithNewInHands (ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemElsewhereWithNewInHandsImpl(InventoryMode.SERVER, lambda);
}
///@} !hand replace -> hand
///@{ hand replace
protected bool ReplaceItemInHandsWithNewImpl (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace HND->HND lambda=" + lambda.DumpToString());
bool code = GetHumanInventory().ReplaceItemInHandsWithNew(mode, lambda);
UpdateInventoryMenu();
return code;
}
bool LocalReplaceItemInHandsWithNew (ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemInHandsWithNewImpl(InventoryMode.LOCAL, lambda);
}
bool ServerReplaceItemInHandsWithNew (ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemInHandsWithNewImpl(InventoryMode.SERVER, lambda);
}
///@} hand replace
///@{ hand replace2
protected bool ReplaceItemInHandsWithNewElsewhereImpl (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace HND->elsewhere lambda=" + lambda.DumpToString());
bool code = GetHumanInventory().ReplaceItemInHandsWithNewElsewhere(mode, lambda);
UpdateInventoryMenu();
return code;
}
bool LocalReplaceItemInHandsWithNewElsewhere (ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemInHandsWithNewElsewhereImpl(InventoryMode.LOCAL, lambda);
}
bool ServerReplaceItemInHandsWithNewElsewhere (ReplaceItemWithNewLambdaBase lambda)
{
return ReplaceItemInHandsWithNewElsewhereImpl(InventoryMode.SERVER, lambda);
}
///@} hand replace2
///@{ to inv juncture
bool JunctureTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
{
return TakeEntityToInventoryImpl(InventoryMode.JUNCTURE, flags, item);
}
override bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToInventory input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
return JunctureTakeEntityToInventory(flags, item);
else
return TakeEntityToInventoryImpl(InventoryMode.PREDICTIVE, flags, item);
}
override bool LocalTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
{
return TakeEntityToInventoryImpl(InventoryMode.LOCAL, flags, item);
}
override bool ServerTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
{
return TakeEntityToInventoryImpl(InventoryMode.SERVER, flags, item);
}
protected bool TakeEntityToInventoryImpl (InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetHumanInventory().TakeEntityToInventory(mode, flags, item);
UpdateInventoryMenu();
return code;
}
///@} to inv juncture
///@{ to cgo juncture
bool JunctureTakeEntityToCargo (notnull EntityAI item)
{
return TakeEntityToCargoImpl(InventoryMode.JUNCTURE, item);
}
override bool PredictiveTakeEntityToCargo (notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToCargo input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
return JunctureTakeEntityToCargo(item);
else
return TakeEntityToCargoImpl(InventoryMode.PREDICTIVE, item);
}
override bool LocalTakeEntityToCargo (notnull EntityAI item)
{
return TakeEntityToCargoImpl(InventoryMode.LOCAL, item);
}
override bool ServerTakeEntityToCargo (notnull EntityAI item)
{
return TakeEntityToCargoImpl(InventoryMode.SERVER, item);
}
protected bool TakeEntityToCargoImpl (InventoryMode mode, notnull EntityAI item)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetHumanInventory().TakeEntityToCargo(mode, item);
UpdateInventoryMenu();
return code;
}
///@} to cgo juncture
///@{ as att juncture
bool JunctureTakeEntityAsAttachment (notnull EntityAI item)
{
return TakeEntityAsAttachmentImpl(InventoryMode.JUNCTURE, item);
}
override bool PredictiveTakeEntityAsAttachment (notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityAsAttachment input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
return JunctureTakeEntityAsAttachment(item);
else
return TakeEntityAsAttachmentImpl(InventoryMode.PREDICTIVE, item);
}
override bool LocalTakeEntityAsAttachment (notnull EntityAI item)
{
return TakeEntityAsAttachmentImpl(InventoryMode.LOCAL, item);
}
override bool ServerTakeEntityAsAttachment (notnull EntityAI item)
{
return TakeEntityAsAttachmentImpl(InventoryMode.SERVER, item);
}
protected bool TakeEntityAsAttachmentImpl (InventoryMode mode, notnull EntityAI item)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Att(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetHumanInventory().TakeEntityAsAttachment(mode, item);
UpdateInventoryMenu();
return code;
}
///@} as att juncture
///@{ as att ex juncture
bool JunctureTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
{
return TakeEntityAsAttachmentExImpl(InventoryMode.JUNCTURE, item, slot);
}
override bool PredictiveTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityAsAttachmentEx input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
return JunctureTakeEntityAsAttachmentEx(item, slot);
else
return TakeEntityAsAttachmentExImpl(InventoryMode.PREDICTIVE, item, slot);
}
override bool LocalTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
{
return TakeEntityAsAttachmentExImpl(InventoryMode.LOCAL, item, slot);
}
override bool ServerTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
{
return TakeEntityAsAttachmentExImpl(InventoryMode.SERVER, item, slot);
}
protected bool TakeEntityAsAttachmentExImpl (InventoryMode mode, notnull EntityAI item, int slot)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetHumanInventory().TakeEntityAsAttachmentEx(mode, item, slot);
UpdateInventoryMenu();
return code;
}
///@} as att ex juncture
///@{ swap juncture
bool JunctureSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
{
return SwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2);
}
bool PredictiveSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveSwapEntities input data not sent yet, cannot allow another input action");
return false;
}
bool need_j1 = NeedInventoryJunctureFromServer(item1, item1.GetHierarchyParent(), item2.GetHierarchyParent());
bool need_j2 = NeedInventoryJunctureFromServer(item2, item2.GetHierarchyParent(), item1.GetHierarchyParent());
if (need_j1 || need_j2)
return SwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2);
else
return SwapEntitiesImpl(InventoryMode.PREDICTIVE, item1, item2);
}
bool LocalSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
{
return SwapEntitiesImpl(InventoryMode.LOCAL, item1, item2);
}
bool ServerSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
{
return SwapEntitiesImpl(InventoryMode.SERVER, item1, item2);
}
protected bool SwapEntitiesImpl (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
{
bool code;
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::SwapImpl(" + typename.EnumToString(InventoryMode, mode) + ") item1=" + Object.GetDebugName(item1) + " item2=" + item2.GetDebugName(this));
if (!GameInventory.CanSwapEntitiesEx(item1, item2))
Error("[inv] (Man@" + this + ") SwapEntitiesImpl - cannot swap items!");
code = GetHumanInventory().SwapEntities(mode, item1, item2);
UpdateInventoryMenu();
if (!code)
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " SwapEntitiesImpl - cannot swap or forceswap");
return code;
}
///@} swap juncture
///@{ ForceSwap juncture
bool JunctureForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
{
return ForceSwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2, item2_dst);
}
bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveForceSwapEntities input data not sent yet, cannot allow another input action");
return false;
}
bool need_j1 = NeedInventoryJunctureFromServer(item1, item1.GetHierarchyParent(), item2.GetHierarchyParent());
bool need_j2 = NeedInventoryJunctureFromServer(item2, item2.GetHierarchyParent(), item1.GetHierarchyParent());
if (need_j1 || need_j2)
return ForceSwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2, item2_dst);
else
return ForceSwapEntitiesImpl(InventoryMode.PREDICTIVE, item1, item2, item2_dst);
}
bool LocalForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
{
return ForceSwapEntitiesImpl(InventoryMode.LOCAL, item1, item2, item2_dst);
}
bool ServerForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
{
return ForceSwapEntitiesImpl(InventoryMode.SERVER, item1, item2, item2_dst);
}
protected bool ForceSwapEntitiesImpl (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
{
bool code = false;
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ForceSwapImpl(" + typename.EnumToString(InventoryMode, mode) + ") item1=" + Object.GetDebugName(item1) + " item2=" + item2.GetDebugName(this));
code = GetHumanInventory().ForceSwapEntities(mode, item1, item2, item2_dst);
UpdateInventoryMenu();
if (!code)
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ForceSwapEntitiesImpl - cannot Forceswap");
return code;
}
///@} ForceSwap juncture
///@{ to target inv juncture
bool JunctureTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
{
return TakeEntityToTargetInventoryImpl(InventoryMode.JUNCTURE, target, flags, item);
}
override bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetInventory input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
return JunctureTakeEntityToTargetInventory(target, flags, item);
else
return TakeEntityToTargetInventoryImpl(InventoryMode.PREDICTIVE, target, flags, item);
}
bool PredictiveTakeOrSwapAttachment( notnull EntityAI item )
{
if( GetInventory().CanAddAttachment( item ) )
{
return PredictiveTakeEntityAsAttachment( item );
}
else
{
for( int i = 0; i < item.GetInventory().GetSlotIdCount(); i++ )
{
int slot_id = item.GetInventory().GetSlotId(i);
EntityAI slot_item = GetInventory().FindAttachment( slot_id );
if( slot_item && GetInventory().CanSwapEntitiesEx( item, slot_item ) )
{
return PredictiveSwapEntities(item, slot_item);
}
}
}
return false;
}
override bool LocalTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
{
return TakeEntityToTargetInventoryImpl(InventoryMode.LOCAL, target, flags, item);
}
protected bool TakeEntityToTargetInventoryImpl (InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2TargetInv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetInventory().TakeEntityToTargetInventory(mode, target, flags, item);
UpdateInventoryMenu();
return code;
}
///@} to target inv juncture
///@{ to target cgo ex juncture
bool JunctureTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
{
return TakeEntityToTargetCargoExImpl(InventoryMode.JUNCTURE, cargo, item, row, col);
}
override bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetCargoEx input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), cargo.GetCargoOwner()))
return JunctureTakeEntityToTargetCargoEx(cargo, item, row, col);
else
return TakeEntityToTargetCargoExImpl(InventoryMode.PREDICTIVE, cargo, item, row, col);
}
override bool LocalTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
{
return TakeEntityToTargetCargoExImpl(InventoryMode.LOCAL, cargo, item, row, col);
}
override bool ServerTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
{
return TakeEntityToTargetCargoExImpl(InventoryMode.SERVER, cargo, item, row, col);
}
protected bool TakeEntityToTargetCargoExImpl (InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetInventory().TakeEntityToTargetCargoEx(mode, cargo, item, row, col);
UpdateInventoryMenu();
return code;
}
///@} to target cgo ex juncture
///@{ to target cgo juncture
bool JunctureTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
{
return TakeEntityToTargetCargoImpl(InventoryMode.JUNCTURE, target, item);
}
override bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetCargo input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
return JunctureTakeEntityToTargetCargo(target, item);
else
return TakeEntityToTargetCargoImpl(InventoryMode.PREDICTIVE, target, item);
}
override bool LocalTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
{
return TakeEntityToTargetCargoImpl(InventoryMode.LOCAL, target, item);
}
override bool ServerTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
{
if (IsAlive())
return TakeEntityToTargetCargoImpl(InventoryMode.SERVER, target, item);
else
return TakeEntityToTargetCargoImpl(InventoryMode.SERVER, target, item);
}
protected bool TakeEntityToTargetCargoImpl (InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Take2TargetCgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetInventory().TakeEntityToTargetInventory(mode, target, FindInventoryLocationType.CARGO, item);
UpdateInventoryMenu();
return code;
}
///@} to target cgo juncture
///@{ to target att ex juncture
bool JunctureTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
{
return TakeEntityToTargetAttachmentExImpl(InventoryMode.JUNCTURE, target, item, slot);
}
override bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetAttachmentEx input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
return JunctureTakeEntityToTargetAttachmentEx(target, item, slot);
else
return TakeEntityToTargetAttachmentExImpl(InventoryMode.PREDICTIVE, target, item, slot);
}
override bool LocalTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
{
return TakeEntityToTargetAttachmentExImpl(InventoryMode.LOCAL, target, item, slot);
}
override bool ServerTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
{
return TakeEntityToTargetAttachmentExImpl(InventoryMode.SERVER, target, item, slot);
}
protected bool TakeEntityToTargetAttachmentExImpl (InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2TargetAtt(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
bool code = GetInventory().TakeEntityAsTargetAttachmentEx(mode, target, item, slot);
UpdateInventoryMenu();
return code;
}
///@} to target att ex juncture
///@{ to target att juncture
bool JunctureTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
{
return TakeEntityToTargetAttachmentImpl(InventoryMode.JUNCTURE, target, item);
}
override bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToTargetAttachment input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
return JunctureTakeEntityToTargetAttachment(target, item);
else
return TakeEntityToTargetAttachmentImpl(InventoryMode.PREDICTIVE, target, item);
}
override bool LocalTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
{
return TakeEntityToTargetAttachmentImpl(InventoryMode.LOCAL, target, item);
}
override bool ServerTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
{
return TakeEntityToTargetAttachmentImpl(InventoryMode.SERVER, target, item);
}
protected bool TakeEntityToTargetAttachmentImpl (InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
{
InventoryLocation il = new InventoryLocation;
if( target.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ATTACHMENT, il) )
{
return TakeEntityToTargetAttachmentExImpl(mode, target, item, il.GetSlot());
}
return false;
}
///@} to target att juncture
///@{ to dst juncture
bool JunctureTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
{
return TakeToDstImpl(InventoryMode.JUNCTURE, src, dst);
}
override bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
{
if (!ScriptInputUserData.CanStoreInputUserData())
{
Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeToDst input data not sent yet, cannot allow another input action");
return false;
}
if (NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
return JunctureTakeToDst(src, dst);
else
return TakeToDstImpl(InventoryMode.PREDICTIVE, src, dst);
}
override bool LocalTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
{
return TakeToDstImpl(InventoryMode.LOCAL, src, dst);
}
override bool ServerTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
{
return TakeToDstImpl(InventoryMode.SERVER, src, dst);
}
protected bool TakeToDstImpl (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
{
if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
bool code = GetHumanInventory().TakeToDst(mode, src, dst);
UpdateInventoryMenu();
return code;
}
///@} to dst juncture
///@} inventory
void JunctureDeleteItem(EntityAI item)
{
}
override bool CanBeSkinned()
{
return true;
}
void UpdateInventoryMenu();
///@{ Stats
//! Registers new stat type for this player.
/*!
\param[in] name The name of the stat type.
*/
proto native bool StatRegister( string name );
//! Gets counter value of the specified stat type.
/*!
\param[in] name The name of the stat type.
*/
proto native float StatGet( string name );
//! Gets counter value as string of the specified stat type.
/*!
\param[in] name The name of the stat type.
\param[out] value A formatted string containing stat value.
*/
proto void StatGetCounter( string name, out string value );
//! Gets counter value as formatted time string of the specified stat type.
/*!
\param[in] name The name of the stat type.
\param[out] value A formatted string containing stat value.
*/
proto void StatGetAsTime( string name, out string value );
//! Updates stat counter with given value.
/*!
\param[in] name The name of the stat type.
\param[in] value The specified value.
*/
proto native void StatUpdate( string name, float value );
//! Updates stat counter by time.
/*!
Use this to measure play time.
\param[in] name The name of the stat type.
*/
proto native void StatUpdateByTime( string name );
//! Updates stat counter by player's actual position.
/*!
Use this to measure player's travelling distance.
\param[in] name The name of the stat type.
*/
proto native void StatUpdateByPosition( string name );
//! Updates stat counter by given position.
/*!
\param[in] name The name of the stat type.
\param[in] pos The specified position.
*/
proto native void StatUpdateByGivenPos( string name, vector pos );
/*! Invokes read stats from server to client.
\note Call this on client when you need update stats.
*/
proto native void StatInvokeUpdate();
/*! Invokes save stats from server to client.
\note Call this on server when you need update stats.
*/
proto native void StatSyncToClient();
///@} Stats
bool IsInventorySoftLocked()
{
return false;
}
void SetInventorySoftLock(bool status);
/// returns true if man is in transport, false otherwise
bool IsInTransport()
{
return Transport.Cast(GetParent()) != null;
}
void StopDeathDarkeningEffect();
bool PhysicalPredictiveDropItem(EntityAI entity, bool heavy_item_only = true);
void SetProcessUIWarning(bool state);
void OnGameplayDataHandlerSync(); //depricated, sync now happens before the player is created, calling of this event still happens for legacy reasons
bool CanPlaceItem(EntityAI item);
};
|