Space Plunder
Loading...
Searching...
No Matches
FPlayerQuestStatus Struct Reference

#include <QuestData.h>

Inheritance diagram for FPlayerQuestStatus:

Public Member Functions

 FPlayerQuestStatus ()
 
TArray< FQuestOutcomeCanQuestsBeCompleted (const UObject *Owner)
 
bool AddObjective (const FQuestObjectives &ObjectiveInfo)
 
bool AddObjectiveToQuests (const FQuestObjectives *Objective)
 
int32 GetNewUniqueID (const FString &QuestID) const
 
int32 StartQuest (const UObject *Owner, FQuestInfo &QuestInfo)
 
void StartObjectives (const UObject *Owner)
 
bool AddObjectiveAmount (const FString &ObjectiveID, const int32 Amount)
 
bool AddObjectiveAmount (const FUniqueID &ObjectiveID, const int32 Amount)
 
bool AddObjectiveFailAmount (const FString &ObjectiveID, const int32 Amount)
 
bool AddObjectiveFailAmount (const FUniqueID &ObjectiveID, const int32 Amount)
 
bool GetQuestObjectivesIDs (const FString &QuestID, TArray< FString > &ObjectiveIDs) const
 
bool GetQuestActiveObjectivesIDs (const FString &QuestID, TArray< FString > &ObjectiveIDs) const
 
bool GetQuestActiveObjectivesIDsWithMarkers (const FUniqueID &QuestID, TArray< FString > &ObjectiveIDs) const
 
bool GetDoesObjectiveHaveWorldMarker (const FString &ObjectiveID) const
 
bool GetQuestIndex (const FQuestInfo &QuestInfo, int32 &Index) const
 
bool GetQuestIndex (const FUniqueID &QuestID, int32 &Index) const
 
bool RemoveQuest (const FQuestInfo &QuestInfo)
 
void CheckObjectives (TArray< FString > ObjectiveIDs)
 
void CheckAllObjectives ()
 
TArray< FString > GetQuestsToBeAddedAfterCompletion (const FString &QuestID)
 
FString GetQuestName (const FString &QuestID)
 
TArray< FString > GetQuestIDs ()
 
TArray< FString > GetObjectiveIDs ()
 
const FQuestObjectivesGetQuestObjectivePtr (const FUniqueID &ObjectiveID) const
 
bool GetActiveQuest (const FUniqueID &QuestID, FQuestInfo &QuestInfo)
 
bool GetIsQuestActive (const FString &QuestID) const
 
bool GetIsQuestActive (const FUniqueID &QuestID) const
 
bool GetIsQuestActive (const int32 QuestIndex) const
 
bool GetQuest (const int32 QuestIndex, FQuestInfo &QuestInfo) const
 
bool GetQuestID (const int32 QuestIndex, FUniqueID &QuestID) const
 
EQuestStatus GetQuestStatus (const FString &QuestID) const
 
int32 GetLevel () const
 
void SaveTimes (const UObject *Owner)
 
void ResumeQuestsAndObjectives ()
 
void UpdateQuestDetails (const FQuestInfo &UpdatedQuestInfo)
 Check if this is worth doing with this or just putting in GameState component.
 
bool UpdateObjectiveDetails (const FQuestObjectives &UpdatedObjectiveInfo)
 
bool UpdateQuestStatus (FQuestOutcome &Outcome)
 
TArray< FQuestInfoFilterQuests (const EQuestStatus QuestFilter)
 
bool IsValid () const
 

Public Attributes

TArray< FQuestInfoActiveQuests
 
int32 Credits = 0
 
int32 Experience = 0
 
int32 MaximumActiveQuests = 999
 

Protected Member Functions

void SaveQuestTimes (const UObject *Owner)
 
void SaveObjectiveTimes (const UObject *Owner)
 

Protected Attributes

TArray< FQuestObjectivesObjectives
 

Private Attributes

bool bValid = true
 

Constructor & Destructor Documentation

◆ FPlayerQuestStatus()

FPlayerQuestStatus::FPlayerQuestStatus ( )
inline
1120{}

Member Function Documentation

◆ AddObjective()

bool FPlayerQuestStatus::AddObjective ( const FQuestObjectives & ObjectiveInfo)
inline

Adds objective to the Objective Array, and any Quests NOTE: add Quest First!

1154 {
1155 const FQuestObjectives* ExistingPtr = Objectives.FindByPredicate(
1156 [&](const FQuestObjectives& Obj)
1157 {
1158 return (Obj.ObjectiveID == ObjectiveInfo.ObjectiveID && Obj.GetUniqueID() == ObjectiveInfo.GetUniqueID());
1159 });
1160
1161 if(ExistingPtr)
1162 {
1163 AddObjectiveToQuests(ExistingPtr);
1164 return true;
1165 }
1166 const int32 Index = Objectives.AddUnique(ObjectiveInfo);
1167 const FQuestObjectives* NewPtr = &Objectives[Index];
1168 AddObjectiveToQuests(NewPtr);
1169 return true;
1170
1171 //@TODO if Objective is not Unique
1172 // const int32 Index = Objectives.AddUnique(ObjectiveInfo);
1173 // TSharedPtr<FQuestObjectives> ObjectivePtr = MakeShared<FQuestObjectives>(Objectives[Index]);
1174 // if(ObjectivePtr == nullptr){return false;}
1175 // AddObjectiveToQuests(ObjectivePtr);
1176 // return true;
1177 }
bool AddObjectiveToQuests(const FQuestObjectives *Objective)
Definition QuestData.h:1179
TArray< FQuestObjectives > Objectives
Definition QuestData.h:1793
Definition QuestData.h:361
FUniqueID GetUniqueID() const
Definition QuestData.h:466
FString ObjectiveID
Definition QuestData.h:365

◆ AddObjectiveAmount() [1/2]

bool FPlayerQuestStatus::AddObjectiveAmount ( const FString & ObjectiveID,
const int32 Amount )
inline
1280 {
1281 bool bCompleted = false;
1282 // Go through each Objective
1283 for(FQuestObjectives& Objective : Objectives)
1284 {
1285 // Ignore complete ones, or Unactive ones //! Potentially redundant before ID check as only the matching ID will work be edited
1286 if(Objective.GetIsComplete() || Objective.GetIsActive() == false){continue;}
1287 //- if It's the Correct ID
1288 if(ObjectiveID == Objective.ObjectiveID)
1289 {
1290 const bool bFinishedObjective = Objective.AddProgress(Amount);
1291 if(bCompleted == false)
1292 {
1293 bCompleted = bFinishedObjective;
1294 }
1295 }
1296 }
1297 return bCompleted;
1298 }

◆ AddObjectiveAmount() [2/2]

bool FPlayerQuestStatus::AddObjectiveAmount ( const FUniqueID & ObjectiveID,
const int32 Amount )
inline
1301 {
1302 bool bCompleted = false;
1303 // Go through each Objective
1304 for(FQuestObjectives& Objective : Objectives)
1305 {
1306 // Ignore complete ones, or Unactive ones //! Potentially redundant before ID check as only the matching ID will work be edited
1307 if(Objective.GetIsComplete() || Objective.GetIsActive() == false){continue;}
1308 //- if It's the Correct ID
1309 if(ObjectiveID == Objective.GetUniqueID())
1310 {
1311 bCompleted = Objective.AddProgress(Amount);
1312 }
1313 }
1314 return bCompleted;
1315 }

◆ AddObjectiveFailAmount() [1/2]

bool FPlayerQuestStatus::AddObjectiveFailAmount ( const FString & ObjectiveID,
const int32 Amount )
inline
1318 {
1319 bool bCompleted = false;
1320 // Go through each Objective
1321 for(FQuestObjectives& Objective : Objectives)
1322 {
1323 // Ignore complete ones, or Unactive ones //! Potentially redundant before ID check as only the matching ID will work be edited
1324 if(Objective.GetIsComplete() || Objective.GetIsActive() == false){continue;}
1325 //- if It's the Correct ID
1326 if(ObjectiveID == Objective.ObjectiveID)
1327 {
1328 bCompleted = Objective.AddFailProgress(Amount);
1329 }
1330 }
1331 return bCompleted;
1332 }

◆ AddObjectiveFailAmount() [2/2]

bool FPlayerQuestStatus::AddObjectiveFailAmount ( const FUniqueID & ObjectiveID,
const int32 Amount )
inline
1334 {
1335 bool bCompleted = false;
1336 // Go through each Objective
1337 for(FQuestObjectives& Objective : Objectives)
1338 {
1339 // Ignore complete ones, or Unactive ones //! Potentially redundant before ID check as only the matching ID will work be edited
1340 if(Objective.GetIsComplete() || Objective.GetIsActive() == false){continue;}
1341 //- if It's the Correct ID
1342 if(ObjectiveID == Objective.GetUniqueID())
1343 {
1344 bCompleted = Objective.AddFailProgress(Amount);
1345 }
1346 }
1347 return bCompleted;
1348 }

◆ AddObjectiveToQuests()

bool FPlayerQuestStatus::AddObjectiveToQuests ( const FQuestObjectives * Objective)
inline
1180 {
1181 if(Objective == nullptr){return false;}
1182 for(auto& Quest : ActiveQuests)
1183 {
1184 //@ TODO Check
1185 if(Quest.bUniqueObjectives && Quest.GetUniqueID().GetUniqueNumber() != Objective->GetUniqueID().GetUniqueNumber())
1186 {
1187 continue;
1188 }
1189 //- @TODO And need to check if Unique
1190 if(Quest.ObjectiveIDs.Contains(Objective->ObjectiveID))
1191 {
1192 const bool bAlreadyAdded = Quest.Status.ObjectiveReferences.ContainsByPredicate(
1193 [&](const FQuestObjectives* Existing)
1194 {
1195 return Existing == Objective;
1196 });
1197
1198 if(!bAlreadyAdded)
1199 {
1200 Quest.Status.ObjectiveReferences.Add(Objective);
1201 }
1202 }
1203 }
1204 return true;
1205 }
TArray< FQuestInfo > ActiveQuests
Definition QuestData.h:1122
int32 GetUniqueNumber() const
Definition BaseData.h:263

◆ CanQuestsBeCompleted()

TArray< FQuestOutcome > FPlayerQuestStatus::CanQuestsBeCompleted ( const UObject * Owner)
inline
1132 {
1134 TArray<FQuestOutcome> AllOutcomes;
1135 for(auto& Quest : ActiveQuests)
1136 {
1137 FQuestOutcome Outcome;
1138 EQuestStatus QuestOutcome;
1139 if(Quest.GetCanBeCompleted(Owner, QuestOutcome))
1140 {
1141 Outcome.Outcome = QuestOutcome;
1142 Outcome.CompletedObjectives = Quest.GetCompletedObjectives();
1143 Outcome.QuestID = Quest.GetUniqueID();
1144 Outcome.QuestName = Quest.QuestName;
1145 AllOutcomes.Add(Outcome);
1146 }
1147 }
1148 return AllOutcomes;
1149 }
EQuestStatus
Definition QuestData.h:57
void SaveTimes(const UObject *Owner)
Definition QuestData.h:1633
Definition QuestData.h:1084
EQuestStatus Outcome
Definition QuestData.h:1094
TArray< FQuestObjectives > CompletedObjectives
Definition QuestData.h:1092
FString QuestName
Definition QuestData.h:1090
FUniqueID QuestID
Definition QuestData.h:1088

◆ CheckAllObjectives()

void FPlayerQuestStatus::CheckAllObjectives ( )
inline

Check to Make sure all Objectives are valid to a quest

1496 {
1497 TArray<FString> ObjectiveIDs;
1498 for(const FQuestInfo& Quest: ActiveQuests)
1499 {
1500 ObjectiveIDs.Append(Quest.ObjectiveIDs);
1501 }
1502
1503 Objectives.RemoveAll([&](const FQuestObjectives& Old)
1504 {
1505 return !ObjectiveIDs.Contains(Old.ObjectiveID);
1506 });
1507 }
Definition QuestData.h:798

◆ CheckObjectives()

void FPlayerQuestStatus::CheckObjectives ( TArray< FString > ObjectiveIDs)
inline

After Removing a Quest, Check if the objectives are needed on other quests

@TODO FIX THIS

1468 {
1469 for(const auto& ObjectiveID : ObjectiveIDs) // {QO_01 QO_02}
1470 {
1471 // Check if any other quest uses this objective
1472 bool bUsedInOtherQuest = false;
1473 for(const FQuestInfo& Quest: ActiveQuests)
1474 {
1476 if(Quest.ObjectiveIDs.Contains(ObjectiveID))
1477 {
1478 bUsedInOtherQuest = true;
1479 }
1480 }
1481 if(bUsedInOtherQuest)
1482 {
1483
1484 }
1485 else
1486 {
1487 Objectives.RemoveAll([&](const FQuestObjectives& Old)
1488 {
1489 return Old.ObjectiveID == ObjectiveID; // uses operator== under the hood
1490 });
1491 }
1492 }
1493 }

◆ FilterQuests()

TArray< FQuestInfo > FPlayerQuestStatus::FilterQuests ( const EQuestStatus QuestFilter)
inline
1759 {
1760 TArray<FQuestInfo> FilteredQuests;
1761 for(auto& Quest : ActiveQuests)
1762 {
1763 if(Quest.GetQuestStatus() == QuestFilter)
1764 {
1765 FilteredQuests.Add(Quest);
1766 }
1767 }
1768 return FilteredQuests;
1769 }

◆ GetActiveQuest()

bool FPlayerQuestStatus::GetActiveQuest ( const FUniqueID & QuestID,
FQuestInfo & QuestInfo )
inline
1556 {
1557 for(const auto& Quest : ActiveQuests)
1558 {
1559 if(Quest.GetUniqueID() == QuestID)
1560 {
1561 QuestInfo = Quest;
1562 return true;
1563 }
1564 }
1565 return false;
1566 }

◆ GetDoesObjectiveHaveWorldMarker()

bool FPlayerQuestStatus::GetDoesObjectiveHaveWorldMarker ( const FString & ObjectiveID) const
inline
1389 {
1390 for(const auto& Objective : Objectives)
1391 {
1392 if(Objective.ObjectiveID == ObjectiveID)
1393 {
1394 return Objective.bHasWorldMarker;
1395 }
1396 }
1397 return false;
1398 }

◆ GetIsQuestActive() [1/3]

bool FPlayerQuestStatus::GetIsQuestActive ( const FString & QuestID) const
inline
1568 {
1569 for(const auto& Quest : ActiveQuests)
1570 {
1571 if(Quest.QuestID == QuestID)
1572 {
1573 return Quest.GetIsActive();
1574 }
1575 }
1576 return false;
1577 }

◆ GetIsQuestActive() [2/3]

bool FPlayerQuestStatus::GetIsQuestActive ( const FUniqueID & QuestID) const
inline
1579 {
1580 for(const auto& Quest : ActiveQuests)
1581 {
1582 if(Quest.GetUniqueID() == QuestID)
1583 {
1584 return Quest.GetIsActive();
1585 }
1586 }
1587 return false;
1588 }

◆ GetIsQuestActive() [3/3]

bool FPlayerQuestStatus::GetIsQuestActive ( const int32 QuestIndex) const
inline
1590 {
1591 if(ActiveQuests.IsValidIndex(QuestIndex))
1592 {
1593 return ActiveQuests[QuestIndex].GetIsActive();
1594 }
1595 return false;
1596 }

◆ GetLevel()

int32 FPlayerQuestStatus::GetLevel ( ) const
inline
1629 {
1630 return FMath::Min(static_cast<int32>(Experience / XP_PER_LEVEL), MAX_SKILL_LEVEL); // Ensure Level does not exceed MaxLevel
1631 }
static int32 XP_PER_LEVEL
Definition BaseData.h:707
static int32 MAX_SKILL_LEVEL
Definition BaseData.h:706
int32 Experience
Definition QuestData.h:1126

◆ GetNewUniqueID()

int32 FPlayerQuestStatus::GetNewUniqueID ( const FString & QuestID) const
inline
1207 {
1208 int32 UniqueID = 1;
1209 for(const auto& Quest :ActiveQuests)
1210 {
1211 if(Quest.QuestID == QuestID)
1212 {
1213 if(UniqueID <= Quest.GetUniqueID().GetUniqueNumber())
1214 {
1215 UniqueID = Quest.GetUniqueID().GetUniqueNumber() + 1;
1216 }
1217 }
1218 }
1219 return UniqueID;
1220 }

◆ GetObjectiveIDs()

TArray< FString > FPlayerQuestStatus::GetObjectiveIDs ( )
inline
1542 {
1543 TArray<FString> ActiveObjectiveIDs;
1544 for (const auto& Objective: Objectives)
1545 {
1546 ActiveObjectiveIDs.Add(Objective.ObjectiveID);
1547 }
1548 return ActiveObjectiveIDs;
1549 }

◆ GetQuest()

bool FPlayerQuestStatus::GetQuest ( const int32 QuestIndex,
FQuestInfo & QuestInfo ) const
inline

Returns if Quest Found

1599 {
1600 if(ActiveQuests.IsValidIndex(QuestIndex))
1601 {
1602 QuestInfo = ActiveQuests[QuestIndex];
1603 return true;
1604 }
1605 return false;
1606 }

◆ GetQuestActiveObjectivesIDs()

bool FPlayerQuestStatus::GetQuestActiveObjectivesIDs ( const FString & QuestID,
TArray< FString > & ObjectiveIDs ) const
inline
1364 {
1365 for(const auto& Quest : ActiveQuests)
1366 {
1367 if(Quest.QuestID == QuestID)
1368 {
1369 ObjectiveIDs = Quest.GetActiveObjectiveIDs();
1370 return true;
1371 }
1372 }
1373 return false;
1374 }

◆ GetQuestActiveObjectivesIDsWithMarkers()

bool FPlayerQuestStatus::GetQuestActiveObjectivesIDsWithMarkers ( const FUniqueID & QuestID,
TArray< FString > & ObjectiveIDs ) const
inline
1377 {
1378 for(const auto& Quest : ActiveQuests)
1379 {
1380 if(Quest.GetUniqueID() == QuestID)
1381 {
1382 ObjectiveIDs = Quest.GetActiveObjectiveIDsWithMarkers();
1383 return true;
1384 }
1385 }
1386 return false;
1387 }

◆ GetQuestID()

bool FPlayerQuestStatus::GetQuestID ( const int32 QuestIndex,
FUniqueID & QuestID ) const
inline
1608 {
1609 if(ActiveQuests.IsValidIndex(QuestIndex))
1610 {
1611 QuestID = ActiveQuests[QuestIndex].GetUniqueID();
1612 return true;
1613 }
1614 return false;
1615 }

◆ GetQuestIDs()

TArray< FString > FPlayerQuestStatus::GetQuestIDs ( )
inline
1533 {
1534 TArray<FString> ActiveQuestIDs;
1535 for (const FQuestInfo& Quest: ActiveQuests)
1536 {
1537 ActiveQuestIDs.Add(Quest.QuestID);
1538 }
1539 return ActiveQuestIDs;
1540 }

◆ GetQuestIndex() [1/2]

bool FPlayerQuestStatus::GetQuestIndex ( const FQuestInfo & QuestInfo,
int32 & Index ) const
inline
1400 {
1401 for(int32 i = 0; i < ActiveQuests.Num(); i++)
1402 {
1403 if(ActiveQuests[i].GetUniqueID() == QuestInfo.GetUniqueID())
1404 {
1405 Index = i;
1406 return true;
1407 }
1408 }
1409 return false;
1410 }
FUniqueID GetUniqueID() const
Definition QuestData.h:918

◆ GetQuestIndex() [2/2]

bool FPlayerQuestStatus::GetQuestIndex ( const FUniqueID & QuestID,
int32 & Index ) const
inline
1412 {
1413 for(int32 i = 0; i < ActiveQuests.Num(); i++)
1414 {
1415 if(ActiveQuests[i].GetUniqueID() == QuestID)
1416 {
1417 Index = i;
1418 return true;
1419 }
1420 }
1421 // if(ActiveQuests.Contains(QuestID))
1422 // {
1423 // const int32 QuestIndex = ActiveQuests.IndexOfByKey(QuestID);
1424 // Index = QuestIndex;
1425 // return true;
1426 // }
1427 return false;
1428 }

◆ GetQuestName()

FString FPlayerQuestStatus::GetQuestName ( const FString & QuestID)
inline
1521 {
1522 for (const FQuestInfo& Quest: ActiveQuests)
1523 {
1524 if(QuestID == Quest.QuestID)
1525 {
1526 return Quest.QuestName;
1527 }
1528 }
1529 return "";
1530 }

◆ GetQuestObjectivePtr()

const FQuestObjectives * FPlayerQuestStatus::GetQuestObjectivePtr ( const FUniqueID & ObjectiveID) const
inline
1551 {
1552 return Objectives.FindByPredicate([&](const FQuestObjectives& Elem){ return Elem.GetUniqueID() == ObjectiveID;});
1553 }

◆ GetQuestObjectivesIDs()

bool FPlayerQuestStatus::GetQuestObjectivesIDs ( const FString & QuestID,
TArray< FString > & ObjectiveIDs ) const
inline

Gets all Objective IDs from Quest

1352 {
1353 for(const auto& Quest : ActiveQuests)
1354 {
1355 if(Quest.QuestID == QuestID)
1356 {
1357 ObjectiveIDs = Quest.ObjectiveIDs;
1358 return true;
1359 }
1360 }
1361 return false;
1362 }

◆ GetQuestStatus()

EQuestStatus FPlayerQuestStatus::GetQuestStatus ( const FString & QuestID) const
inline
1618 {
1619 for(const auto& Quest : ActiveQuests)
1620 {
1621 if(Quest.QuestID == QuestID)
1622 {
1623 return Quest.GetQuestStatus();
1624 }
1625 }
1626 return EQuestStatus::NotStarted;
1627 }

◆ GetQuestsToBeAddedAfterCompletion()

TArray< FString > FPlayerQuestStatus::GetQuestsToBeAddedAfterCompletion ( const FString & QuestID)
inline
1509 {
1510 TArray<FString> QuestsToBeAdded;
1511 for (const FQuestInfo& Quest: ActiveQuests)
1512 {
1513 if(QuestID == Quest.QuestID)
1514 {
1515 QuestsToBeAdded.Append(Quest.QuestsToBeAddedAfterCompletion);
1516 }
1517 }
1518 return QuestsToBeAdded;
1519 }

◆ IsValid()

bool FPlayerQuestStatus::IsValid ( ) const
inline
1773 {
1774 return bValid;
1775 }
bool bValid
Definition QuestData.h:1797

◆ RemoveQuest()

bool FPlayerQuestStatus::RemoveQuest ( const FQuestInfo & QuestInfo)
inline
1431 {
1432 int32 Index = 0;
1433 TArray<FString> ObjectiveIDs;
1434 bool bFound = false;
1435 for(int32 i = 0; i < ActiveQuests.Num(); i++)
1436 {
1437 if(ActiveQuests[i].GetUniqueID() == QuestInfo.GetUniqueID())
1438 {
1439 Index = i;
1440 ObjectiveIDs = ActiveQuests[Index].ObjectiveIDs;
1441 bFound = true;
1442 break;
1443 }
1444 }
1445 if(bFound)
1446 {
1447 ActiveQuests.RemoveAt(Index);
1448 CheckObjectives(ObjectiveIDs);
1449 }
1450 return bFound;
1451 }
void CheckObjectives(TArray< FString > ObjectiveIDs)
Definition QuestData.h:1467

◆ ResumeQuestsAndObjectives()

void FPlayerQuestStatus::ResumeQuestsAndObjectives ( )
inline
1639 {
1640 for(auto& Quest : ActiveQuests)
1641 {
1642 if(Quest.GetIsActive())
1643 {
1644 Quest.ResumeFromElapsedTime();
1645 }
1646 }
1647 for(auto& Objective : Objectives)
1648 {
1649 if(Objective.GetIsActive())
1650 {
1651 Objective.ResumeFromElapsedTime();
1652 }
1653 }
1654 }

◆ SaveObjectiveTimes()

void FPlayerQuestStatus::SaveObjectiveTimes ( const UObject * Owner)
inlineprotected
1785 {
1786 for(auto& Objective : Objectives)
1787 {
1788 Objective.SaveObjectiveTime(Owner);
1789 }
1790 }

◆ SaveQuestTimes()

void FPlayerQuestStatus::SaveQuestTimes ( const UObject * Owner)
inlineprotected
1778 {
1779 for(auto& ActiveQuest : ActiveQuests)
1780 {
1781 ActiveQuest.SaveQuestTime(Owner);
1782 }
1783 }

◆ SaveTimes()

void FPlayerQuestStatus::SaveTimes ( const UObject * Owner)
inline
1634 {
1637 }
void SaveQuestTimes(const UObject *Owner)
Definition QuestData.h:1777
void SaveObjectiveTimes(const UObject *Owner)
Definition QuestData.h:1784

◆ StartObjectives()

void FPlayerQuestStatus::StartObjectives ( const UObject * Owner)
inline
1247 {
1248 for(auto& ActiveQuest : ActiveQuests)
1249 {
1250 //- If We have unique Objectives, Update them with the Unique progress
1251 if(ActiveQuest.bUniqueObjectives)
1252 {
1253 for(auto& Objective : Objectives)
1254 {
1255 if(ActiveQuest.ObjectiveIDs.Contains(Objective.ObjectiveID))
1256 {
1257 if(ActiveQuest.GetUniqueID().GetUniqueNumber() == Objective.GetUniqueID().GetUniqueNumber())
1258 {
1259 Objective.StartObjective(Owner, ActiveQuest.GetTotalProgress());
1260 }
1261 }
1262 }
1263 }
1264 else
1265 {
1266 for(auto& Objective : Objectives)
1267 {
1268 if(Objective.GetUniqueID().IsUnique()){continue;}
1269 if(ActiveQuest.GetUniqueID().GetUniqueNumber() == Objective.GetUniqueID().GetUniqueNumber())
1270 {
1271 Objective.StartObjective(Owner);
1272 }
1273 }
1274
1275 }
1276 }
1277 }

◆ StartQuest()

int32 FPlayerQuestStatus::StartQuest ( const UObject * Owner,
FQuestInfo & QuestInfo )
inline

Starts Quest timer and objective timers

1223 {
1224 QuestInfo.StartQuest(Owner);
1225 if(QuestInfo.bUniqueObjectives)
1226 {
1227 const int32 UniqueID = GetNewUniqueID(QuestInfo.QuestID);
1228 QuestInfo.SetUniqueID(UniqueID);
1229 return ActiveQuests.Add(QuestInfo);
1230 }
1231 // QuestInfo.GetTotalProgress()
1232
1233 //@ TODO add seperate Objectives function? or should GScomp just start the objectives when they're found from DT ?
1234 // StartObjectives();
1235 for(auto& Objective : Objectives)
1236 {
1237 //@ TODO is there better way to check? is this just 2 for loops?
1238 // if(Objective.ObjectiveID == )
1239 if(QuestInfo.ObjectiveIDs.Contains(Objective.ObjectiveID))
1240 {
1241 Objective.StartObjective(Owner);
1242 }
1243 }
1244 return ActiveQuests.AddUnique(QuestInfo);
1245 }
int32 GetNewUniqueID(const FString &QuestID) const
Definition QuestData.h:1206
bool bUniqueObjectives
Definition QuestData.h:813
TArray< FString > ObjectiveIDs
Definition QuestData.h:810
void SetUniqueID(const int32 ID)
Definition QuestData.h:914
FString QuestID
Definition QuestData.h:802
void StartQuest(const UObject *Owner)
Definition QuestData.h:952

◆ UpdateObjectiveDetails()

bool FPlayerQuestStatus::UpdateObjectiveDetails ( const FQuestObjectives & UpdatedObjectiveInfo)
inline
1670 {
1671 //- @TODO We need a case for when the objective is new and not in the array of objectives, or when it's not in the array
1672 for(auto& OldObjective : Objectives)
1673 {
1674 if(OldObjective.ObjectiveID == UpdatedObjectiveInfo.ObjectiveID)
1675 {
1676 FQuestObjectives NewObjectiveDetails = UpdatedObjectiveInfo;
1677 NewObjectiveDetails.ObjectiveStatus = OldObjective.ObjectiveStatus;
1678 OldObjective = NewObjectiveDetails;
1679 return true;
1680 }
1681 }
1682 //- Updated Objective Doesn't Exist? Add it to Array
1683 Objectives.Add(UpdatedObjectiveInfo);
1684 return false;
1685
1686 //- @TODO Missing if an Objective gets Deleted
1687
1688
1689 // const int32 ObjectiveIndex = Objectives.Find(UpdatedObjectiveInfo);
1690 // //@TODO if it's not in the Objectives array, add it.
1691 // if(Objectives.IsValidIndex(ObjectiveIndex))
1692 // {
1693 // // BUG NOT FINISHED
1694 //
1695 // Objectives[ObjectiveIndex];
1696 // return true;
1697 // }
1698 // Objectives.Add(UpdatedObjectiveInfo);
1699 // for(auto& Objective : Objectives)
1700 // {
1701 // if(Objective.ObjectiveID == UpdatedObjectiveInfo.ObjectiveID)
1702 // {
1703 // FQuestObjectives NewObjectiveInfo = UpdatedObjectiveInfo;
1704 // NewObjectiveInfo.ObjectiveStatus = Objective.ObjectiveStatus;
1705 // Objective = NewObjectiveInfo;
1706 // }
1707 // }
1708 }
FQuestObjectivesStatus ObjectiveStatus
Definition QuestData.h:410

◆ UpdateQuestDetails()

void FPlayerQuestStatus::UpdateQuestDetails ( const FQuestInfo & UpdatedQuestInfo)
inline

Check if this is worth doing with this or just putting in GameState component.

1658 {
1659 for(auto& OldQuest : ActiveQuests)
1660 {
1661 if(OldQuest.QuestID == UpdatedQuestInfo.QuestID)
1662 {
1663 FQuestInfo NewQuestDetails = UpdatedQuestInfo;
1664 NewQuestDetails.Status = OldQuest.Status;
1665 OldQuest = NewQuestDetails;
1666 }
1667 }
1668 }
FQuestInfoStatus Status
Definition QuestData.h:836

◆ UpdateQuestStatus()

bool FPlayerQuestStatus::UpdateQuestStatus ( FQuestOutcome & Outcome)
inline
1710 {
1711 for(auto& Quest : ActiveQuests)
1712 {
1713 if(Quest.GetUniqueID() == Outcome.QuestID)
1714 {
1715 switch(Outcome.Outcome)
1716 {
1717 case EQuestStatus::NotStarted:
1718 Quest.SetStatus(Outcome.Outcome);
1719 break;
1720 case EQuestStatus::Active:
1721 Quest.SetStatus(Outcome.Outcome);
1722 break;
1723 case EQuestStatus::Completed:
1724 Quest.SetStatus(Outcome.Outcome);
1725 Outcome.Reward = Quest.GetFullQuestReward();
1726 break;
1727 case EQuestStatus::Failed:
1728 if(Quest.bCanQuestFail)
1729 {
1730 Outcome.Reward = Quest.GetFullQuestReward();
1731 Quest.SetStatus(Outcome.Outcome);
1732 }
1733 else
1734 {
1735 return false;
1736 }
1737 break;
1738 case EQuestStatus::Abandoned:
1739 if(Quest.bCanQuestBeAbandoned)
1740 {
1741 Quest.SetStatus(Outcome.Outcome);
1742 }
1743 else
1744 {
1745 return false;
1746 }
1747 break;
1748 case EQuestStatus::NotAvailable:
1749 Quest.SetStatus(Outcome.Outcome);
1750 break;
1751 }
1752 return true;
1753 }
1754 }
1755 return false;
1756 }
FQuestReward Reward
Definition QuestData.h:1096

Member Data Documentation

◆ ActiveQuests

TArray<FQuestInfo> FPlayerQuestStatus::ActiveQuests

◆ bValid

bool FPlayerQuestStatus::bValid = true
private

◆ Credits

int32 FPlayerQuestStatus::Credits = 0

◆ Experience

int32 FPlayerQuestStatus::Experience = 0

◆ MaximumActiveQuests

int32 FPlayerQuestStatus::MaximumActiveQuests = 999

◆ Objectives

TArray<FQuestObjectives> FPlayerQuestStatus::Objectives
protected

The documentation for this struct was generated from the following file: