Advertisement
Guest User

Client event optimizations

a guest
Nov 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. //
  2. // Event Table
  3. // Author: McTwist (9845)
  4. // Date: 2017-11-26
  5. //
  6. // Makes it possible for easier access for event variables through a table.
  7. // Some is even replacing existing functionality for increased performance.
  8.  
  9.  
  10. // Register input event
  11. function clientCmdRegisterInputEvent(%class, %name, %targetList)
  12. {
  13.     $InputEvent_Count[%class] += 0;
  14.     if ($InputEvent_Table[%class, %name] $= "")
  15.     {
  16.         $InputEvent_Table[%class, %name] = $InputEvent_Count[%class];
  17.         $InputEvent_Count[%class]++;
  18.     }
  19.     $InputEvent_TargetList[%class, $InputEvent_Table[%class, %name]] = %targetList;
  20.  
  21.     if (SaveBricksGui.isAwake())
  22.     {
  23.         SaveBricks_DownloadText.setText(SaveBricks_DownloadText.getText() + 1);
  24.     }
  25. }
  26.  
  27. // Register output event
  28. function clientCmdRegisterOutputEvent(%class, %name, %a, %b, %c, %d)
  29. {
  30.     %parameterList = %a @ %b @ %c @ %d;
  31.  
  32.     $OutputEvent_Count[%class] += 0;
  33.     if ($OutputEvent_Table[%class, %name] $= "")
  34.     {
  35.         $OutputEvent_Table[%class, %name] = $OutputEvent_Count[%class];
  36.         $InputEvent_Count[%class]++;
  37.     }
  38.     $OutputEvent_parameterList[%class, $OutputEvent_Table[%class, %name]] = %parameterList;
  39.  
  40.     if (SaveBricksGui.isAwake())
  41.     {
  42.         SaveBricks_DownloadText.setText(SaveBricks_DownloadText.getText() + 1);
  43.     }
  44. }
  45.  
  46. // Add NT name on client
  47. function SimGroup::CLIENTaddNTName(%obj, %name)
  48. {
  49.     %obj.NTNameCount += 0;
  50.     if (%obj.NTTable[%name] $= "")
  51.     {
  52.         %obj.NTTable[%name] = %obj.NTNameCount;
  53.         %obj.NTName[%obj.NTNameCount] = %name;
  54.         %obj.NTNameCount++;
  55.     }
  56. }
  57.  
  58. // Remove NT name on client
  59. function SimGroup::CLIENTremoveNTName(%obj, %name)
  60. {
  61.     %obj.NTNameCount += 0;
  62.     if (%obj.NTTable[%name] !$= "")
  63.     {
  64.         // Replace current index with the new name
  65.         if (%obj.NTNameCount > 1)
  66.         {
  67.             %i = %obj.NTTable[%name];
  68.             %moveName = %obj.NTName[%obj.NTNameCount - 1];
  69.             %obj.NTName[%i] = %moveName;
  70.             %obj.NTTable[%moveName] = %i;
  71.         }
  72.  
  73.         // Remove name from table
  74.         %obj.NTTable[%name] = "";
  75.         %obj.NTName[%obj.NTNameCount - 1] = "";
  76.         %obj.NTNameCount--;
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement