Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditorTask.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Tasks", description: "Move task.", color: "0 0 255 255")]
5
6class SCR_EditorTask : SCR_ExtendedTask
7{
8 [Attribute(SCR_Enum.GetDefault(ETaskTextType.NONE), UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ETaskTextType))]
9 protected ETaskTextType m_TextType;
10
11 [Attribute("0", category: "Editor Task")]
12 protected int m_iTextIndex;
13
14 [Attribute("0", UIWidgets.ComboBox, "Task completion", "", ParamEnumArray.FromEnum(EEditorTaskCompletionType) )]
16
18
19 protected static int s_iNextAutomatedTaskID = 0;
20 protected const string GENERATED_TASK_PREFIX = "$EDITOR_TASK_";
21
22 //------------------------------------------------------------------------------------------------
28 {
29 m_sLocationName = locationName;
30 }
31
32 //------------------------------------------------------------------------------------------------
38 {
39 return m_sLocationName;
40 }
41
42 //------------------------------------------------------------------------------------------------
47 ETaskTextType GetTextType()
48 {
49 return m_TextType;
50 }
51
52 //------------------------------------------------------------------------------------------------
58 {
59 return m_iTextIndex;
60 }
61
62 //------------------------------------------------------------------------------------------------
68 {
70 }
71
72 //------------------------------------------------------------------------------------------------
81
82 //------------------------------------------------------------------------------------------------
88 {
89 if (m_iTaskCompletionType == newTaskCompletionType)
90 return;
91
92 m_iTaskCompletionType = newTaskCompletionType;
93 }
94
95 //------------------------------------------------------------------------------------------------
96 override void SetTaskState(SCR_ETaskState state)
97 {
98 if (state == GetTaskState())
99 return;
100
101 super.SetTaskState(state);
102
103 string text;
104 ENotification notification;
105 switch (state)
106 {
107 case SCR_ETaskState.CREATED:
108 text = SCR_TextsTaskManagerComponent.TASK_AVAILABLE_TEXT;
109 notification = ENotification.EDITOR_TASK_PLACED;
110 break;
111 case SCR_ETaskState.COMPLETED:
112 text = SCR_TextsTaskManagerComponent.TASK_COMPLETED_TEXT;
113 notification = ENotification.EDITOR_TASK_COMPLETED;
114 break;
115 case SCR_ETaskState.FAILED:
116 text = SCR_TextsTaskManagerComponent.TASK_FAILED_TEXT;
117 notification = ENotification.EDITOR_TASK_FAILED;
118 break;
119 case SCR_ETaskState.CANCELLED:
120 text = SCR_TextsTaskManagerComponent.TASK_CANCELLED_TEXT;
121 notification = ENotification.EDITOR_TASK_CANCELED;
122 break;
123
124 default:
125 return;
126 }
127
128 Rpc_PopUpNotification(text, true);
129 Rpc(Rpc_PopUpNotification, text, true);
130
131 ShowTaskNotification(notification);
132 }
133
134 //------------------------------------------------------------------------------------------------
135 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
136 protected void Rpc_PopUpNotification(string prefix, bool alwaysInEditor)
137 {
138 //--- Get player faction (prioritize respawn faction, because it's defined even when player is waiting for respawn)
139 Faction playerFaction;
140 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
141 if (factionManager)
142 playerFaction = factionManager.GetLocalPlayerFaction();
143
144 if (!playerFaction)
146
147 string playerFactionKey;
148 if (playerFaction)
149 playerFactionKey = playerFaction.GetFactionKey();
150
151 //--- Show notification when player is assigned, of the same faction, or has unlimited editor (i.e., is Game Master)
152 if (IsTaskAssignedTo(SCR_TaskExecutor.FromLocalPlayer()) || GetOwnerFactionKeys().Contains(playerFactionKey) || (alwaysInEditor && !SCR_EditorManagerEntity.IsLimitedInstance()))
153 {
154 //--- SCR_PopUpNotification.GetInstance() is never null, as it creates the instance if it doesn't exist yet
156 }
157 }
158
159 //------------------------------------------------------------------------------------------------
160 protected void ShowPopUpNotification(string subtitle)
161 {
163 }
164
165 //------------------------------------------------------------------------------------------------
170 void ShowTaskNotification(ENotification taskNotification, bool SendOverNetwork = false)
171 {
173 if (!editableTask)
174 return;
175
176 int taskID = Replication.FindItemId(editableTask);
177
178 FactionManager factionManager = GetGame().GetFactionManager();
179 if (!factionManager)
180 return;
181
182 Faction faction = factionManager.GetFactionByKey(GetOwnerFactionKeys()[0]);
183 if (!faction)
184 return;
185
187
188 int factionIndex = factionManager.GetFactionIndex(faction);
189
190 //Send local GM
191 if (!SendOverNetwork)
192 {
193 if (taskNotification == ENotification.EDITOR_TASK_PLACED)
194 GetGame().GetCallqueue().CallLater(DelayedPlacedNotification, 1, false, position, taskID, factionIndex);
195 else
196 SCR_NotificationsComponent.SendLocalUnlimitedEditor(taskNotification, position, taskID, factionIndex);
197 }
198 else
199 {
200 SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(taskNotification, position, taskID, factionIndex);
201 }
202 }
203
204 //------------------------------------------------------------------------------------------------
205 protected void DelayedPlacedNotification(vector position, int taskID, int factionIndex)
206 {
207 SCR_NotificationsComponent.SendLocalUnlimitedEditor(ENotification.EDITOR_TASK_PLACED, position, taskID, factionIndex);
208 }
209
210 //------------------------------------------------------------------------------------------------
211 override void EOnInit(IEntity owner)
212 {
213 super.EOnInit(owner);
214
215 if (Replication.IsClient())
216 return;
217
218 SetTaskID(GENERATED_TASK_PREFIX + s_iNextAutomatedTaskID);
219 s_iNextAutomatedTaskID++;
220 }
221
222 //------------------------------------------------------------------------------------------------
224 {
225 s_iNextAutomatedTaskID--;
226 }
227}
EEditorTaskCompletionType
Way of determening if a task is completed automaticly, manually or always manually (In the latter cas...
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
override void SetTaskState(SCR_ETaskState state)
SCR_ECampaignPopupPriority
Popup message priorities sorted from lowest to highest.
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
vector position
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
LocalizedString m_sLocationName
ETaskTextType GetTextType()
void SetTextIndex(int index)
void SetTaskCompletionType(EEditorTaskCompletionType completionType)
int GetTextIndex()
EEditorTaskCompletionType GetTaskCompletionType()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
void ~SCR_EditorTask()
void SetLocationName(LocalizedString locationName)
void ShowPopUpNotification(string subtitle)
const string GENERATED_TASK_PREFIX
EEditorTaskCompletionType m_iTaskCompletionType
void ShowTaskNotification(ENotification taskNotification, bool SendOverNetwork=false)
void DelayedPlacedNotification(vector position, int taskID, int factionIndex)
void Rpc_PopUpNotification(string prefix, bool alwaysInEditor)
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_ETaskState GetTaskState()
vector GetTaskPosition()
Definition SCR_Task.c:1282
array< string > GetOwnerFactionKeys()
Definition SCR_Task.c:951
void SetTaskID(string taskID)
Definition SCR_Task.c:175
SCR_ETaskState
Definition SCR_Task.c:3
bool IsTaskAssignedTo(SCR_TaskExecutor executor, out SCR_TaskExecutor match=null)
Definition SCR_Task.c:493
string GetTaskName(SCR_Task task)
void SCR_TextsTaskManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Main replication API.
Definition Replication.c:14
static Faction GetLocalMainEntityFaction()
Takes care of dynamic and static onscreen popups.
void PopupMsg(string text, float duration=DEFAULT_DURATION, string text2="", int prio=-1, string param1="", string param2="", string param3="", string param4="", string text2param1="", string text2param2="", string text2param3="", string text2param4="", string sound="", SCR_EPopupMsgFilter category=SCR_EPopupMsgFilter.ALL, WorldTimestamp progressStart=null, WorldTimestamp progressEnd=null)
static SCR_PopUpNotification GetInstance()
override void EOnInit(IEntity owner)
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
Tuple param1
proto bool Contains(T value)