private void UnforbidAdjacentThingsTo(IntVec3 center, Map map)
 {
     foreach (var offset in GenAdj.AdjacentCellsAndInside)
     {
         var pos = center + offset;
         AllowToolUtility.ToggleForbiddenInCell(pos, map, false);
     }
 }
Esempio n. 2
0
        public static void DoBehaviorForPawn(JobDriver_Wait driver)
        {
            var hunter = driver.pawn;

            if (!AllowToolController.Instance.Handles.PartyHuntSetting || !WorldSettings.PawnIsPartyHunting(hunter))
            {
                return;
            }
            var verb = hunter.TryGetAttackVerb(null, !hunter.IsColonist);

            if (hunter.Faction != null &&
                driver.job.def == JobDefOf.Wait_Combat &&
                AllowToolUtility.PawnCapableOfViolence(hunter) &&
                !hunter.stances.FullBodyBusy)
            {
                // fire at target
                if (hunter.drafter.FireAtWill)
                {
                    // fudge melee range for easier target acquisition
                    var weaponRange = verb.verbProps.IsMeleeAttack ? 2 : verb.verbProps.range;
                    var target      = TryFindHuntingTarget(hunter, verb.verbProps.minRange, weaponRange, HuntingTargetAttackFilter);
                    if (target != null)
                    {
                        hunter.TryStartAttack(target);
                        ResetAutoUndraftTimer(hunter.drafter);
                        if (target.Dead && WorldSettings.UnforbidDrops)
                        {
                            target.Corpse?.SetForbidden(false, false);
                        }
                    }
                }

                // finish off targets. Wait for everyone to finish firing to avoid catching stray bullets
                if (!hunter.stances.FullBodyBusy && WorldSettings.AutoFinishOff &&
                    CanDoCommonerWork(hunter) && !AnyHuntingPartyMembersInCombat(hunter, MaxPartyMemberDistance))
                {
                    // try mark a downed animal
                    var target = TryFindHuntingTarget(hunter, 0, MaxFinishOffDistance, HuntingTargetFinishFilter);
                    if (target != null)
                    {
                        target.ToggleDesignation(AllowToolDefOf.FinishOffDesignation, true);
                    }
                    // query work giver for finish off job in range
                    var job = WorkGiver_FinishOff.CreateInstance().TryGetJobInRange(hunter, MaxFinishOffDistance);
                    if (job != null)
                    {
                        hunter.jobs.StartJob(job, JobCondition.Ongoing, null, true);
                        if (hunter.jobs.curDriver is JobDriver_FinishOff jdfo && WorldSettings.UnforbidDrops)
                        {
                            jdfo.UnforbidBody = true;
                        }
                        // return to starting position
                        hunter.jobs.jobQueue.EnqueueFirst(JobMaker.MakeJob(JobDefOf.Goto, hunter.Position));
                    }
                }
            }
        }
 public override void DrawMouseAttachments()
 {
     base.DrawMouseAttachments();
     if (GetSelectionCompleteAction() == SectionCompleteAction.CommitSelection)
     {
         var textColor = new Color(.8f, .8f, .8f);
         AllowToolUtility.DrawMouseAttachedLabel("StripMine_cursor_autoApply".Translate(), textColor);
     }
 }
Esempio n. 4
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            var result = base.GizmoOnGUI(topLeft, maxWidth);

            if (Event.current.type == EventType.Repaint)
            {
                AllowToolUtility.DrawRightClickIcon(topLeft.x + overlayIconOffset.x, topLeft.y + overlayIconOffset.y);
            }
            return(result);
        }
Esempio n. 5
0
        public override void MapLoaded(Map map)
        {
            // necessary when adding the mod to existing saves
            var injected = AllowToolUtility.EnsureAllColonistsKnowAllWorkTypes(map);

            if (injected)
            {
                AllowToolUtility.EnsureAllColonistsHaveWorkTypeEnabled(AllowToolDefOf.HaulingUrgent, map);
                AllowToolUtility.EnsureAllColonistsHaveWorkTypeEnabled(AllowToolDefOf.FinishingOff, map);
            }
        }
Esempio n. 6
0
        public void RebindAllDesignators()
        {
            activeListeners.Clear();
            var providers = AllowToolUtility.EnumerateResolvedDirectDesignators()
                            .Where(d => d is IGlobalHotKeyProvider p && p.GlobalHotKey != null);

            foreach (var designator in providers)
            {
                activeListeners.Add(new HotkeyListener(designator, ((IGlobalHotKeyProvider)designator).GlobalHotKey));
            }
        }
Esempio n. 7
0
 public override void MapLoaded(Map map)
 {
     // hidden worktypes can get disabled under unknown circumstances (other mods are involved)
     // make sure they always revert to being enabled.
     // Don't do this for visible work types- player could have disabled the worktype manually
     if (!Handles.HaulWorktypeSetting)
     {
         AllowToolUtility.EnsureAllColonistsHaveWorkTypeEnabled(AllowToolDefOf.HaulingUrgent, map);
     }
     if (!Handles.FinishOffWorktypeSetting)
     {
         AllowToolUtility.EnsureAllColonistsHaveWorkTypeEnabled(AllowToolDefOf.FinishingOff, map);
     }
 }
 public Command_PartyHunt(Pawn pawn)
 {
     this.pawn    = pawn;
     icon         = AllowToolDefOf.Textures.partyHunt;
     defaultLabel = "PartyHuntToggle_label".Translate();
     defaultDesc  = "PartyHuntToggle_desc".Translate();
     isActive     = () => WorldSettings.PawnIsPartyHunting(pawn);
     toggleAction = ToggleAction;
     hotKey       = KeyBindingDefOf.Misc9;
     disabled     = !AllowToolUtility.PawnCapableOfViolence(pawn);
     if (disabled)
     {
         disabledReason = "IsIncapableOfViolence".Translate(pawn.Name.ToStringShort, pawn);
     }
 }
Esempio n. 9
0
        public override void MapLoaded(Map map)
        {
            // necessary when adding the mod to existing saves
            var injected = AllowToolUtility.EnsureAllColonistsKnowAllWorkTypes(map);

            // hidden worktypes can get disabled by adding mods to a save
            // make sure they always revert to being enabled.
            // Don't do this for visible work types- player could have disabled the worktype manually
            if (injected || !Handles.HaulWorktypeSetting)
            {
                AllowToolUtility.EnsureAllColonistsHaveWorkTypeEnabled(AllowToolDefOf.HaulingUrgent, map);
            }
            if (injected || !Handles.FinishOffWorktypeSetting)
            {
                AllowToolUtility.EnsureAllColonistsHaveWorkTypeEnabled(AllowToolDefOf.FinishingOff, map);
            }
        }
Esempio n. 10
0
        private void DoSocialImpact(Pawn victim)
        {
            var isPrisoner  = victim.IsPrisonerOfColony;
            var giveThought = AllowToolUtility.PawnIsFriendly(victim);

            if (giveThought)
            {
                ThoughtUtility.GiveThoughtsForPawnExecuted(victim, PawnExecutionKind.GenericBrutal);
            }
            if (victim.RaceProps != null && victim.RaceProps.intelligence == Intelligence.Animal)
            {
                pawn.records.Increment(RecordDefOf.AnimalsSlaughtered);
            }
            if (isPrisoner)
            {
                TaleRecorder.RecordTale(TaleDefOf.ExecutedPrisoner, pawn, victim);
            }
        }
        public static AcceptanceReport PawnMeetsSkillRequirement(Pawn pawn, Pawn targetPawn)
        {
            if (pawn == null)
            {
                return(AcceptanceReport.WasRejected);
            }
            if (!AllowToolUtility.PawnCapableOfViolence(pawn))
            {
                return(new AcceptanceReport("IsIncapableOfViolenceShort".Translate()));
            }
            var targetIsAnimal = targetPawn?.RaceProps != null && targetPawn.RaceProps.Animal;
            var skillPass      = pawn.skills != null && (!AllowToolController.Instance.FinishOffSkillRequirement ||
                                                         pawn.skills.GetSkill(SkillDefOf.Melee).Level >= MeleeSkillLevelRequired);

            if (!targetIsAnimal && !skillPass)
            {
                return(new AcceptanceReport("Finish_off_pawnSkillRequired".Translate(MeleeSkillLevelRequired)));
            }
            return(AcceptanceReport.WasAccepted);
        }
Esempio n. 12
0
        public override void SelectedOnGUI()
        {
            // update def filter and draw filter readout on cursor
            if (constraintsNeedReindexing)
            {
                ReindexSelectionConstraints();
            }
            string label;

            if (!SelectionLimitAllowsAdditionalThing())
            {
                label = "SelectSimilar_cursor_limit".Translate();
            }
            else if (AnySelectionConstraints)
            {
                label = "SelectSimilar_cursor_nowSelecting".Translate(readableConstraintList);
            }
            else
            {
                label = "SelectSimilar_cursor_needConstraint".Translate();
            }
            AllowToolUtility.DrawMouseAttachedLabel(label);
        }
Esempio n. 13
0
 private static bool AnyHuntingPartyMembersInCombat(Pawn centerPawn, float maxPartyMemberDistance)
 {
     return(centerPawn.Map.mapPawns.FreeColonists.Where(p => AllowToolUtility.PartyHuntIsEnabled(p) && centerPawn.Position.DistanceTo(p.Position) <= maxPartyMemberDistance
                                                        ).Any(p => p.stances.FullBodyBusy));
 }
 public override void DesignateSingleCell(IntVec3 cell)
 {
     numThingsDesignated = AllowToolUtility.ToggleForbiddenInCell(cell, Find.VisibleMap, false);
 }
        public static AcceptanceReport FriendlyPawnIsValidTarget(Thing t)
        {
            var result = !AllowToolUtility.PawnIsFriendly(t) || HugsLibUtility.ShiftIsHeld;

            return(result ? true : new AcceptanceReport("Finish_off_floatMenu_reason_friendly".Translate()));
        }
Esempio n. 16
0
 public override void DesignateSingleCell(IntVec3 cell)
 {
     numThingsDesignated = AllowToolUtility.ToggleForbiddenInCell(cell, Find.CurrentMap, true);
 }
 public override void DrawMouseAttachments()
 {
     base.DrawMouseAttachments();
     AllowToolUtility.DrawMouseAttachedLabel("HarvestFullyGrown_cursorTip".Translate());
 }