Esempio n. 1
0
 public bool IsJobPossible()
 {
     if (!IsDummyUsable())
     {
         return(false);
     }
     if (LearningSaturated())
     {
         return(false);
     }
     if (HugsLibUtility.HasDesignation(TargetThingA, CombatTrainingDefOf.TrainCombatDesignation))
     {
         return(true);
     }
     if (pawn.equipment.Primary == null)
     {
         return(HugsLibUtility.HasDesignation(TargetThingA, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly));
     }
     if (HugsLibUtility.HasDesignation(TargetThingA, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly))
     {
         return(pawn.equipment.Primary.def.IsMeleeWeapon);
     }
     if (HugsLibUtility.HasDesignation(TargetThingA, CombatTrainingDefOf.TrainCombatDesignationRangedOnly))
     {
         return(pawn.equipment.Primary.def.IsRangedWeapon);
     }
     return(false);
 }
Esempio n. 2
0
        public ThingWithComps GetNearestTrainingWeapon(Thing currentWeapon)
        {
            ThingWithComps result = null;

            if (currentWeapon?.def.IsMeleeWeapon ?? false)
            {
                result = GetNearestTrainingWeaponMelee();
            }
            if (currentWeapon != null && !currentWeapon.def.IsMeleeWeapon)
            {
                result = GetNearestTrainingWeaponRanged();
            }
            if (currentWeapon == null && !HugsLibUtility.HasDesignation(base.TargetThingA, CombatTrainingDefOf.TrainCombatDesignation))
            {
                if (HugsLibUtility.HasDesignation(base.TargetThingA, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly))
                {
                    result = GetNearestTrainingWeaponMelee();
                }
                else if (HugsLibUtility.HasDesignation(base.TargetThingA, CombatTrainingDefOf.TrainCombatDesignationRangedOnly))
                {
                    result = GetNearestTrainingWeaponRanged();
                }
            }
            if (currentWeapon == null && HugsLibUtility.HasDesignation(base.TargetThingA, CombatTrainingDefOf.TrainCombatDesignation))
            {
                ThingRequest req = ThingRequest.ForGroup(ThingRequestGroup.Weapon);
                result = (ThingWithComps)GenClosest.RegionwiseBFSWorker(base.TargetA.Thing.Position, pawn.Map, req, PathEndMode.OnCell, TraverseParms.For(pawn), (Thing x) => CombatTrainingDefOf.TrainingWeapons.DescendantThingDefs.Contains(x.def) && pawn.CanReserve(x), null, 0, 12, 50f, out int _, RegionType.Set_Passable, ignoreEntirelyForbiddenRegions: true);
            }
            return(result);
        }
        public bool IsValidJobTarget(Thing dummy, Pawn pawn)
        {
            if (pawn == null || dummy == null)
            {
                return(false);
            }
            ThingWithComps primary = pawn.equipment.Primary;

            if (!IsDummyUsable(dummy))
            {
                return(false);
            }
            if (HugsLibUtility.HasDesignation(dummy, CombatTrainingDefOf.TrainCombatDesignation))
            {
                return(true);
            }
            if (HugsLibUtility.HasDesignation(dummy, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly))
            {
                if (primary == null)
                {
                    return(true);
                }
                return(primary.def.IsMeleeWeapon);
            }
            if (HugsLibUtility.HasDesignation(dummy, CombatTrainingDefOf.TrainCombatDesignationRangedOnly))
            {
                if (primary == null)
                {
                    return(false);
                }
                return(primary.def.IsRangedWeapon);
            }
            return(false);
        }
Esempio n. 4
0
 public override AcceptanceReport CanDesignateThing(Thing t)
 {
     if (t != null && IsCombatDummy(t) && !HugsLibUtility.HasDesignation(t, defOf))
     {
         return(true);
     }
     return(false);
 }
 public override void PostMapInit()
 {
     if (HugsLibUtility.HasDesignation((Thing)this, CombatTrainingDefOf.TrainCombatDesignation))
     {
         trainingType = TrainingTypes.Any;
     }
     else if (HugsLibUtility.HasDesignation((Thing)this, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly))
     {
         trainingType = TrainingTypes.Melee;
     }
     else if (HugsLibUtility.HasDesignation((Thing)this, CombatTrainingDefOf.TrainCombatDesignationRangedOnly))
     {
         trainingType = TrainingTypes.Ranged;
     }
 }
 public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
 {
     if (pawn.story.WorkTagIsDisabled(WorkTags.Violent))
     {
         JobFailReason.Is(null, "IsIncapableOfViolence".Translate());
         return(false);
     }
     if (!t.IsForbidden(pawn))
     {
         LocalTargetInfo target = t;
         if (pawn.CanReserve(target, 1, -1, null, forced))
         {
             ThingWithComps startingEquippedWeapon = pawn.equipment.Primary;
             if (startingEquippedWeapon == null)
             {
                 if (HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignation) ||
                     HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly) ||
                     HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignationRangedOnly))
                 {
                     return(true);
                 }
             }
             else if (startingEquippedWeapon.def.IsMeleeWeapon)
             {
                 if (HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignation) ||
                     HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignationMeleeOnly))
                 {
                     return(true);
                 }
             }
             else
             {
                 if (HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignation) ||
                     HugsLibUtility.HasDesignation(t, CombatTrainingDefOf.TrainCombatDesignationRangedOnly))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }