public void BeginTargeting(ITargetingSource source, ITargetingSource parent = null) { if (source.Targetable) { targetingSource = source; targetingSourceAdditionalPawns = new List <Pawn>(); } else { Verb getVerb = source.GetVerb; if (getVerb.verbProps.nonInterruptingSelfCast) { getVerb.TryStartCastOn(getVerb.Caster); return; } Job job = JobMaker.MakeJob(JobDefOf.UseVerbOnThing, getVerb.Caster); job.verbToUse = getVerb; source.CasterPawn.jobs.StartJob(job, JobCondition.InterruptForced); } action = null; caster = null; targetParams = null; actionWhenFinished = null; mouseAttachment = null; targetingSourceParent = parent; needsStopTargetingCall = false; }
public void OrderPawnForceTarget(ITargetingSource targetingSource) { LocalTargetInfo target = CurrentTargetUnderMouse(mustBeHittableNowIfNotMelee: true); if (target.IsValid) { targetingSource.OrderForceTarget(target); } }
public static IEnumerable <LocalTargetInfo> OurTargetsAt(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false, ITargetingSource source = null) { if (blockAHlONonItems) { return(Enumerable.Empty <LocalTargetInfo>()); //yield break; } return(GenUI.TargetsAt(clickPos, clickParams, thingsOnly, source)); }
public void StopTargeting() { if (actionWhenFinished != null) { Action obj = actionWhenFinished; actionWhenFinished = null; obj(); } targetingSource = null; action = null; targetParams = null; }
public void BeginTargeting(TargetingParameters targetParams, Action <LocalTargetInfo> action, Pawn caster = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null) { targetingSource = null; targetingSourceParent = null; targetingSourceAdditionalPawns = null; this.action = action; this.targetParams = targetParams; this.caster = caster; this.actionWhenFinished = actionWhenFinished; this.mouseAttachment = mouseAttachment; needsStopTargetingCall = false; }
public static void BeginTargetingPrefix(ITargetingSource source) { if (!(source is Verb verb)) { return; } if (verb.verbTracker != null && verb.verbTracker.directOwner != null && verb.DirectOwner is CompEquippable equippable) { Comp_VerbSaveable comp = equippable.parent.GetComp <Comp_VerbSaveable>(); if (comp != null) { comp.tempVerb = verb; } } }
public void BeginTargeting(TargetingParameters targetParams, ITargetingSource ability, Action <LocalTargetInfo> action, Action actionWhenFinished = null, Texture2D mouseAttachment = null) { targetingSource = null; targetingSourceParent = null; targetingSourceAdditionalPawns = null; this.action = action; this.actionWhenFinished = actionWhenFinished; caster = null; this.targetParams = targetParams; this.mouseAttachment = mouseAttachment; targetingSource = ability; highlightAction = null; targetValidator = null; needsStopTargetingCall = false; }
public static void OrderPawnForceTargetPostfix(Targeter __instance, ITargetingSource targetingSource) { if (!(targetingSource is Verb verb)) { return; } if (verb.verbTracker != null && verb.verbTracker.directOwner != null && verb.DirectOwner is CompEquippable equippable) { Comp_VerbSaveable comp = equippable.parent.GetComp <Comp_VerbSaveable>(); if (comp != null) { if (!Traverse.Create(__instance).Method("CurrentTargetUnderMouse", true).GetValue <LocalTargetInfo>().IsValid) { return; } comp.currentVerb = verb; } } }
public void BeginTargeting(ITargetingSource source, ITargetingSource parent = null) { if (source.Targetable) { targetingSource = source; targetingSourceAdditionalPawns = new List <Pawn>(); } else { Job job = JobMaker.MakeJob(JobDefOf.UseVerbOnThing); job.verbToUse = targetingSource.GetVerb; source.CasterPawn.jobs.StartJob(job); } action = null; caster = null; targetParams = null; actionWhenFinished = null; mouseAttachment = null; targetingSourceParent = parent; needsStopTargetingCall = false; }
private static void SyncVEFAbility(SyncWorker sync, ref ITargetingSource source) { if (sync.isWriting) { sync.Write(source.Caster); sync.Write(source.GetVerb.GetUniqueLoadID()); } else { var caster = sync.Read <Thing>(); var uid = sync.Read <string>(); if (caster is ThingWithComps thing) { var compAbilities = thing.AllComps.First(c => c.GetType() == learnedAbilitiesField.DeclaringType); var list = learnedAbilitiesField.GetValue(compAbilities) as List <ITargetingSource>; source = list.First(s => s.GetVerb.GetUniqueLoadID() == uid); } else { Log.Error("MultiplayerCompat :: SyncVEFAbility : Caster isn't a ThingWithComps"); } } }
public static bool VerbGiverExtended(Targeter __instance, ITargetingSource targetingSource) { Verb verb = targetingSource.GetVerb; if (verb == null) { return(true); } if (verb.EquipmentSource != null || verb.EquipmentCompSource != null) { return(true); } if (verb.HediffSource != null || verb.HediffCompSource != null) { return(true); } if (verb.TerrainSource != null || verb.TerrainDefSource != null) { return(true); } if (verb is Verb_CastPsycast) { return(true); } if (verb.verbProps.IsMeleeAttack) { Traverse.Create(__instance).Field("targetParams").SetValue(TargetingParameters.ForAttackAny()); } LocalTargetInfo localTargetInfo = CurrentTargetUnderMouse(__instance, true); if (!localTargetInfo.IsValid) { return(true); } if (verb.CasterPawn != localTargetInfo.Thing) { if (verb.verbProps.IsMeleeAttack) { Job job = new Job(JobDefOf.AttackMelee, localTargetInfo) { verbToUse = verb, playerForced = true }; if (localTargetInfo.Thing is Pawn pawn) { job.killIncappedTarget = pawn.Downed; } verb.CasterPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); } else { float num = verb.verbProps.EffectiveMinRange(localTargetInfo, verb.CasterPawn); if ((float)verb.CasterPawn.Position.DistanceToSquared(localTargetInfo.Cell) < num * num && verb.CasterPawn.Position.AdjacentTo8WayOrInside(localTargetInfo.Cell)) { Messages.Message("MessageCantShootInMelee".Translate(), verb.CasterPawn, MessageTypeDefOf.RejectInput, false); } else { JobDef def = (!verb.verbProps.ai_IsWeapon) ? JobDefOf.UseVerbOnThing : PCF_JobDefOf.PCF_AttackStaticExtended; Job job2 = new Job(def) { verbToUse = verb, targetA = localTargetInfo, endIfCantShootInMelee = true }; verb.CasterPawn.jobs.TryTakeOrderedJob(job2, JobTag.Misc); } } } return(false); }
public static IEnumerable <LocalTargetInfo> TargetsAt_NewTemp(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false, ITargetingSource source = null) { List <Thing> clickableList = ThingsUnderMouse(clickPos, 0.8f, clickParams); Thing caster = source?.Caster; for (int i = 0; i < clickableList.Count; i++) { Pawn pawn = clickableList[i] as Pawn; if (pawn == null || !pawn.IsInvisible() || caster == null || caster.Faction == pawn.Faction) { yield return(clickableList[i]); } } if (!thingsOnly) { IntVec3 intVec = UI.MouseCell(); if (intVec.InBounds(Find.CurrentMap) && clickParams.CanTarget(new TargetInfo(intVec, Find.CurrentMap))) { yield return(intVec); } } }
public static IEnumerable <LocalTargetInfo> TargetsAtMouse_NewTemp(TargetingParameters clickParams, bool thingsOnly = false, ITargetingSource source = null) { return(TargetsAt_NewTemp(UI.MouseMapPosition(), clickParams, thingsOnly, source)); }