static bool TryUpdateRequirementType <T>(TraitRequirement requirement, int dataId,
                                                 QueryResult result, MARSTraitDataProvider <T> provider)
        {
            if (requirement.Required)
            {
                if (provider.dictionary.TryGetValue(requirement.TraitName, out var traitValues))
                {
                    if (traitValues.TryGetValue(dataId, out var value))
                    {
                        result.SetTrait(requirement.TraitName, value);
                        return(true);
                    }

                    return(false);
                }

                return(false);
            }
            else
            {
                if (provider.dictionary.TryGetValue(requirement.TraitName, out var traitValues))
                {
                    if (traitValues.TryGetValue(dataId, out var value))
                    {
                        result.SetTrait(requirement.TraitName, value);
                    }
                }

                return(true);
            }
        }
        static ProxyTraitRequirements RequirementsForType <T>(string trait)
        {
            var requirement = new TraitRequirement(trait, typeof(T));

            return(new ProxyTraitRequirements(new List <TraitRequirement> {
                requirement
            }));
        }
        void SetTraitRequirement()
        {
            // if we have a condition that is excluding a tag, it can't be a required trait,
            // or else it will filter itself out and never match.
            var required = m_MatchRule != SemanticTagMatchRule.Exclude;

            m_RequiredTraits[0] = new TraitRequirement(m_TraitName, typeof(bool), required);
        }
예제 #4
0
        public bool Equals(TraitRequirement obj)
        {
            if (obj == null)
            {
                return(false);
            }

            return(obj.TraitName == TraitName && obj.Type == Type);
        }
 internal void FillVector2Requirement(TraitRequirement requirement, int dataId, QueryResult result)
 {
     if (requirement.Required)
     {
         var value = Vector2TraitProvider.dictionary[requirement.TraitName][dataId];
         result.SetTrait(requirement.TraitName, value);
     }
     else
     {
         if (!Vector2TraitProvider.dictionary.TryGetValue(requirement.TraitName, out var traitValues))
         {
             return;
         }
         if (traitValues.TryGetValue(dataId, out var value))
         {
             result.SetTrait(requirement.TraitName, value);
         }
     }
 }
        static void FillRequirementType <T>(TraitRequirement requirement, int dataId,
                                            QueryResult result, MARSTraitDataProvider <T> provider)
        {
            if (requirement.Required)
            {
                // if we get an error with any of the dictionary access here, that means something
                // went wrong in the trait filtering stage, which should ensure that this
                // trait, with this type & data ID, is present in the database.
                var value = provider.dictionary[requirement.TraitName][dataId];
                result.SetTrait(requirement.TraitName, value);
            }
            else
            {
                if (!provider.dictionary.TryGetValue(requirement.TraitName, out var traitValues))
                {
                    return;
                }

                if (traitValues.TryGetValue(dataId, out var value))
                {
                    result.SetTrait(requirement.TraitName, value);
                }
            }
        }
예제 #7
0
 public void SetChild2TraitName(string traitName)
 {
     m_RequiredTraits[1] = new TraitRequirement(traitName, typeof(TTrait));
 }
 internal bool UpdateVector2Requirement(TraitRequirement requirement, int dataId, QueryResult result)
 {
     return(TryUpdateRequirementType(requirement, dataId, result, Vector2TraitProvider));
 }
 internal bool UpdateStringRequirement(TraitRequirement requirement, int dataId, QueryResult result)
 {
     return(TryUpdateRequirementType(requirement, dataId, result, StringTraitProvider));
 }
예제 #10
0
 public SerializedTraitRequirement(TraitRequirement requirement)
 {
     m_TraitName = requirement.TraitName;
     m_TypeName  = requirement.Type.AssemblyQualifiedName;
     m_Required  = requirement.Required;
 }
예제 #11
0
 public virtual void Initialize(int traitIndex)
 {
     traitName           = TraitNameForIndex <T>(traitIndex);
     k_RequiredTraits[0] = new TraitRequirement(traitName, typeof(T));
 }
예제 #12
0
 public void ApplyStats(TraitRequirement to)
 {
     Util.AssignDef(this.def, out to.def);
     to.degree = this.degree;
 }
예제 #13
0
 public TraitRequirementStat(TraitRequirement d)
 {
     Util.AssignDefStat(d.def, out this.def);
     this.degree = d.degree;
 }