public List <int> attack_animation(AnimTypeKeys type, int distance, AttackAnims anim) { var attack_set = AttackAnimations .FirstOrDefault(x => x.Type.attack_type_match(type, distance)); // If no match, for thrown weapons at 1 range, default down to normal attack if possible if (attack_set == null && type.HasEnumFlag(AnimTypeKeys.ThrownWeapon) && distance == 1) { attack_set = AttackAnimations .FirstOrDefault(x => x.Type.attack_type_match( (type & ~AnimTypeKeys.ThrownWeapon) | AnimTypeKeys.NormalAttack, distance)); } if (attack_set != null) { return(attack_set.attack_animation(anim)); } return(null); }
public bool attack_type_match(AnimTypeKeys type, int distance) { if ((type & ~AnimTypeKeys.DistanceDefined) == (AttackType & ~AnimTypeKeys.DistanceDefined)) { // If this anim type cares about distance if (AttackType.HasEnumFlag(AnimTypeKeys.DistanceDefined)) { if (MinDistance > 0 && distance < MinDistance) { return(false); } else if (MaxDistance > 0 && distance > MaxDistance) { return(false); } } return(true); } return(false); }