public void MarkSetDataUsedForUpdates(QueryMatchID queryMatchId, HashSet <int> data) { var module = ModuleLoaderCore.instance.GetModule <QueryPipelinesModule>(); if (module == null) { return; } var setPipe = module.GroupPipeline; if (!setPipe.Data.MatchIdToIndex.TryGetValue(queryMatchId, out var setIndex)) { return; } if (SetDataUsedByQueryMatches.ContainsKey(queryMatchId)) { Debug.LogErrorFormat( "Query '{0}' is already using set data. If you wish to mark new data as used, " + "first call UnmarkSetDataUsedForUpdates with this query ID.", queryMatchId); return; } // duplicate input into owned buffer: { var newBuffer = Pools.DataIdHashSets.Get(); newBuffer.Clear(); foreach (var i in data) { newBuffer.Add(i); } data = newBuffer; } SetDataUsedByQueryMatches[queryMatchId] = data; var queryId = queryMatchId.queryID; if (SetDataUsedByQueries.TryGetValue(queryId, out var dataUsedByQuery)) { dataUsedByQuery.Add(data); } else { dataUsedByQuery = new PreviousSetMatches(data.Count); dataUsedByQuery.Add(data); SetDataUsedByQueries[queryId] = dataUsedByQuery; } var memberIndices = setPipe.Data.MemberIndices[setIndex]; var memberData = setPipe.MemberData; foreach (var mi in memberIndices) { var assignedId = memberData.BestMatchDataIds[mi]; var exclusivity = memberData.Exclusivities[mi]; ReserveDataForQueryMatch(assignedId, queryMatchId, exclusivity); } }
internal void ClearQueryData() { DataUsedByQueries.Clear(); DataUsedByQueryMatches.Clear(); SetDataUsedByQueries.Clear(); SetDataUsedByQueryMatches.Clear(); m_QueryDataDirtyStates.Clear(); SharedDataUsersCounter.Clear(); ReservedData.Clear(); }
public void UnmarkSetDataUsedForUpdates(QueryMatchID queryMatchId) { if (SetDataUsedByQueryMatches.TryGetValue(queryMatchId, out var dataUsedByQueryMatch)) { foreach (var id in dataUsedByQueryMatch) { UnreserveDataForQueryMatch(id, queryMatchId); } dataUsedByQueryMatch.Clear(); SetDataUsedByQueryMatches.Remove(queryMatchId); } var queryId = queryMatchId.queryID; if (SetDataUsedByQueries.TryGetValue(queryId, out var dataUsedByQuery)) { dataUsedByQuery.Remove(dataUsedByQueryMatch); if (dataUsedByQuery.Count == 0) { SetDataUsedByQueries.Remove(queryId); } } }