public void Initialize(IMRObject child1, IMRObject child2, string trait1, string trait2) { this.child1 = child1; this.child2 = child2; child1TraitName = trait1; child2TraitName = trait2; }
int Add(QueryMatchID matchId, IMRObject objectRef, Exclusivity exclusivity, int bestMatchDataId, bool isRequired, CachedTraitCollection traitCache, ProxyConditions condition, ProxyTraitRequirements requirements, ConditionRatingsData rating, HashSet <int> matchSet, Dictionary <int, float> flatRatings, QueryResult result) { var index = GetInsertionIndex(); QueryMatchIds[index] = matchId; ObjectReferences[index] = objectRef; Exclusivities[index] = exclusivity; Required[index] = isRequired; BestMatchDataIds[index] = bestMatchDataId; CachedTraits[index] = traitCache; Conditions[index] = condition; TraitRequirements[index] = requirements; RelationMemberships[index] = null; ConditionRatings[index] = rating; ReducedConditionRatings[index] = flatRatings; ConditionMatchSets[index] = matchSet; QueryResults[index] = result; m_Count++; ValidIndices.Add(index); return(index); }
public int Register(QueryMatchID id, IMRObject obj, SetChildArgs args) { var index = Add(id, obj, args.tryBestMatchArgs.exclusivity, (int)ReservedDataIDs.Invalid, args.required, new CachedTraitCollection(args.tryBestMatchArgs.conditions), args.tryBestMatchArgs.conditions, args.TraitRequirements, Pools.ConditionRatings.Get().Initialize(args.tryBestMatchArgs.conditions), Pools.DataIdHashSets.Get(), Pools.Ratings.Get(), new QueryResult { queryMatchId = id }); AcquiringIndices.Add(index); List <int> tempIndices; if (MatchIdToIndex.TryGetValue(id, out tempIndices)) { tempIndices.Add(index); } else { tempIndices = new List <int> { index }; MatchIdToIndex[id] = tempIndices; } return(index); }
bool UnmatchNonRequiredMember(QueryMatchID queryMatchId, IMRObject memberProxy) { var groupData = m_PipelinesModule.GroupPipeline.Data; // fail if this match id doesn't belong to a registered Group if (!groupData.MatchIdToIndex.TryGetValue(queryMatchId, out var groupIndex)) { return(false); } // fail if this match id is not actually assigned any data if (!groupData.UpdatingIndices.Contains(groupIndex)) { return(false); } var memberIndices = groupData.MemberIndices[groupIndex]; var memberData = m_PipelinesModule.GroupPipeline.MemberData; foreach (var mi in memberIndices) { if (memberData.ObjectReferences[mi] == memberProxy) { // fail if it turns out that this member is actually required if (memberData.Required[mi]) { return(false); } // unmark the data previously used by this proxy k_NonRequiredMembersUnMatching[0] = memberProxy; this.UnmarkPartialSetDataUsedForUpdates(queryMatchId, k_NonRequiredMembersUnMatching); // remove all trait values from the member result memberData.QueryResults[mi].Clear(); memberData.BestMatchDataIds[mi] = InvalidDataId; // let the group itself know about the match loss for this proxy var groupResult = groupData.QueryResults[groupIndex]; groupResult.nonRequiredChildrenLost.Clear(); groupResult.nonRequiredChildrenLost.Add(memberProxy); // group update handlers will respond to non-required member match loss groupData.UpdateHandlers[groupIndex]?.Invoke(groupResult); return(true); } } return(false); }
/// <summary> /// Try to find the indices (into the set member data) of both members of a relation /// </summary> /// <param name="queryMatchId">ID of the query match</param> /// <param name="context2">Object reference to the first member</param> /// <param name="context1">Object reference to the second member</param> /// <param name="index1">Index of the first member</param> /// <param name="index2">Index of the second member</param> /// <returns>True if both member's indices are found, false otherwise.</returns> public bool TryGetRelationMemberIndices(QueryMatchID queryMatchId, IMRObject context1, IMRObject context2, out int index1, out int index2) { if (!MatchIdToIndex.TryGetValue(queryMatchId, out var indices)) { index1 = -1; index2 = -1; return(false); } int tempIndex1 = -1, tempIndex2 = -1; foreach (var storageIndex in indices) { var storedContext = ObjectReferences[storageIndex]; if (storedContext == context1) { tempIndex1 = storageIndex; } else if (storedContext == context2) { tempIndex2 = storageIndex; } } if (tempIndex1 > -1 && tempIndex2 > -1) { index1 = tempIndex1; index2 = tempIndex2; return(true); } index1 = -1; index2 = -1; return(false); }
public KnownMember(IMRObject reference, int dataIndex) { DataIndex = dataIndex; Reference = reference; }
/// <summary> /// Revoke the match for a single Proxy in a group, which must not be marked as required. /// </summary> /// <param name="caller">The object that had made a query</param> /// <param name="queryMatchId">The identifier of the query match instance</param> /// <param name="memberProxy">The proxy to unmatch.</param> /// <returns>True if the proxy had a match that it has now given up, false otherwise</returns> internal static bool UnmatchNonRequiredMember(this IUsesSetQueryResults caller, QueryMatchID queryMatchId, IMRObject memberProxy) { return(ISetQueryResultsMethods.UnmatchNonRequiredMember(queryMatchId, memberProxy)); }