muffin v6.19
This commit is contained in:
parent
5bd47e3d16
commit
bb6fd2f2bf
9 changed files with 1167 additions and 77 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Common;
|
||||
using Questionable.Model.Questing;
|
||||
|
@ -260,4 +261,53 @@ internal sealed class AlliedSocietyData
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetTurnInIssuers(ElementId elementId, out uint[] issuerDataIds)
|
||||
{
|
||||
EAlliedSociety commonAlliedSocietyTurnIn = GetCommonAlliedSocietyTurnIn(elementId);
|
||||
if (commonAlliedSocietyTurnIn == EAlliedSociety.None)
|
||||
{
|
||||
issuerDataIds = Array.Empty<uint>();
|
||||
return false;
|
||||
}
|
||||
GetCommonAlliedSocietyNpcs(commonAlliedSocietyTurnIn, out uint[] normalNpcs, out uint[] mountNpcs);
|
||||
if (normalNpcs.Length != 0)
|
||||
{
|
||||
issuerDataIds = normalNpcs;
|
||||
}
|
||||
else if (mountNpcs.Length != 0)
|
||||
{
|
||||
issuerDataIds = mountNpcs;
|
||||
}
|
||||
else
|
||||
{
|
||||
issuerDataIds = Array.Empty<uint>();
|
||||
}
|
||||
return issuerDataIds.Length != 0;
|
||||
}
|
||||
|
||||
public Dictionary<uint, List<QuestId>> GroupQuestsByTurnInIssuer(IEnumerable<QuestId> quests)
|
||||
{
|
||||
Dictionary<uint, List<QuestId>> dictionary = new Dictionary<uint, List<QuestId>>();
|
||||
foreach (QuestId quest in quests)
|
||||
{
|
||||
if (TryGetTurnInIssuers(quest, out uint[] issuerDataIds) && issuerDataIds.Length != 0)
|
||||
{
|
||||
uint key = issuerDataIds[0];
|
||||
if (dictionary.TryGetValue(key, out var value))
|
||||
{
|
||||
value.Add(quest);
|
||||
continue;
|
||||
}
|
||||
int num = 1;
|
||||
List<QuestId> list = new List<QuestId>(num);
|
||||
CollectionsMarshal.SetCount(list, num);
|
||||
Span<QuestId> span = CollectionsMarshal.AsSpan(list);
|
||||
int index = 0;
|
||||
span[index] = quest;
|
||||
dictionary[key] = list;
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue