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, int[] members, RelationDataPair[] pairs, SetQueryArgs args)
        {
            var index = GetInsertionIndex();

            QueryMatchIds[index] = id;
            SetQueryArgs[index]  = args;
            MemberIndices[index] = members;

            UsedByMatch[index]  = Pools.DataIdHashSets.Get();
            SetMatchData[index] = new SetMatchData()
            {
                dataAssignments = new Dictionary <IMRObject, int>(),
                exclusivities   = new Dictionary <IMRObject, Exclusivity>()
            };

            CachedTraits[index]    = new RelationTraitCache(args.relations);
            Relations[index]       = args.relations;
            RelationRatings[index] = Pools.RelationRatings.Get().Initialize(args.relations);

            RelationIndexPairs[index] = pairs;
            var localPairs = new RelationDataPair[pairs.Length];

            MapGlobalToLocalRelationPairs(members, pairs, localPairs);
            LocalRelationIndexPairs[index] = localPairs;

            QueryResults[index]        = new SetQueryResult(id);
            TimeOuts[index]            = args.commonQueryData.timeOut;
            ReAcquireOnLoss[index]     = args.commonQueryData.reacquireOnLoss;
            Priorities[index]          = args.commonQueryData.priority;
            UpdateMatchInterval[index] = args.commonQueryData.updateMatchInterval;
            LastUpdateCheckTime[index] = 0f;
            AcquireHandlers[index]     = args.onAcquire;
            UpdateHandlers[index]      = args.onMatchUpdate;
            LossHandlers[index]        = args.onLoss;
            TimeoutHandlers[index]     = args.onTimeout;
            // SearchData will be initialized after the initial add

            m_Count++;
            MatchIdToIndex.Add(id, index);
            ValidIndices.Add(index);
            AcquiringIndices.Add(index);
            return(index);
        }
Exemplo n.º 3
0
        public void Register(QueryMatchID id, QueryArgs args)
        {
            if (MatchIdToIndex.ContainsKey(id))
            {
                return; // query is already registered
            }

            var index = GetInsertionIndex();

            QueryMatchIds[index]    = id;
            QueryArgs[index]        = args;
            Exclusivities[index]    = args.exclusivity;
            BestMatchDataIds[index] = (int)ReservedDataIDs.Invalid;

            TimeOuts[index]            = args.commonQueryData.timeOut;
            ReAcquireOnLoss[index]     = args.commonQueryData.reacquireOnLoss;
            Priority[index]            = args.commonQueryData.priority;
            UpdateMatchInterval[index] = args.commonQueryData.updateMatchInterval;

            CachedTraits[index]            = new CachedTraitCollection(args.conditions);
            TraitRequirements[index]       = args.traitRequirements;
            Conditions[index]              = args.conditions;
            ConditionRatings[index]        = Pools.ConditionRatings.Get().Initialize(args.conditions);
            ConditionMatchSets[index]      = Pools.DataIdHashSets.Get();
            ReducedConditionRatings[index] = Pools.Ratings.Get();
            QueryResults[index]            = new QueryResult {
                queryMatchId = id
            };

            AcquireHandlers[index] = args.onAcquire;
            UpdateHandlers[index]  = args.onMatchUpdate;
            LossHandlers[index]    = args.onLoss;
            TimeoutHandlers[index] = args.onTimeout;

            m_Count++;
            ValidIndices.Add(index);
            MatchIdToIndex.Add(id, index);
            AcquiringIndices.Add(index);
        }