Advertisement
MonsOlympus

Plugin_Component.uc

May 29th, 2012
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Copyright 2005-2012 Daniel Batten (MonsOlympus), All Rights Reserved.
  3.  */
  4. class Plugin_Component extends ActorComponent;
  5.  
  6. //var GameInfo Game;        //TODO: Could attach this to GameInfo Components, Track which volume this is in on server side, this list will be smaller than Pawn/Controller
  7.  
  8. var private bool    bActive;
  9. var private float   Tickrate,   //The rate at which ticks are counted.
  10.                     Ticks,      //The amount of lifetime that has passed.
  11.                     Lifetime;   //The total amount of lifetime for this component.
  12.  
  13. simulated function PostBeginPlay()
  14. {
  15.     SetActive(bActive);
  16. }
  17.  
  18. function SetRate(float NewTickRate)
  19. {
  20.     local bool bOldActive;
  21.  
  22.     bOldActive=bActive;
  23.     SetActive(!bActive);
  24.     Tickrate=NewTickRate;
  25.     SetActive(bOldActive);
  26. }
  27.  
  28. function SetLifetime(float NewLifetime)
  29. {
  30.     local bool bOldActive;
  31.     /*local float OldLifetime;
  32.  
  33.     OldLifetime=Lifetime;
  34.     if(NewLifetime > Lifetime){
  35.     //  Lifetime-NewLifetime;
  36.     }else{
  37.  
  38.     }*/
  39.  
  40.     bOldActive=bActive;
  41.     SetActive(!bActive);
  42. //  Tickrate=NewTickRate;
  43.     SetActive(bOldActive);
  44. }
  45.  
  46. function SetActive(bool bOn)
  47. {
  48.     if(Owner != None)
  49.     {
  50.         if(bOn)
  51.             Owner.SetTimer(TickRate, True, 'Timer', Self);
  52.         else
  53.             Owner.ClearTimer('Timer', Self);
  54.     }
  55. }
  56.  
  57. function Timer()
  58. {
  59.     if((Lifetime != 0 && Ticks >= Lifetime) || !bActive)
  60.     {
  61.         Owner.ClearTimer('Timer', Self);
  62.         DetachFromAny();
  63.     }
  64.  
  65. /*  if(TickRate != default.TickRate){SetTimer(default.TickRate, True, 'Timer', Self);}*/
  66.  
  67.     Ticks+=Tickrate;
  68. }
  69.  
  70. defaultproperties
  71. {
  72.     bNeedsUpdateTransform=false
  73.  
  74.     Tickrate=0.01
  75.     Lifetime=10.0
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement