public void Modify(QueryMatchID id, int index, SetChildArgs args)
        {
            Assert.IsTrue(MatchIdToIndex.ContainsKey(id) &&
                          QueryMatchIds[index].Equals(id) &&
                          ValidIndices.Contains(index),
                          $"Invalid query match id {id} or invalid index {index}");

            Exclusivities[index]       = args.tryBestMatchArgs.exclusivity;
            Required[index]            = args.required;
            BestMatchDataIds[index]    = (int)ReservedDataIDs.Invalid;
            CachedTraits[index]        = new CachedTraitCollection(args.tryBestMatchArgs.conditions);
            Conditions[index]          = args.tryBestMatchArgs.conditions;
            TraitRequirements[index]   = args.TraitRequirements;
            RelationMemberships[index] = null;
            ConditionRatings[index].Recycle();
            ConditionRatings[index] = Pools.ConditionRatings.Get().Initialize(args.tryBestMatchArgs.conditions);
            ReducedConditionRatings[index].Clear();
            ConditionMatchSets[index].Clear();
            QueryResults[index] = new QueryResult {
                queryMatchId = id
            };

            AcquiringIndices.Add(index);
            UpdatingIndices.Remove(index);
        }
コード例 #2
0
        public bool Remove(QueryMatchID id)
        {
            int index;

            if (!MatchIdToIndex.TryGetValue(id, out index))
            {
                return(false);
            }

            MatchIdToIndex.Remove(id);

            QueryMatchIds[index] = QueryMatchID.NullQuery;
            // the query result can still be in use (by the onLoss event), so we don't pool/recycle it
            QueryResults[index] = null;

            Pools.DataIdHashSets.Recycle(UsedByMatch[index]);
            UsedByMatch[index] = null;

            Pools.RelationTraitCaches.Recycle(CachedTraits[index]);
            CachedTraits[index] = null;
            Pools.RelationRatings.Recycle(RelationRatings[index]);
            RelationRatings[index] = null;

            RelationIndexPairs[index]      = null;
            LocalRelationIndexPairs[index] = null;
            RatingConfigurations[index]    = default(GroupRatingConfiguration);
            SetQueryArgs[index]            = null;

            SearchData[index]?.Dispose();
            SearchData[index]   = null;
            SetMatchData[index] = default;

            TimeOuts[index]            = 0f;
            OrderWeights[index]        = 0f;
            Relations[index]           = null;
            ReAcquireOnLoss[index]     = false;
            Priorities[index]          = default;
            UpdateMatchInterval[index] = 0f;
            LastUpdateCheckTime[index] = 0f;

            AcquireHandlers[index] = null;
            UpdateHandlers[index]  = null;
            LossHandlers[index]    = null;
            TimeoutHandlers[index] = null;

            FreeIndex(index);
            if (UpdatingIndices.Contains(index))
            {
                UpdatingIndices.Remove(index);
            }

            if (AcquiringIndices.Contains(index))
            {
                AcquiringIndices.Remove(index);
            }

            m_Count--;
            return(true);
        }
コード例 #3
0
        public bool Remove(QueryMatchID id)
        {
            int index;

            if (!MatchIdToIndex.TryGetValue(id, out index))
            {
                return(false);
            }

            MatchIdToIndex.Remove(id);

            QueryMatchIds[index] = QueryMatchID.NullQuery;
            QueryArgs[index]     = null;
            // the query result can still be in use (by the onLoss event), so we don't pool/recycle it
            QueryResults[index] = null;

            Pools.TraitCaches.Recycle(CachedTraits[index]);
            CachedTraits[index] = null;
            Pools.ConditionRatings.Recycle(ConditionRatings[index]);
            ConditionRatings[index] = null;

            // these collection members are re-usable, but we null them out so it's clear what data is invalid
            Pools.DataIdHashSets.Recycle(ConditionMatchSets[index]);
            ConditionMatchSets[index] = null;
            Pools.Ratings.Recycle(ReducedConditionRatings[index]);
            ReducedConditionRatings[index] = null;

            Exclusivities[index]    = default(Exclusivity);
            BestMatchDataIds[index] = (int)ReservedDataIDs.Invalid;

            TimeOuts[index]            = 0f;
            Conditions[index]          = null;
            TraitRequirements[index]   = null;
            ReAcquireOnLoss[index]     = false;
            Priority[index]            = MarsEntityPriority.Normal;
            UpdateMatchInterval[index] = 0f;

            AcquireHandlers[index] = null;
            UpdateHandlers[index]  = null;
            LossHandlers[index]    = null;
            TimeoutHandlers[index] = null;

            FreeIndex(index);
            UpdatingIndices.Remove(index);
            AcquiringIndices.Remove(index);
            m_Count--;
            return(true);
        }
コード例 #4
0
        public void Modify(QueryMatchID id, QueryArgs args)
        {
            if (!MatchIdToIndex.TryGetValue(id, out var index))
            {
                return;
            }

            Assert.IsTrue(QueryMatchIds[index].Equals(id),
                          $"{index} mismatch with {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;

            if (!AcquiringIndices.Contains(index))
            {
                AcquiringIndices.Add(index);
            }

            UpdatingIndices.Remove(index);
        }
        public bool Remove(QueryMatchID id, int memberIndex)
        {
            if (!MatchIdToIndex.TryGetValue(id, out var indices))
            {
                return(false);
            }

            Assert.IsTrue(indices.Contains(memberIndex) && QueryMatchIds[memberIndex].Equals(id),
                          $"Unknown index: {memberIndex} or Id mismatch!: {id}");

            QueryMatchIds[memberIndex] = QueryMatchID.NullQuery;

            // the query result can still be in use (by the onLoss event), so we don't pool/recycle it
            QueryResults[memberIndex]     = null;
            ObjectReferences[memberIndex] = null;

            Pools.TraitCaches.Recycle(CachedTraits[memberIndex]);
            CachedTraits[memberIndex] = null;
            Pools.ConditionRatings.Recycle(ConditionRatings[memberIndex]);
            ConditionRatings[memberIndex] = null;

            // these collection members are re-usable, but we null them out so it's clear what data is invalid
            Pools.DataIdHashSets.Recycle(ConditionMatchSets[memberIndex]);
            ConditionMatchSets[memberIndex] = null;
            Pools.Ratings.Recycle(ReducedConditionRatings[memberIndex]);
            ReducedConditionRatings[memberIndex] = null;
            TraitRequirements[memberIndex]       = null;

            Exclusivities[memberIndex]    = default;
            BestMatchDataIds[memberIndex] = (int)ReservedDataIDs.Invalid;
            Conditions[memberIndex]       = null;
            Required[memberIndex]         = false;

            FreeIndex(memberIndex);
            UpdatingIndices.Remove(memberIndex);
            AcquiringIndices.Remove(memberIndex);
            m_Count--;
            indices.Remove(memberIndex);

            return(true);
        }
コード例 #6
0
        public void Modify(int index, int[] members, RelationDataPair[] pairs, SetQueryArgs args)
        {
            Assert.IsTrue(ValidIndices.Contains(index),
                          $"{index} is not valid to modify!");

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

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

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

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

            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;

            if (UpdatingIndices.Contains(index))
            {
                UpdatingIndices.Remove(index);
            }

            if (!AcquiringIndices.Contains(index))
            {
                AcquiringIndices.Add(index);
            }
        }