コード例 #1
0
        public Command_SetTargetingMode()
        {
            TargetingModeDef targetingMode         = null;
            bool             multiplePawnsSelected = false;

            foreach (Thing thing in Find.Selector.SelectedObjects)
            {
                if (thing.TryGetComp <CompTargetingMode>() != null)
                {
                    if (thing.TryGetComp <CompTargetingMode>().GetTargetingMode() != null)
                    {
                        //single pawn?
                    }
                    else
                    {
                        //multiple pawns?
                        multiplePawnsSelected = true;
                        break;
                    }
                    targetingMode = thing.TryGetComp <CompTargetingMode>().GetTargetingMode();
                }
            }

            icon         = (multiplePawnsSelected) ? SetTargetingModeTex : targetingMode.uiIcon;
            defaultLabel = (multiplePawnsSelected) ? "CommandSetTargetingModeMulti".Translate() : "CommandSetTargetingMode".Translate(targetingMode.LabelCap);
        }
コード例 #2
0
        public void SetTargetingMode(TargetingModeDef targetMode)
        {
            // Actually set the targeting mode
            _targetingMode = targetMode;

            // Set which tick the game will try to reset the mode at
            _resetTargetingModeTick = Find.TickManager.TicksGame + TargModeResetAttemptInterval();
        }
コード例 #3
0
        public static void TryAssignRandomTargetingMode(this Pawn pawn)
        {
            if (TargetingModesSettings.raidersUseTargModes && pawn.TryGetComp <CompTargetingMode>() is CompTargetingMode targetingComp)
            {
                TargetingModeDef newTargetingMode = DefDatabase <TargetingModeDef> .AllDefsListForReading.RandomElementByWeight(t => t.commonality);

                targetingComp.SetTargetingMode(newTargetingMode);
            }
        }
コード例 #4
0
        private string FloatMenuLabel(TargetingModeDef targetingMode)
        {
            string label = targetingMode.LabelCap;

            if (targetingMode.HitChanceFactor != 1f)
            {
                label += $" (x{targetingMode.HitChanceFactor.ToStringPercent()} Acc)";
            }
            return(label);
        }
コード例 #5
0
 public static BodyPartRecord RerollBodyPart(TargetingModeDef targetingMode, BodyPartRecord bodyPart, DamageDef damDef, BodyPartHeight height, BodyPartDepth depth, Pawn pawn, Thing instigator)
 {
     for (int i = 0; i < targetingMode.RerollCount(pawn, instigator); i++)
     {
         BodyPartRecord newPart = pawn.health.hediffSet.GetRandomNotMissingPart(damDef, height, depth);
         if (newPart.IsPrioritizedPart(targetingMode))
         {
             return(newPart);
         }
     }
     return(bodyPart);
 }
コード例 #6
0
        public static BodyPartRecord ResolvePrioritizedPart_External(BodyPartRecord part, DamageInfo dinfo, Pawn pawn)
        {
            BodyPartRecord newPart = part;

            if (dinfo.Instigator.CanUseTargetingModes(dinfo.Weapon) && dinfo.Instigator?.TryGetComp <CompTargetingMode>() is CompTargetingMode targetingComp)
            {
                TargetingModeDef targetingMode = targetingComp.GetTargetingMode();
                if (!part.IsPrioritizedPart(targetingMode))
                {
                    newPart = RerollBodyPart(targetingMode, part, dinfo.Def, dinfo.Height, BodyPartDepth.Outside, pawn, dinfo.Instigator);
                }
            }
            return(newPart);
        }
コード例 #7
0
        public static BodyPartRecord ResolvePrioritizedPart(BodyPartRecord part, DamageInfo dinfo, Pawn pawn)
        {
            BodyPartRecord newPart = part;

            if (dinfo.Instigator.CanUseTargetingModes(dinfo.Weapon) && dinfo.Instigator.TryGetComp <CompTargetingMode>() != null)
            {
                CompTargetingMode targetingComp = dinfo.Instigator.TryGetComp <CompTargetingMode>();
                TargetingModeDef  targetingMode = targetingComp.GetTargetingMode();
                if (!part.IsPrioritizedPart(targetingMode))
                {
                    newPart = RerollBodyPart(targetingMode, part, dinfo, pawn);
                }
            }
            return(newPart);
        }
コード例 #8
0
        public Command_SetTargetingMode()
        {
            TargetingModeDef targetingMode         = null;
            bool             multiplePawnsSelected = false;

            foreach (object obj in Find.Selector.SelectedObjects)
            {
                if (obj is ThingWithComps thing && thing.TryGetComp <CompTargetingMode>() is ITargetModeSettable targetModeSettable)
                {
                    if (targetingMode != null && targetingMode != targetModeSettable.GetTargetingMode())
                    {
                        multiplePawnsSelected = true;
                        break;
                    }
                    targetingMode = targetModeSettable.GetTargetingMode();
                }
            }
            icon         = (multiplePawnsSelected) ? SetTargetingModeTex : targetingMode.uiIcon;
            defaultLabel = (multiplePawnsSelected) ? "CommandSetTargetingModeMulti".Translate() : "CommandSetTargetingMode".Translate(targetingMode.LabelCap);
        }
コード例 #9
0
 public static BodyPartRecord RerollBodyPart(TargetingModeDef targetingMode, BodyPartRecord bodyPart, DamageInfo dinfo, Pawn pawn) =>
 RerollBodyPart(targetingMode, bodyPart, dinfo.Def, dinfo.Height, dinfo.Depth, pawn, dinfo.Instigator);
コード例 #10
0
 public static bool IsPrioritizedPart(this BodyPartRecord part, TargetingModeDef targetingMode) =>
 targetingMode.HasNoSpecifiedPartDetails ||
 targetingMode.PartsListContains(part.def) ||
 targetingMode.PartsOrAnyChildrenListContains(part) ||
 targetingMode.TagsListContains(part.def.tags);