Advertisement
RustyDios

DSL_UIPersonnel_StatusSort

May 18th, 2023
2,383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. simulated function int SortByStatus(StateObjectReference A, StateObjectReference B)
  3. {
  4.     local XComGameState_Unit UnitA, UnitB;
  5.     local string StatusA, StatusB, TimeLabelA, TimeLabelB, TimeValueA, TimeValueB;
  6.     local int RankA, RankB, iTimeValueA, iTimeValueB;
  7.     local EMentalState CurrentMentalStateA, CurrentMentalStateB;
  8.  
  9.     UnitA = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(A.ObjectID));
  10.     UnitB = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(B.ObjectID));
  11.  
  12.     //CANNOT USE THIS AS DOES NOT GATHER ENOUGH DATA EG: TIME
  13.     //StatusA = class'UIUtilities_Strategy'.static.GetPersonnelStatus(UnitA);
  14.     //StatusB = class'UIUtilities_Strategy'.static.GetPersonnelStatus(UnitB);
  15.  
  16.     //THIS GIVES US ALPHABETICAL STATUS, TIME LABEL (DAYS/HRS), VALUE AS AN INT IN HRS?
  17.     UnitA.GetStatusStringsSeparate(StatusA, TimeLabelA, iTimeValueA);
  18.     UnitB.GetStatusStringsSeparate(StatusB, TimeLabelB, iTimeValueB);
  19.  
  20.     //THIS GIVES THE ABOVE BUT ALSO INCLUDES CHL DATA (TIME VALUE HERE IS A USELESS STRING THAT DOESNT COMPARE CORRECTLY)
  21.     class'UIUtilities_Strategy'.static.GetPersonnelStatusSeparate(UnitA, StatusA, TimeLabelA, TimeValueA, -1, false);
  22.     class'UIUtilities_Strategy'.static.GetPersonnelStatusSeparate(UnitB, StatusB, TimeLabelB, TimeValueB, -1, false);
  23.  
  24.     //convert STRING time back into an INT for correct comparrisons
  25.     //iTimeValueA = int(TimeValueA);
  26.     //iTimeValueB = int(TimeValueB);
  27.  
  28.     //GIVES MENTAL STATE AS AN ENUM
  29.     CurrentMentalStateA = UnitA.GetMentalState();
  30.     CurrentMentalStateB = UnitB.GetMentalState();
  31.  
  32.     //SO AVAILIABLE SORT BY RANK STILL
  33.     RankA = UnitA.GetRank();
  34.     RankB = UnitB.GetRank();
  35.  
  36.     //sort by Shaken TO BOTTOM
  37.     if (!UnitA.bIsShaken && UnitB.bIsShaken)
  38.     {
  39.         return m_bFlipSort ? -1 : 1;
  40.     }
  41.     else if (UnitA.bIsShaken && !UnitB.bIsShaken)
  42.     {
  43.         return m_bFlipSort ? 1 : -1;
  44.     }
  45.  
  46.     //sort by status string Alphabetical, A is less than Z
  47.     if( StatusA < StatusB )
  48.     {
  49.         return m_bFlipSort ? -1 : 1;
  50.     }
  51.     else if( StatusA > StatusB )
  52.     {
  53.         return m_bFlipSort ? 1 : -1;
  54.     }
  55.  
  56.     //sort by mental Ready 2, Tired 1, Shaken 0
  57.     if (CurrentMentalStateA > CurrentMentalStateB)
  58.     {
  59.         return m_bFlipSort ? -1 : 1;
  60.     }
  61.     else if (CurrentMentalStateA < CurrentMentalStateB)
  62.     {
  63.         return m_bFlipSort ? 1 : -1;
  64.     }
  65.  
  66.     //sort by time ASCENDING
  67.     if( iTimeValueA < iTimeValueB )
  68.     {
  69.         return m_bFlipSort ? -1 : 1;
  70.     }
  71.     else if( iTimeValueA > iTimeValueB )
  72.     {
  73.         return m_bFlipSort ? 1 : -1;
  74.     }
  75.  
  76.     //sort by rank
  77.     if (class'UISL_SSStatusAutoSort'.default.bSortStatusIncludesRank)
  78.     {
  79.         if( RankA > RankB )
  80.         {
  81.             return m_bFlipSort ? -1 : 1;
  82.         }
  83.         else if( RankA < RankB )
  84.         {
  85.             return m_bFlipSort ? 1 : -1;
  86.         }
  87.     }
  88.    
  89.     return 0;
  90. }
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement