Fixed GetQuestFromDb failing when accepting a repeatable quest
This commit is contained in:
@@ -659,20 +659,16 @@ public class QuestHelper(
|
||||
*/
|
||||
public Quest GetQuestFromDb(string questId, PmcData pmcData)
|
||||
{
|
||||
// May be a repeatable quest
|
||||
var quest = _databaseService.GetQuests()[questId];
|
||||
if (quest == null)
|
||||
// Maybe a repeatable quest?
|
||||
if (_databaseService.GetQuests().TryGetValue(questId, out var quest))
|
||||
{
|
||||
// Check daily/weekly objects
|
||||
foreach (var repeatableQuest in pmcData.RepeatableQuests)
|
||||
{
|
||||
quest = repeatableQuest.ActiveQuests.FirstOrDefault(r => r.Id == questId);
|
||||
if (quest != null)
|
||||
break;
|
||||
}
|
||||
return quest;
|
||||
}
|
||||
|
||||
return quest;
|
||||
// Check daily/weekly objects
|
||||
return pmcData.RepeatableQuests
|
||||
.SelectMany(x => x.ActiveQuests)
|
||||
.FirstOrDefault(x => x.Id == questId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -50,30 +50,29 @@ namespace SptCommon.Extensions
|
||||
return (T?)cachedProperty.GetValue(obj);
|
||||
}
|
||||
|
||||
public static List<T?> GetAllPropValuesAsList<T>(this object? obj)
|
||||
public static List<object> GetAllPropValuesAsList(this object? obj)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(obj);
|
||||
|
||||
var list = obj.GetType().GetProperties();
|
||||
var result = new List<T?>();
|
||||
var result = new List<object>();
|
||||
|
||||
foreach (var prop in list)
|
||||
{
|
||||
result.Add((T?)prop.GetValue(obj));
|
||||
result.Add(prop.GetValue(obj));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Dictionary<string, T?> GetAllPropsAsDict<T>(this object? obj)
|
||||
public static Dictionary<string, object> GetAllPropsAsDict(this object? obj)
|
||||
{
|
||||
var result = new Dictionary<string, T?>();
|
||||
|
||||
var result = new Dictionary<string, object>();
|
||||
var props = obj.GetType().GetProperties();
|
||||
|
||||
foreach (var prop in props)
|
||||
{
|
||||
result.Add(prop.Name, (T?)prop.GetValue(obj));
|
||||
result.Add(prop.Name, prop.GetValue(obj));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user