File size: 21,945 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 925 926 927 928 929 930 931 932 933 934 935 936 937 |
enum AnimType
{
FULL_BODY = 1,
ADDITIVE,
}
enum SymptomIDs
{
SYMPTOM_COUGH = 1,
SYMPTOM_VOMIT,
SYMPTOM_BLINDNESS,
SYMPTOM_BULLET_HIT,
SYMPTOM_BLEEDING_SOURCE,
SYMPTOM_BLOODLOSS,
SYMPTOM_SNEEZE,
SYMPTOM_FEVERBLUR,
SYMPTOM_LAUGHTER,
SYMPTOM_UNCONSCIOUS,
SYMPTOM_FREEZE,
SYMPTOM_HOT,
SYMPTOM_PAIN_LIGHT,
SYMPTOM_PAIN_HEAVY,
SYMPTOM_HAND_SHIVER,
};
enum SymptomTypes
{
PRIMARY,
SECONDARY
};
enum EAnimPlayState
{
OK,
POSTPONED,
FAILED,
};
const int DEBUG_PADDING_OFFSET = 2;
const int MAX_QUEUE_SIZE = 5;
class SymptomManager
{
PlayerBase m_Player;
ref map<int, ref SymptomBase> m_AvailableSymptoms;
ref map<int, int> m_ActiveSymptomTypes;//for each type(symptom id), keep track of how many times it is in queue
ref array<ref SymptomBase> m_SymptomQueuePrimary;
ref array<ref SymptomBase> m_SymptomQueueSecondary;
ref map<int , SymptomBase > m_SymptomsUIDs;
ref array<ref Param> m_SymptomQueueServerDbg;
ref array<ref Param> m_SymptomQueueServerDbgPrimary;
ref array<ref Param> m_SymptomQueueServerDbgSecondary;
//ref array<string> m_SymptomQueueSecondaryServerDbg;
ref Timer m_Timer;
int m_ActiveSymptomIndexPrimary = -1;
int m_CurrentCommandID;
const int STORAGE_VERSION = 121;
bool m_ShowDebug = false;
bool m_ShowDebug2 = false;
ref SmptAnimMetaBase m_AnimMeta;
void Init()
{
RegisterSymptom(new CoughSymptom);
RegisterSymptom(new VomitSymptom);
RegisterSymptom(new BlindnessSymptom);
RegisterSymptom(new SneezeSymptom);
RegisterSymptom(new FeverBlurSymptom);
RegisterSymptom(new BloodLoss);
RegisterSymptom(new LaughterSymptom);
RegisterSymptom(new FreezeSymptom);
RegisterSymptom(new HotSymptom);
RegisterSymptom(new PainLightSymptom);
RegisterSymptom(new PainHeavySymptom);
RegisterSymptom(new HandShiversSymptom);
//RegisterSymptom(new BulletHitSymptom);
}
int GetStorageVersion()
{
return STORAGE_VERSION;
}
void AutoactivateSymptoms()
{
if ( GetGame().IsClient() )
{
return;
}
QueueUpSecondarySymptom(SymptomIDs.SYMPTOM_BLOODLOSS);
}
void SymptomManager(PlayerBase player)
{
m_ActiveSymptomTypes = new map<int, int>;
m_SymptomsUIDs = new map<int , SymptomBase >;
m_SymptomQueuePrimary = new array<ref SymptomBase>;
m_SymptomQueueSecondary = new array<ref SymptomBase>;
m_SymptomQueueServerDbg = new array<ref Param>;
m_SymptomQueueServerDbgPrimary = new array<ref Param>;
m_SymptomQueueServerDbgSecondary = new array<ref Param>;
m_AvailableSymptoms = new map<int, ref SymptomBase>;
m_Player = player;
Init();
AutoactivateSymptoms();
}
void OnPlayerKilled()
{
for (int i = 0; i < m_SymptomQueuePrimary.Count(); i++)
{
m_SymptomQueuePrimary.Get(i).OnOwnerKilled();
}
for (i = 0; i < m_SymptomQueueSecondary.Count(); i++)
{
if (m_SymptomQueueSecondary.Get(i)) m_SymptomQueueSecondary.Get(i).OnOwnerKilled();
}
}
SymptomBase GetSymptomByUID(int SYMPTOM_uid)
{
return m_SymptomsUIDs.Get(SYMPTOM_uid);
}
void ~SymptomManager()
{
}
PlayerBase GetPlayer()
{
return m_Player;
}
void RegisterSymptom(SymptomBase Symptom)
{
Symptom.Init(this, m_Player,0);
int id = Symptom.GetType();
if ( m_AvailableSymptoms.Contains(id) )
{
Error("SymptomBase Symptom already registered !");
return;
}
m_AvailableSymptoms.Insert(id, Symptom);
//PrintString("inserting id: "+ToString(id));
}
void OnAnimationFinished(eAnimFinishType type = eAnimFinishType.SUCCESS)
{
if ( m_AnimMeta )
{
m_AnimMeta.AnimFinished(type);
}
}
void OnAnimationStarted()
{
if ( GetCurrentPrimaryActiveSymptom() )
GetCurrentPrimaryActiveSymptom().AnimationStart();
}
int CreateUniqueID()
{
int uid = Math.RandomInt( 1, 2147483647);
if ( !IsUIDUsed(uid) ) return uid;
else return CreateUniqueID();
}
bool IsUIDUsed(int uid)
{
return m_SymptomsUIDs.Contains(uid);
}
string GetSymptomName(int symptom_id)
{
return m_AvailableSymptoms.Get(symptom_id).GetName();
}
SmptAnimMetaBase SpawnAnimMetaObject(int symptom_id)
{
SmptAnimMetaBase animMeta = m_AvailableSymptoms.Get(symptom_id).SpawnAnimMetaObject();
animMeta.m_StateType = symptom_id;
return animMeta;
}
//! Exits a specific Symptom with a given UID
void RequestSymptomExit(int SYMPTOM_uid)
{
if ( m_SymptomsUIDs.Get(SYMPTOM_uid) ) m_SymptomsUIDs.Get(SYMPTOM_uid).RequestDestroy();
}
bool IsSymptomPrimary(int symptom_id)
{
return m_AvailableSymptoms.Get(symptom_id).IsPrimary();
}
void OnInputUserDataReceived(ParamsReadContext ctx)
{
}
int GetCurrentCommandID()
{
return m_CurrentCommandID;
}
void OnTick(float deltatime, int pCurrentCommandID, HumanMovementState movement_state)
{
// pCurrentCommandID might be the initial value, but the system itself requires
// current value, so retrieve the current value from player instead
m_CurrentCommandID = m_Player.GetCurrentCommandID();
if (m_ActiveSymptomIndexPrimary == -1)
{
m_ActiveSymptomIndexPrimary = FindFirstAvailableSymptomIndex();
}
UpdateActiveSymptoms(deltatime);
if ( m_AnimMeta )
{
if ( m_AnimMeta.IsDestroyReqested() )
{
m_AnimMeta = null;
}
}
if ( m_AnimMeta )
{
//anim requested
if ( !m_AnimMeta.IsPlaying() )
{
// not playing yet and not possible to play
SymptomBase symptom = m_AvailableSymptoms.Get( m_AnimMeta.m_StateType );
if ( symptom && !symptom.CanActivate() )
{
m_AnimMeta = null;
}
else if ( m_AnimMeta.PlayRequest() == EAnimPlayState.FAILED )
{
OnAnimationFinished(eAnimFinishType.FAILURE);
}
}
else
{
m_AnimMeta.Update(movement_state);
}
}
#ifdef DIAG_DEVELOPER
#ifndef SERVER //must be here !!!
if ( DiagMenu.GetBool(DiagMenuIDs.MISC_PLAYER_SYMPTOMS_SHOW) )
{
//DisplayDebug(true);
array<ref Param> primary_debug = PrepareClientDebug(m_SymptomQueuePrimary);
array<ref Param> secondary_debug = PrepareClientDebug(m_SymptomQueueSecondary);
DisplayDebug1("Symptoms Client", 50, primary_debug, secondary_debug);
DisplayDebug2("Symptoms Server", 300, m_SymptomQueueServerDbgPrimary, m_SymptomQueueServerDbgSecondary);
ShowAvailableSymptoms();
}
else
{
CleanDebug1("Symptoms Client", 50);
CleanDebug2("Symptoms Server", 300);
CleanAvailableSymptoms();
}
#endif
#endif
}
void SetAnimation(ParamsReadContext ctx)
{
if (m_AnimMeta)
{
// animation meta already exists
// pass
}
else
{
int state_type;
if (ctx.Read(state_type))
{
m_AnimMeta = SpawnAnimMetaObject(state_type);
if (m_AnimMeta)
{
m_AnimMeta.Init(ctx, this, m_Player);
}
}
}
}
void UpdateActiveSymptoms(float deltatime)
{
//if( GetGame().IsClient() && !m_Player.IsPlayer() ) return;
//primary
if ( GetCurrentPrimaryActiveSymptom() )
{
if ( !GetCurrentPrimaryActiveSymptom().IsActivated() )
{
if ( GetCurrentPrimaryActiveSymptom().CanActivate() )
GetCurrentPrimaryActiveSymptom().Activate();
}
if ( GetCurrentPrimaryActiveSymptom().IsActivated() )
{
GetCurrentPrimaryActiveSymptom().Update(deltatime);
}
}
//secondary
for (int i = 0; i < m_SymptomQueueSecondary.Count(); i++)
{
if ( m_SymptomQueueSecondary.Get(i) && !m_SymptomQueueSecondary.Get(i).IsActivated() )
{
m_SymptomQueueSecondary.Get(i).Activate();
}
else
{
if (m_SymptomQueueSecondary.Get(i)) m_SymptomQueueSecondary.Get(i).Update(deltatime);
}
}
}
void OnSymptomExit(SymptomBase Symptom, int uid)
{
bool is_primary;
if ( Symptom )
{
is_primary = Symptom.IsPrimary();
DecreaseSymptomCount(Symptom.GetType());
}
if ( m_SymptomsUIDs.Contains(uid) )
{
m_SymptomsUIDs.Remove(uid);
}
else
{
Debug.LogError("Symptom with this UID does not exist", "PlayerSymptoms");
}
if (is_primary)
{
for (int i = 0; i < m_SymptomQueuePrimary.Count(); i++)
{
if ( m_SymptomQueuePrimary.Get(i) == Symptom )
{
m_SymptomQueuePrimary.RemoveOrdered(i);
break;
}
}
}
else
{
for (i = 0; i < m_SymptomQueueSecondary.Count(); i++)
{
if ( m_SymptomQueueSecondary.Get(i) == Symptom )
{
m_SymptomQueueSecondary.RemoveOrdered(i);
break;
}
}
}
m_ActiveSymptomIndexPrimary = -1;
#ifdef DIAG_DEVELOPER
if ( GetGame() ) SendServerDebugToClient();
#endif
}
int GetSymptomMaxCount(int symptom_id)
{
return m_AvailableSymptoms.Get(symptom_id).GetMaxCount();
}
int GetSymptomCount(int symptom_id)
{
if ( m_ActiveSymptomTypes.Contains(symptom_id) )
return m_ActiveSymptomTypes.Get(symptom_id);
else
return -1;
}
void IncreaseSymptomCount(int symptom_id)
{
if ( m_ActiveSymptomTypes.Contains(symptom_id) )
{
m_ActiveSymptomTypes.Set(symptom_id, m_ActiveSymptomTypes.Get(symptom_id) + 1);
}
else
{
m_ActiveSymptomTypes.Insert(symptom_id, 1);
}
}
void DecreaseSymptomCount(int symptom_id)
{
if ( m_ActiveSymptomTypes.Contains(symptom_id) )
{
if ( m_ActiveSymptomTypes.Get(symptom_id) == 1)
m_ActiveSymptomTypes.Remove(symptom_id);
else
m_ActiveSymptomTypes.Set(symptom_id, m_ActiveSymptomTypes.Get(symptom_id) - 1);
}
}
SymptomBase SpawnSymptom( int symptom_id, int uid = -1 )
{
if ( m_AvailableSymptoms.Get(symptom_id) )
{
SymptomBase Symptom = SymptomBase.Cast(m_AvailableSymptoms.Get(symptom_id).ClassName().ToType().Spawn());
if (uid == -1)
{
uid = CreateUniqueID();
}
Symptom.Init(this, m_Player,uid);
if ( m_SymptomsUIDs.Contains(uid) )
Error("Symptoms: Unique ID already exists !");
m_SymptomsUIDs.Insert(uid, Symptom);
IncreaseSymptomCount(symptom_id);
return Symptom;
}
if ( !Symptom )
{
Error("Symptom not registered");
}
return NULL;
}
void CleanUpPrimaryQueue()
{
for (int i = 0; i < m_SymptomQueuePrimary.Count(); i++)
{
m_SymptomQueuePrimary.Get(i).RequestDestroy();
}
}
SymptomBase QueueUpPrimarySymptom(int symptom_id, int uid = -1)
{
SymptomBase Symptom;
if ((GetSymptomCount(symptom_id) >= GetSymptomMaxCount(symptom_id)) && GetSymptomMaxCount(symptom_id) != -1)
return null;
for ( int i = 0; i < m_SymptomQueuePrimary.Count(); i++ )
{
if ( m_SymptomQueuePrimary.Get(i).CanBeInterupted() && ComparePriority( GetSymptomPriority(symptom_id), m_SymptomQueuePrimary.Get(i).GetPriority() ) == 1 )
{
Symptom = SpawnSymptom( symptom_id, uid );
m_SymptomQueuePrimary.InsertAt(Symptom,i);
if ( m_SymptomQueuePrimary.Count() > MAX_QUEUE_SIZE )
{
m_SymptomQueuePrimary.Get(MAX_QUEUE_SIZE).RequestDestroy();// no need to remove from the array, that's done via Symptom callback on destruct
}
break;
}
}
if ( !Symptom && m_SymptomQueuePrimary.Count() < MAX_QUEUE_SIZE)
{
Symptom = SpawnSymptom( symptom_id, uid );
m_SymptomQueuePrimary.Insert(Symptom);
}
#ifdef DIAG_DEVELOPER
SendServerDebugToClient();
#endif
return Symptom;
}
void QueueUpSecondarySymptom(int symptom_id, int uid = -1)
{
QueueUpSecondarySymptomEx(symptom_id, uid);
}
SymptomBase QueueUpSecondarySymptomEx(int symptom_id, int uid = -1)
{
if ((GetSymptomCount(symptom_id) >= GetSymptomMaxCount(symptom_id)) && GetSymptomMaxCount(symptom_id) != -1)
return null;
if ( m_AvailableSymptoms.Get(symptom_id).IsPrimary() )
return null;
SymptomBase Symptom = SpawnSymptom( symptom_id, uid);
m_SymptomQueueSecondary.Insert(Symptom);
return Symptom;
}
//! Removes a single Symptom
void RemoveSecondarySymptom(int symptom_id)
{
for (int i = 0; i < m_SymptomQueueSecondary.Count();i++)
{
if ( m_SymptomQueueSecondary.Get(i) && m_SymptomQueueSecondary.Get(i).GetType() == symptom_id )
{
m_SymptomQueueSecondary.Get(i).RequestDestroy();
return;
}
}
}
SymptomBase GetCurrentPrimaryActiveSymptom()
{
if ( GetGame().IsServer() )
{
if ( m_ActiveSymptomIndexPrimary >= 0 && m_ActiveSymptomIndexPrimary < m_SymptomQueuePrimary.Count() )
{
if ( m_SymptomQueuePrimary.Get(m_ActiveSymptomIndexPrimary) ) return m_SymptomQueuePrimary.Get(m_ActiveSymptomIndexPrimary);
}
}
if ( !GetGame().IsDedicatedServer() )
{
if ( m_SymptomQueuePrimary.Count() > 0 )
return m_SymptomQueuePrimary.Get(0);
}
return NULL;
}
int FindFirstAvailableSymptomIndex()
{
for (int i = 0; i < m_SymptomQueuePrimary.Count();i++)
{
if ( m_SymptomQueuePrimary.Get(i).CanActivate() )
{
return i;
}
}
return -1;
}
int ComparePriority( int prio1, int prio2 )
{
if ( prio1 > prio2 )
{
return 1;
}
else if ( prio2 > prio1 )
{
return 2;
}
return 0;
}
int GetSymptomPriority(int symptom_id)
{
return m_AvailableSymptoms.Get(symptom_id).GetPriority();
}
void OnRPC(int rpc_type, ParamsReadContext ctx)
{
ctx.Read(CachedObjectsParams.PARAM2_INT_INT);
int symptom_id = CachedObjectsParams.PARAM2_INT_INT.param1;
int uid = CachedObjectsParams.PARAM2_INT_INT.param2;
bool is_primary = m_AvailableSymptoms.Get(symptom_id).IsPrimary();
if ( rpc_type == ERPCs.RPC_PLAYER_SYMPTOM_ON )
{
if ( is_primary )
{
CleanUpPrimaryQueue();
QueueUpPrimarySymptom(symptom_id,uid);
}
else
{
QueueUpSecondarySymptom(symptom_id,uid);
}
}
else if ( rpc_type == ERPCs.RPC_PLAYER_SYMPTOM_OFF )
{
if ( is_primary )
{
CleanUpPrimaryQueue();
}
else
{
RemoveSecondarySymptom( symptom_id );
}
}
}
void OnStoreSave( ParamsWriteContext ctx )
{
array<int> m_SaveQueue = new array<int>;
for ( int i = 0; i < m_SymptomQueuePrimary.Count(); i++ )
{
if ( m_SymptomQueuePrimary.Get(i).IsPersistent() )
{
m_SaveQueue.Insert( m_SymptomQueuePrimary.Get(i).GetType() );
}
}
for ( i = 0; i < m_SymptomQueueSecondary.Count(); i++ )
{
if ( m_SymptomQueueSecondary.Get(i).IsPersistent() )
{
m_SaveQueue.Insert( m_SymptomQueueSecondary.Get(i).GetType() );
}
}
ctx.Write( m_SaveQueue );
}
bool OnStoreLoad( ParamsReadContext ctx, int version )
{
array<int> m_SaveQueue;
if (ctx.Read(m_SaveQueue))
{
for ( int i = 0; i < m_SaveQueue.Count(); i++ )
{
int id = m_SaveQueue.Get(i);
if ( IsSymptomPrimary(id) )
{
QueueUpPrimarySymptom( id );
}
else
{
QueueUpSecondarySymptom( id );
}
}
return true;
}
else
{
return false;
}
}
#ifdef DIAG_DEVELOPER
void OnRPCDebug(int rpc_type, ParamsReadContext ctx)
{
switch (rpc_type)
{
case ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_ON:
{
if (ctx.Read(CachedObjectsParams.PARAM1_INT))
{
if (IsSymptomPrimary(CachedObjectsParams.PARAM1_INT.param1))
{
QueueUpPrimarySymptom(CachedObjectsParams.PARAM1_INT.param1);
}
else
{
QueueUpSecondarySymptom(CachedObjectsParams.PARAM1_INT.param1);
}
}
break;
}
case ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_OFF:
{
if (ctx.Read(CachedObjectsParams.PARAM1_INT))
RequestSymptomExit(CachedObjectsParams.PARAM1_INT.param1);
break;
}
case ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG:
{
int primary_Symptoms_count;
int secondary_Symptoms_count;
int symptom_id;
if (ctx.Read(CachedObjectsParams.PARAM1_INT))
{
primary_Symptoms_count = CachedObjectsParams.PARAM1_INT.param1;
}
if (ctx.Read(CachedObjectsParams.PARAM1_INT))
{
secondary_Symptoms_count = CachedObjectsParams.PARAM1_INT.param1;
}
m_SymptomQueueServerDbg.Clear();
m_SymptomQueueServerDbgPrimary.Clear();
m_SymptomQueueServerDbgSecondary.Clear();
int overall_count = primary_Symptoms_count + secondary_Symptoms_count;
for (int i = 0; i < overall_count ; ++i)
{
Param3<bool, int, int> p3 = new Param3<bool, int, int>(false,0,0);
ctx.Read(p3);
bool is_primary = p3.param1;
if (is_primary)
{
m_SymptomQueueServerDbgPrimary.Insert(p3);// m_SymptomQueueServerDbg.Insert(p3);
}
else
{
m_SymptomQueueServerDbgSecondary.Insert(p3);
}
//PrintString("elements m_SymptomQueueServerDbgPrimary:" + m_SymptomQueueServerDbgPrimary.Count());
//PrintString("elements m_SymptomQueueServerDbgSecondary:" + m_SymptomQueueServerDbgSecondary.Count());
}
/*
for(i = 0; i < secondary_Symptoms_count; i++)
{
ctx.Read(CachedObjectsParams.PARAM1_STRING);
m_SymptomQueueSecondaryServerDbg.Insert(CachedObjectsParams.PARAM1_STRING.param1);
}*/
break;
}
}
}
void SendServerDebugToClient()
{
array<ref Param> debug_list = new array<ref Param>;
Param1<int> p1 = new Param1<int>(0);
Param1<int> p2 = new Param1<int>(0);
p1.param1 = m_SymptomQueuePrimary.Count();
p2.param1 = m_SymptomQueueSecondary.Count();
debug_list.Insert(p1);
debug_list.Insert(p2);
Param3<bool,int,int> p;
bool is_primary;
int symptom_id;
int SYMPTOM_uid;
foreach ( SymptomBase symptom : m_SymptomQueuePrimary )
{
is_primary = symptom.IsPrimary();
symptom_id = symptom.GetType();
SYMPTOM_uid = symptom.GetUID();
p = new Param3<bool,int,int>(is_primary, symptom_id, SYMPTOM_uid );
debug_list.Insert(p);
}
foreach ( SymptomBase secSymptom : m_SymptomQueueSecondary )
{
is_primary = secSymptom.IsPrimary();
symptom_id = secSymptom.GetType();
SYMPTOM_uid = secSymptom.GetUID();
p = new Param3<bool,int,int>(is_primary, symptom_id, SYMPTOM_uid );
debug_list.Insert(p);
}
GetGame().RPC(GetPlayer(), ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG, debug_list, true);
}
void DebugRequestExitSymptom(int SYMPTOM_uid)
{
CachedObjectsParams.PARAM1_INT.param1 = SYMPTOM_uid;
if (GetPlayer())
GetGame().RPCSingleParam(GetPlayer(), ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_OFF, CachedObjectsParams.PARAM1_INT, true, GetPlayer().GetIdentity());
}
array<ref Param> PrepareClientDebug(array<ref SymptomBase> Symptoms)
{
array<ref Param> debug_array = new array<ref Param>;
Param3<bool, int, int> p3;
for (int i = 0; i < Symptoms.Count(); i++)
{
bool is_primary = Symptoms.Get(i).IsPrimary();
int symptom_id = Symptoms.Get(i).GetType();
int SYMPTOM_uid = Symptoms.Get(i).GetUID();
p3 = new Param3<bool,int,int>(is_primary, symptom_id, SYMPTOM_uid );
debug_array.Insert(p3);
}
return debug_array;
}
void DisplayDebug1(string name, int y_offset, array<ref Param> Symptoms_primary, array<ref Param> Symptoms_secondary)
{
string primary;
Param3<bool, int, int> p3 = new Param3<bool, int, int>(false,0,0);
DbgUI.BeginCleanupScope();
DbgUI.Begin(name, 50, y_offset);
DbgUI.Text("Primary: ");
bool is_primary;
int symptom_id;
int SYMPTOM_uid;
string SYMPTOM_name;
for (int i = 0; i < Symptoms_primary.Count(); i++)
{
p3 = Param3<bool, int, int>.Cast(Symptoms_primary.Get(i));
is_primary = p3.param1;
symptom_id = p3.param2;
SYMPTOM_uid = p3.param3;
SYMPTOM_name = GetSymptomName(symptom_id);
primary += SYMPTOM_name + " | ";
}
DbgUI.Text(primary);
DbgUI.Text("Secondary: ");
for (i = 0; i < Symptoms_secondary.Count(); i++)
{
p3 = Param3<bool, int, int>.Cast(Symptoms_secondary.Get(i));
is_primary = p3.param1;
symptom_id = p3.param2;
SYMPTOM_uid = p3.param3;
SYMPTOM_name = GetSymptomName(symptom_id);
DbgUI.Text(SYMPTOM_name);
}
DbgUI.End();
DbgUI.EndCleanupScope();
}
void DisplayDebug2(string name, int y_offset, array<ref Param> Symptoms_primary, array<ref Param> Symptoms_secondary)
{
string primary;
Param3<bool, int, int> p3 = new Param3<bool, int, int>(false,0,0);
DbgUI.BeginCleanupScope();
DbgUI.Begin(name, 50, y_offset);
DbgUI.Text("Primary: ");
bool is_primary;
int symptom_id;
int SYMPTOM_uid;
string SYMPTOM_name;
for (int i = 0; i < Symptoms_primary.Count(); i++)
{
p3 = Param3<bool, int, int>.Cast(Symptoms_primary.Get(i));
is_primary = p3.param1;
symptom_id = p3.param2;
SYMPTOM_uid = p3.param3;
SYMPTOM_name = GetSymptomName(symptom_id);
if (DbgUI.Button( i.ToString() + " " + SYMPTOM_name, 80))
{
DebugRequestExitSymptom(SYMPTOM_uid);
}
}
DbgUI.Text("Secondary: ");
for (i = 0; i < Symptoms_secondary.Count(); i++)
{
p3 = Param3<bool, int, int>.Cast(Symptoms_secondary.Get(i));
is_primary = p3.param1;
symptom_id = p3.param2;
SYMPTOM_uid = p3.param3;
SYMPTOM_name = GetSymptomName(symptom_id);
if (DbgUI.Button( i.ToString() + " " + SYMPTOM_name, 80))
{
DebugRequestExitSymptom(SYMPTOM_uid);
}
}
DbgUI.End();
DbgUI.EndCleanupScope();
}
void ShowAvailableSymptoms()
{
DbgUI.BeginCleanupScope();
DbgUI.Begin("available Symptoms", 300, 50);
for (int i = 0; i < m_AvailableSymptoms.Count(); i++)
{
SymptomBase Symptom = m_AvailableSymptoms.GetElement(i);
string SYMPTOM_name = Symptom.GetName();
int symptom_id = Symptom.GetType();
if (DbgUI.Button( i.ToString() + " " + SYMPTOM_name, 80))
{
DebugRequestActivateSymptom(symptom_id);
}
}
DbgUI.End();
DbgUI.EndCleanupScope();
}
void CleanAvailableSymptoms()
{
DbgUI.BeginCleanupScope();
DbgUI.Begin("available Symptoms", 300, 50);
DbgUI.End();
DbgUI.EndCleanupScope();
}
void CleanDebug1(string name, int y_offset)
{
DbgUI.BeginCleanupScope();
DbgUI.Begin(name, 50, y_offset);
DbgUI.End();
DbgUI.EndCleanupScope();
}
void CleanDebug2(string name, int y_offset)
{
DbgUI.BeginCleanupScope();
DbgUI.Begin(name, 50, y_offset);
DbgUI.End();
DbgUI.EndCleanupScope();
}
void DebugRequestActivateSymptom(int symptom_id)
{
CachedObjectsParams.PARAM1_INT.param1 = symptom_id;
if (GetPlayer())
GetGame().RPCSingleParam(GetPlayer(), ERPCs.DIAG_PLAYER_SYMPTOMS_DEBUG_ON, CachedObjectsParams.PARAM1_INT, true, GetPlayer().GetIdentity());
}
#endif
} |