コード例 #1
0
        /// <summary>
        ///     Recursively resolves the entire decision tree. (The lazy non stack friendly way, the trees are not supposed to get
        ///     giant anyway.)
        /// </summary>
        /// <param name="def">Def to set.</param>
        public virtual void Resolve(AbilityUserAIProfileDef def)
        {
            profileDef = def;

            //Debug
            //Log.Message("Resolving for '" + GetType().ToString() + "' for def '" + def.defName + "'");

            foreach (var node in subNodes)
            {
                node.parent = this;
                node.Resolve(def);
            }
        }
 public override void Resolve(AbilityUserAIProfileDef def)
 {
     //Cache all eligible abilities for given def.
     blacklistedTagSet ??= new HashSet <string>(blacklistedTags);
     tagSet ??= new HashSet <string>(tags);
     eligibleAbilities = new List <AbilityAIDef>();
     foreach (var validAbility in def.abilities)
     {
         if (tagSet.IsSubsetOf(validAbility.tags) &&
             !blacklistedTagSet.Overlaps(validAbility.tags))
         {
             eligibleAbilities.Add(validAbility);
         }
     }
     //Log.Message(this + " eligibleAbilities: " + eligibleAbilities.ToStringSafeEnumerable());
     base.Resolve(def);
 }
コード例 #3
0
 /// <summary>
 /// First check on whether a Ability can be used or not. Default implementation have no special criterias.
 /// </summary>
 /// <param name="profileDef">Profile Def to check for.</param>
 /// <param name="pawn">Pawn to check for.</param>
 /// <param name="abilityDef">Ability Def to check for.</param>
 /// <returns>True if Ability can be used. False if not.</returns>
 public virtual bool CanUseAbility(AbilityUserAIProfileDef profileDef, Pawn pawn, AbilityAIDef abilityDef)
 {
     return(true);
 }
コード例 #4
0
 /// <summary>
 /// Checks whether this Profile is valid for the Pawn or not. Returns true if it eligible for use. Default implementation only cares about checking for matching Traits.
 /// </summary>
 /// <param name="profileDef">Profile Def to check for.</param>
 /// <param name="pawn">Pawn to check for.</param>
 /// <returns>True if its eligible. False if not.</returns>
 public virtual bool ValidProfileFor(AbilityUserAIProfileDef profileDef, Pawn pawn)
 {
     //Default implementation only cares about checking for matching Traits.
     return(profileDef.matchingTraits.Count <= 0 || (profileDef.matchingTraits.Count > 0 && profileDef.matchingTraits.Any(traitDef => pawn.story.traits.HasTrait(traitDef))));
 }