Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkTriggerCountdownDisplay.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 class SCR_ScenarioFrameworkTriggerCountdownDisplay : SCR_InfoDisplayExtended
4 {
5  protected bool m_bTriggerConditionsStatus;
6  protected int m_iPlayersCountByFactionInside;
7  protected int m_iPlayersCountByFaction;
8  protected float m_fTempTimeSlice;
9  protected float m_fActivationCountdownTimer;
10  protected float m_fTempWaitTime;
11  protected float m_fMinimumPlayersNeededPercentage;
12 
13  protected string m_sPlayerActivationNotificationTitle;
14  protected Widget m_wInfoOverlay;
15  protected Widget m_wCountdownOverlay;
16  protected RichTextWidget m_wCountdown;
17  protected RichTextWidget m_wFlavour;
18 
19  //------------------------------------------------------------------------------------------------
21  override void DisplayStartDraw(IEntity owner)
22  {
23  SCR_CharacterTriggerEntity.s_OnTriggerUpdated.Insert(RetrieveTriggerInfo);
24  SCR_CharacterTriggerEntity.s_OnTriggerUpdatedPlayerNotPresent.Insert(RetrieveCountInsideTrigger);
25  m_wInfoOverlay = m_wRoot.FindAnyWidget("Info");
26  m_wCountdownOverlay = m_wRoot.FindAnyWidget("Countdown");
27  ImageWidget leftFlag = ImageWidget.Cast(m_wRoot.FindAnyWidget("FlagSideBlue"));
28  ImageWidget rightFlag = ImageWidget.Cast(m_wRoot.FindAnyWidget("FlagSideRed"));
29  RichTextWidget leftScore = RichTextWidget.Cast(m_wRoot.FindAnyWidget("ScoreBlue"));
30  RichTextWidget rightScore = RichTextWidget.Cast(m_wRoot.FindAnyWidget("ScoreRed"));
31  RichTextWidget winScore = RichTextWidget.Cast(m_wRoot.FindAnyWidget("TargetScore"));
32  m_wCountdown = RichTextWidget.Cast(m_wRoot.FindAnyWidget("CountdownWin"));
33  m_wFlavour = RichTextWidget.Cast(m_wRoot.FindAnyWidget("FlavourText"));
34  ImageWidget winScoreSideLeft = ImageWidget.Cast(m_wRoot.FindAnyWidget("ObjectiveLeft"));
35  ImageWidget winScoreSideRight = ImageWidget.Cast(m_wRoot.FindAnyWidget("ObjectiveRight"));
36 
37  m_wInfoOverlay.SetVisible(false);
38  leftFlag.SetVisible(false);
39  rightFlag.SetVisible(false);
40  leftScore.SetVisible(false);
41  rightScore.SetVisible(false);
42  winScore.SetVisible(false);
43  winScoreSideLeft.SetVisible(false);
44  winScoreSideRight.SetVisible(false);
45 
46  ShowHUD(false);
47  m_bIsEnabled = false;
48  }
49 
50  //------------------------------------------------------------------------------------------------
52  override void DisplayUpdate(IEntity owner, float timeSlice)
53  {
54  m_fTempTimeSlice += timeSlice;
55  if (m_fTempTimeSlice > 1 && m_fTempWaitTime > -1)
56  UpdateHUD();
57  }
58 
59  //------------------------------------------------------------------------------------------------
61  protected void ShowHUD(bool show)
62  {
63  m_wFlavour.SetVisible(show);
64  m_wCountdown.SetVisible(show);
65  m_wInfoOverlay.SetVisible(show);
66  m_wCountdownOverlay.SetVisible(show);
67  }
68 
69  //------------------------------------------------------------------------------------------------
71  void HandleHUD()
72  {
73  if (m_iPlayersCountByFactionInside > 0)
74  {
75  m_bIsEnabled = true;
76  }
77  else
78  {
79  m_bIsEnabled = false;
80  ShowHUD(false);
81  }
82  }
83 
84  //------------------------------------------------------------------------------------------------
86  void RetrieveTriggerInfo(float activationCountdownTimer, float tempWaitTime, int playersCountByFactionInside, int playersCountByFaction, string playerActivationNotificationTitle, bool triggerConditionsStatus, float minimumPlayersNeededPercentage)
87  {
88  m_bTriggerConditionsStatus = triggerConditionsStatus;
89  m_iPlayersCountByFactionInside = playersCountByFactionInside;
90  m_iPlayersCountByFaction = playersCountByFaction;
91  m_fActivationCountdownTimer = activationCountdownTimer;
92  m_fTempWaitTime = tempWaitTime;
93  m_sPlayerActivationNotificationTitle = playerActivationNotificationTitle;
94  m_fMinimumPlayersNeededPercentage = minimumPlayersNeededPercentage;
95 
96  HandleHUD();
97  }
98 
99  //------------------------------------------------------------------------------------------------
101  void RetrieveCountInsideTrigger(int countInsideTrigger)
102  {
103  if (m_iPlayersCountByFactionInside == 0)
104  return;
105 
106  m_iPlayersCountByFactionInside = countInsideTrigger;
107  HandleHUD();
108  }
109 
110  //------------------------------------------------------------------------------------------------
112  protected void UpdateHUD()
113  {
114  m_fTempTimeSlice = 0;
115 
116  int neededNumber = Math.Ceil(m_iPlayersCountByFaction * m_fMinimumPlayersNeededPercentage);
117  if (neededNumber == 0)
118  neededNumber = 1;
119 
120  string title = string.Format(WidgetManager.Translate(m_sPlayerActivationNotificationTitle), m_iPlayersCountByFactionInside, neededNumber);
121  string formattedTitle = string.Format("<color rgba=\"226,168,80,255\">%1</color>", title);
122 
124  {
125  if (m_iPlayersCountByFactionInside == 0)
126  {
127  ShowHUD(false);
128  return;
129  }
130  m_wFlavour.SetText(formattedTitle);
131  ShowHUD(true);
132  m_wCountdownOverlay.SetVisible(false);
133  return;
134  }
135 
136  string shownTime = SCR_FormatHelper.GetTimeFormatting(m_fTempWaitTime, ETimeFormatParam.DAYS | ETimeFormatParam.HOURS, ETimeFormatParam.DAYS | ETimeFormatParam.HOURS | ETimeFormatParam.MINUTES);
137  m_wCountdown.SetText(shownTime);
138 
139  m_wFlavour.SetText(formattedTitle);
140  ShowHUD(true);
141 
142  if (m_fTempWaitTime <= 0)
143  {
144  ShowHUD(false);
145  m_bIsEnabled = false;
146  }
147  }
148 };
m_wFlavour
protected RichTextWidget m_wFlavour
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:63
m_fTempTimeSlice
protected float m_fTempTimeSlice
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:53
m_wCountdown
protected RichTextWidget m_wCountdown
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:62
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
m_sPlayerActivationNotificationTitle
protected string m_sPlayerActivationNotificationTitle
Definition: SCR_CharacterTriggerEntity.c:53
m_bTriggerConditionsStatus
protected bool m_bTriggerConditionsStatus
Definition: SCR_CharacterTriggerEntity.c:71
m_fActivationCountdownTimer
protected float m_fActivationCountdownTimer
Definition: SCR_CharacterTriggerEntity.c:44
m_fTempWaitTime
protected float m_fTempWaitTime
Definition: SCR_CharacterTriggerEntity.c:65
ETimeFormatParam
ETimeFormatParam
Definition: ETimeFormatParam.c:4
m_fMinimumPlayersNeededPercentage
protected float m_fMinimumPlayersNeededPercentage
Definition: SCR_CharacterTriggerEntity.c:41
m_wInfoOverlay
protected Widget m_wInfoOverlay
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:60
m_bIsEnabled
protected bool m_bIsEnabled
Definition: SCR_BaseSupportStationComponent.c:97
SCR_CharacterTriggerEntity
Definition: SCR_CharacterTriggerEntity.c:17
SCR_ScenarioFrameworkTriggerCountdownDisplay
Definition: SCR_ScenarioFrameworkTriggerCountdownDisplay.c:3
m_wCountdownOverlay
protected Widget m_wCountdownOverlay
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:61
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468