MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / SetTaskState

Method SetTaskState

ogsr_engine/xrGame/GametaskManager.cpp:113–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void CGameTaskManager::SetTaskState(CGameTask* t, u16 objective_num, ETaskState state)
114{
115 SGameTaskObjective* o = &t->Objective(objective_num);
116 if (o->TaskState() == state)
117 return;
118
119 bool isRoot = (objective_num == 0);
120
121 CMapLocation* ml = o->LinkedMapLocation();
122 bool bActive = ActiveObjective() == o;
123
124 if ((state == eTaskStateFail || state == eTaskStateCompleted || (state == eTaskStateSkiped)) && ml)
125 {
126 Level().MapManager().RemoveMapLocation(o->map_location, o->object_id);
127 o->map_location = NULL;
128 o->object_id = u16(-1);
129 }
130
131 o->SetTaskState(state);
132
133 // highlight next objective if needed
134 if ((isRoot || !t->HasInProgressObjective()) && (ActiveTask() == t))
135 {
136 SetActiveTask("", 1);
137 }
138 // not last
139 else if (!isRoot && bActive /*&& objective_num < (t->m_Objectives.size() - 1)*/)
140 {
141 //SetActiveTask(t->m_ID, objective_num + 1);
142
143 for (size_t i{1}; i < t->m_Objectives.size(); ++i)
144 {
145 if (t->Objective(i).TaskState() == eTaskStateInProgress)
146 {
147 SetActiveTask(t->m_ID, static_cast<u16>(i));
148 break;
149 }
150 }
151 }
152
153 // setState for task and all sub-tasks
154 if (isRoot)
155 {
156 for (u16 i = 0; i < t->m_Objectives.size(); ++i)
157 if (t->Objective(i).TaskState() == eTaskStateInProgress)
158 SetTaskState(t, i, state);
159 }
160 else if (state == eTaskStateCompleted && objective_num < (t->m_Objectives.size() - 1))
161 {
162 // enable hidden locations for next objective
163 SGameTaskObjective& obj = t->Objective(objective_num + 1);
164
165 if (!obj.def_location_enabled && obj.TaskState() == eTaskStateInProgress)
166 {
167 if (obj.object_id != u16(-1) && *obj.map_location)
168 {
169 CMapLocation* ml = Level().MapManager().AddMapLocation(obj.map_location, obj.object_id);
170 if (obj.map_hint.size())

Callers

nothing calls this directly

Calls 15

MsgFunction · 0.85
ObjectiveMethod · 0.80
TaskStateMethod · 0.80
LinkedMapLocationMethod · 0.80
RemoveMapLocationMethod · 0.80
AddMapLocationMethod · 0.80
SetHintMethod · 0.80
DisablePointerMethod · 0.80
SetSerializableMethod · 0.80
UIGameMethod · 0.80
GetUIMethod · 0.80

Tested by

no test coverage detected