Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIDayNightTest.c
Go to the documentation of this file.
1 class SCR_AIDayNightTest : DecoratorScripted
2 {
3  protected TimeAndWeatherManagerEntity m_TimeManager;
4  protected float m_fSunriseTime;
5  protected float m_fSunsetTime;
6 
7  //-------------------------------------------------------------------
8  protected override string GetOnHoverDescription()
9  {
10  return "Returns true during daytime, false otherwise.";
11  }
12 
13  //-------------------------------------------------------------------
14  override void OnInit(AIAgent owner)
15  {
16  ChimeraWorld world = owner.GetWorld();
17  m_TimeManager = world.GetTimeAndWeatherManager();
18  if( !m_TimeManager )
19  {
20  Print("SCR_AIDayNightTest: Could not find a TimeAndWeatherManagerEntity", LogLevel.WARNING);
21  return;
22  }
23 
24  if (!m_TimeManager.GetSunriseHour(m_fSunriseTime) || !m_TimeManager.GetSunsetHour(m_fSunsetTime))
25  m_TimeManager = null; // Set it to null to indicate that we failed to initialize this decorator
26  }
27 
28  //-------------------------------------------------------------------
29  protected override bool TestFunction(AIAgent owner)
30  {
31  if (!m_TimeManager)
32  return false;
33 
34  float currentTime = m_TimeManager.GetTimeOfTheDay();
35 
36  return currentTime > m_fSunriseTime && currentTime < m_fSunsetTime;
37  }
38 };
ChimeraWorld
Definition: ChimeraWorld.c:12
m_TimeManager
SCR_ClockHandComponentClass m_TimeManager
m_fSunsetTime
protected float m_fSunsetTime
Definition: SCR_MapLightUI.c:41
SCR_AIDayNightTest
Definition: SCR_AIDayNightTest.c:1
m_fSunriseTime
protected float m_fSunriseTime
Definition: SCR_MapLightUI.c:40