XIDCine
Class AlarmFilter

source: C:\XIII\XIDCine\Classes\AlarmFilter.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--XIDCine.AlarmFilter
Direct Known Subclasses:None

class AlarmFilter
extends Engine.Info

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // AlarmFilter Created by iKi //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Variables
 int CurrentIndex

States
STA_FilterOn, STA_FilterOff, STA_init

Function Summary
 void TurnFilterOff()
 void TurnFilterOn()
 void UseCurrentColor()


State STA_FilterOn Function Summary


State STA_FilterOff Function Summary


State STA_init Function Summary



Source Code


00001	//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00002	// AlarmFilter Created by iKi
00003	//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00004	class AlarmFilter extends Info placeable;
00005	
00006	VAR(Filter)	bool	bInitiallyOn;
00007	VAR(Filter)	Array<Color>	Colors;
00008	VAR			Color	NeutralColor;
00009	VAR(Filter)	Array<float>	SpeedToReachColor;
00010	VAR(Filter)	Array<float>	PauseTimeOnColor;
00011	
00012	VAR TRANSIENT	int CurrentIndex;
00013	VAR	TRANSIENT	XIIIPlayerController	PC;
00014	
00015	AUTO STATE STA_init
00016	{
00017	begin:
00018		sleep(0.2);
00019		if (Colors.Length==0)
00020		{
00021			destroy();
00022			stop;
00023		}
00024		do
00025		{
00026			sleep(0.1);
00027			PC=XIIIGameInfo(Level.Game).MapInfo.XIIIController;
00028	//		LOG("----------------------------------"@GetStateName());
00029		} until (PC!=none);
00030	//		if (PC==none) goto ('toto');
00031		if (bInitiallyOn)
00032			TurnFilterOn();
00033		else
00034			TurnFilterOff();
00035		stop;
00036	}
00037	
00038	FUNCTION TurnFilterOff()
00039	{
00040		PC.FilterColorWanted=NeutralColor;
00041		PC.FilterColorSpeed=0.5;
00042		GotoState('STA_FilterOff');
00043	}
00044	
00045	FUNCTION TurnFilterOn()
00046	{
00047		CurrentIndex=0;
00048		UseCurrentColor();
00049		TriggerEvent( event, none, none );
00050		GotoState('STA_FilterOn');
00051	}
00052	
00053	FUNCTION UseCurrentColor()
00054	{
00055		if ( CurrentIndex >= Colors.Length )
00056		{
00057			CurrentIndex=0;
00058			TriggerEvent( event, none, none );
00059		}
00060	//	log("UseCurrentColor"@CurrentIndex);
00061		PC.FilterColorWanted=Colors[CurrentIndex];
00062		if (CurrentIndex<SpeedToReachColor.Length)
00063			PC.FilterColorSpeed=SpeedToReachColor[CurrentIndex];
00064		else
00065			PC.FilterColorSpeed=1.0;
00066	}
00067	
00068	STATE STA_FilterOff
00069	{
00070		EVENT Trigger(Actor a,Pawn p)
00071		{
00072			TurnFilterOn();
00073		}
00074	}
00075	
00076	STATE STA_FilterOn
00077	{
00078		EVENT Tick(float dt)
00079		{
00080			if (PC.FilterColorWanted==PC.FilterColor)
00081			{
00082				if ((CurrentIndex<PauseTimeOnColor.Length) && (PauseTimeOnColor[CurrentIndex]!=0.0))
00083				{
00084					Disable ('Tick');
00085					SetTimer(PauseTimeOnColor[CurrentIndex],false);
00086				}
00087				else
00088				{
00089					CurrentIndex++;
00090					UseCurrentColor();
00091				}
00092	
00093			}
00094		}
00095		EVENT Timer()
00096		{
00097			CurrentIndex++;
00098			UseCurrentColor();
00099			Enable('Tick');
00100		}
00101		EVENT Trigger(Actor a,Pawn p)
00102		{
00103			TurnFilterOff();
00104		}
00105	
00106	}
00107	
00108	
00109	
00110	defaultproperties
00111	{
00112	     NeutralColor=(B=128,G=128,R=128)
00113	     bAlwaysRelevant=True
00114	}

End Source Code