public virtual void AbilityTick() { VerbTracker.VerbsTick(); if (def.warmupMote != null && verb.WarmingUp) { if (warmupMote == null || warmupMote.Destroyed) { warmupMote = MoteMaker.MakeStaticMote(pawn.DrawPos + def.moteDrawOffset, pawn.Map, def.warmupMote); } else { warmupMote.Maintain(); } } if (verb.WarmingUp && !CanApplyOn(verb.CurrentTarget)) { verb.WarmupStance?.Interrupt(); verb.Reset(); } if (cooldownTicks > 0) { cooldownTicks--; if (cooldownTicks == 0 && def.sendLetterOnCooldownComplete) { Find.LetterStack.ReceiveLetter("AbilityReadyLabel".Translate(def.LabelCap), "AbilityReadyText".Translate(pawn, def.label), LetterDefOf.NeutralEvent, new LookTargets(pawn)); } } }
private static Command_VerbTarget CreateVerbTargetCommand(VerbTracker __instance, Thing ownerThing, Verb verb) { Command_VerbTarget command_VerbTarget = new Command_VerbTarget(); command_VerbTarget.defaultDesc = ownerThing.LabelCap + ": " + ownerThing.def.description.CapitalizeFirst(); command_VerbTarget.icon = ownerThing.def.uiIcon; command_VerbTarget.iconAngle = ownerThing.def.uiIconAngle; command_VerbTarget.iconOffset = ownerThing.def.uiIconOffset; command_VerbTarget.tutorTag = "VerbTarget"; command_VerbTarget.verb = verb; if (verb.caster.Faction != Faction.OfPlayer) { command_VerbTarget.Disable("CannotOrderNonControlled".Translate()); } else if (verb.CasterIsPawn) { if (verb.CasterPawn.WorkTagIsDisabled(WorkTags.Violent)) { command_VerbTarget.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn)); } else if (!verb.CasterPawn.drafter.Drafted) { command_VerbTarget.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn)); } } return(command_VerbTarget); }
public static void Patch_VerbTracker_GetVerbsCommands_Postfix( ref VerbTracker __instance, ref IEnumerable <Command> __result, ref KeyCode hotKey) { CompEquippable directOwner = __instance.directOwner as CompEquippable; MultiVerbComp multiVerb = (MultiVerbComp)null; if (directOwner == null || (M0)(multiVerb = (MultiVerbComp)ThingCompUtility.TryGetComp <MultiVerbComp>((Thing)((ThingComp)directOwner).parent)) == null) { return; } List <Command> commandList = new List <Command>(); int index = 0; commandList.AddRange(__result); using (List <Verb> .Enumerator enumerator = __instance.get_AllVerbs().GetEnumerator()) { while (enumerator.MoveNext()) { MechaniteForgeHarmonyPatches.Command_MultiVerb commandMultiVerb = new MechaniteForgeHarmonyPatches.Command_MultiVerb(enumerator.Current, multiVerb, index); commandList.Add((Command)commandMultiVerb); ++index; } } __result = (IEnumerable <Command>)commandList; }
private void InitVerb(Verb verb, VerbProperties properties, VerbTracker verbTracker, Tool tool, ManeuverDef maneuver, string id) { verb.loadID = id; verb.verbProps = properties; verb.verbTracker = verbTracker; verb.tool = tool; verb.maneuver = maneuver; verb.caster = this; }
public void Initialize(Pawn pawn) { Pawn = pawn; VerbTracker = new VerbTracker(this); SearchVerb = (Verb_Search)VerbTracker.PrimaryVerb; NeedsTicking = false; debugOpts.ScoreLogging = false; debugOpts.VerbLogging = false; if (!Base.Features.RangedAnimals && !Base.IgnoredFeatures.RangedAnimals && pawn?.VerbTracker?.AllVerbs != null && pawn.VerbTracker.AllVerbs.Any(v => !v.IsMeleeAttack) && !Base.IsIgnoredMod(pawn?.def?.modContentPack?.Name)) { Log.ErrorOnce( "[MVCF] Found pawn with native ranged verbs while that feature is not enabled. Enabling now. This is not recommended. Contact the author of " + pawn?.def?.modContentPack?.Name + " and ask them to add a MVCF.ModDef.", pawn?.def?.modContentPack?.Name?.GetHashCode() ?? -1); Base.Features.RangedAnimals = true; Base.ApplyPatches(); } if (!Base.IsIgnoredMod(pawn?.def?.modContentPack?.Name) && pawn?.VerbTracker?.AllVerbs != null && Base.Features.RangedAnimals && !Base.IgnoredFeatures.RangedAnimals) { foreach (var verb in pawn.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.RaceDef, pawn.TryGetComp <Comp_VerbGiver>()?.PropsFor(verb)); } } if (pawn?.health?.hediffSet?.hediffs != null && !Base.IgnoredFeatures.HediffVerbs) { foreach (var hediff in pawn.health.hediffSet.hediffs) { this.AddVerbs(hediff); } } if (pawn?.apparel?.WornApparel != null && !Base.IgnoredFeatures.ApparelVerbs) { foreach (var apparel in pawn.apparel.WornApparel) { this.AddVerbs(apparel); } } if (pawn?.equipment?.AllEquipmentListForReading != null && !Base.IgnoredFeatures.ExtraEquipmentVerbs) { foreach (var eq in pawn.equipment.AllEquipmentListForReading) { this.AddVerbs(eq); } } }
private static void Postfix(VerbTracker __instance, ref IEnumerable <Command> __result) { var list = __result.ToList(); CompEquippable compEquippable = __instance.directOwner as CompEquippable; var comp = compEquippable.parent.TryGetCompFast <CompToggleFireMode>(); if (comp != null) { list.RemoveAll(x => x is Command_VerbTarget verbTarget && verbTarget.verb != comp.ActiveVerb); __result = list; } }
public static bool PrimaryVerbPrefix(VerbTracker __instance, ref Verb __result) { Comp_VerbSaveable comp = ((CompEquippable)__instance.directOwner).parent.GetComp <Comp_VerbSaveable>(); if (comp != null) { __result = comp.currentVerb; if (__result != null) { return(false); } } return(true); }
static void Postfix(VerbTracker __instance, Thing ownerThing, ref Verb verb, ref Command_VerbTarget __result) { if (ownerThing is ThingWithComps twc && twc.ParentHolder is Pawn_EquipmentTracker peqt) { CompEquippable ce = __instance.directOwner as CompEquippable; if (peqt.pawn.equipment.TryGetOffHandEquipment(out ThingWithComps offHandEquip)) { if (offHandEquip != twc) { __result = CreateDualWieldCommand(ownerThing, offHandEquip, verb); } } } }
public static void Postfix(VerbTracker __instance, Thing ownerThing, Verb verb, ref Command_VerbTarget __result) { if (__instance != null) { if (ownerThing.Graphic is Graphic_RandomRotated r) { __result.icon = ownerThing.Graphic.MatSingleFor(ownerThing).mainTexture as Texture2D; __result.defaultIconColor = ownerThing.Graphic.color; } /* * if (true) * { * __result.icon = ownerThing.Graphic.MatSingleFor(ownerThing).mainTexture as Texture2D; * } */ } }
internal static void VerbsTick(this VerbTracker _this) { if (_this.AllVerbs == null) { return; } foreach (Verb verb in _this.AllVerbs) { verb.VerbTick(); // If we have a CE verb, call custom VerbTicker Verb_LaunchProjectileCE verbCE = verb as Verb_LaunchProjectileCE; if (verbCE != null) { verbCE.VerbTickCE(); } } }
// Token: 0x06000029 RID: 41 RVA: 0x00002A08 File Offset: 0x00000C08 public static void Patch_VerbTracker_GetVerbsCommands_Postfix(ref VerbTracker __instance, ref IEnumerable <Command> __result, ref KeyCode hotKey) { CompEquippable compEquippable = __instance.directOwner as CompEquippable; MultiVerbComp multiVerb = null; bool flag = compEquippable != null && (multiVerb = compEquippable.parent.TryGetComp <MultiVerbComp>()) != null; if (flag) { List <Command> list = new List <Command>(); int num = 0; list.AddRange(__result); foreach (Verb verb in __instance.AllVerbs) { MechaniteForgeHarmonyPatches.Command_MultiVerb item = new MechaniteForgeHarmonyPatches.Command_MultiVerb(verb, multiVerb, num); list.Add(item); num++; } __result = list; } }
public static bool Patch_VerbTracker_PrimaryVerb_Prefix( ref VerbTracker __instance, ref Verb __result) { if (__instance.get_AllVerbs() == null && MechaniteForgeHarmonyPatches.VerbTracker_InitVerbs != null) { MechaniteForgeHarmonyPatches.VerbTracker_InitVerbs.Invoke((object)__instance, new object[0]); } CompEquippable directOwner = __instance.directOwner as CompEquippable; MultiVerbComp multiVerbComp = (MultiVerbComp)null; if (directOwner != null && (M0)(multiVerbComp = (MultiVerbComp)ThingCompUtility.TryGetComp <MultiVerbComp>((Thing)((ThingComp)directOwner).parent)) != null) { __result = __instance.get_AllVerbs()[multiVerbComp.currentVerbIndex]; if (__result != null) { return(false); } } return(true); }
public override void PostExposeData() { base.PostExposeData(); Scribe_Deep.Look(ref verbTracker, "verbTracker", (object)this); if (Scribe.mode != LoadSaveMode.PostLoadInit) { return; } if (verbTracker == null) { verbTracker = new VerbTracker(this); } if (!(parent?.holdingOwner?.Owner is Pawn_ApparelTracker tracker)) { return; } foreach (var verb in verbTracker.AllVerbs) { verb.caster = tracker.pawn; } }
// Token: 0x06000028 RID: 40 RVA: 0x00002978 File Offset: 0x00000B78 public static bool Patch_VerbTracker_PrimaryVerb_Prefix(ref VerbTracker __instance, ref Verb __result) { bool flag = __instance.AllVerbs == null && MechaniteForgeHarmonyPatches.VerbTracker_InitVerbs != null; if (flag) { MechaniteForgeHarmonyPatches.VerbTracker_InitVerbs.Invoke(__instance, new object[0]); } CompEquippable compEquippable = __instance.directOwner as CompEquippable; MultiVerbComp multiVerbComp = null; bool flag2 = compEquippable != null && (multiVerbComp = compEquippable.parent.TryGetComp <MultiVerbComp>()) != null; if (flag2) { __result = __instance.AllVerbs[multiVerbComp.currentVerbIndex]; bool flag3 = __result != null; if (flag3) { return(false); } } return(true); }
public Pawn_NativeVerbs(Pawn pawn) { this.pawn = pawn; verbTracker = new VerbTracker(this); }
static void Postfix(VerbTracker __instance, ref IEnumerable <Command> __result) { __result = RemoveCommandForOffHand(__result); }
public virtual void AbilityTick() { VerbTracker.VerbsTick(); if (def.warmupMote != null && Casting) { Vector3 vector = pawn.DrawPos + def.moteDrawOffset; vector += (verb.CurrentTarget.CenterVector3 - vector) * def.moteOffsetAmountTowardsTarget; if (warmupMote == null || warmupMote.Destroyed) { warmupMote = MoteMaker.MakeStaticMote(vector, pawn.Map, def.warmupMote); } else { warmupMote.exactPosition = vector; warmupMote.Maintain(); } } if (verb.WarmingUp) { if (!(def.targetWorldCell ? CanApplyOn(pawn.CurJob.globalTarget) : CanApplyOn(verb.CurrentTarget))) { if (def.targetWorldCell) { pawn.jobs.EndCurrentJob(JobCondition.Incompletable); } verb.WarmupStance?.Interrupt(); verb.Reset(); preCastActions.Clear(); } else { for (int num = preCastActions.Count - 1; num >= 0; num--) { if (preCastActions[num].ticksAwayFromCast >= verb.WarmupTicksLeft) { preCastActions[num].action(verb.CurrentTarget, verb.CurrentDestination); preCastActions.RemoveAt(num); } } } } if (pawn.Spawned && Casting) { if (def.warmupSound != null) { if (soundCast == null || soundCast.Ended) { soundCast = def.warmupSound.TrySpawnSustainer(SoundInfo.InMap(new TargetInfo(pawn.Position, pawn.Map), MaintenanceType.PerTick)); } else { soundCast.Maintain(); } } if (!wasCastingOnPrevTick && def.warmupStartSound != null) { def.warmupStartSound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); } if (def.warmupPreEndSound != null && verb.WarmupTicksLeft == def.warmupPreEndSoundSeconds.SecondsToTicks()) { def.warmupPreEndSound.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); } } if (cooldownTicks > 0) { cooldownTicks--; if (cooldownTicks == 0 && def.sendLetterOnCooldownComplete) { Find.LetterStack.ReceiveLetter("AbilityReadyLabel".Translate(def.LabelCap), "AbilityReadyText".Translate(pawn, def.label), LetterDefOf.NeutralEvent, new LookTargets(pawn)); } } for (int num2 = maintainedEffecters.Count - 1; num2 >= 0; num2--) { Effecter first = maintainedEffecters[num2].First; if (first.ticksLeft > 0) { TargetInfo second = maintainedEffecters[num2].Second; first.EffectTick(second, second); first.ticksLeft--; } else { first.Cleanup(); maintainedEffecters.RemoveAt(num2); } } wasCastingOnPrevTick = Casting; }
public void Initialize(Pawn pawn) { Pawn = pawn; VerbTracker = new VerbTracker(this); SearchVerb = (Verb_Search)VerbTracker.PrimaryVerb; NeedsTicking = false; debugOpts.ScoreLogging = false; debugOpts.VerbLogging = false; if (!Base.Features.RangedAnimals && !Base.IgnoredFeatures.RangedAnimals && pawn.VerbTracker.AllVerbs.Any(v => !v.IsMeleeAttack) && !Base.IgnoredMods.Contains(pawn.def.modContentPack.Name)) { Log.ErrorOnce( "[MVCF] Found pawn with native ranged verbs while that feature is not enabled. Enabling now. This is not recommended. Contact the author of " + pawn.def.modContentPack.Name + " and ask them to add a MVCF.ModDef.", pawn.def.modContentPack.Name.GetHashCode()); Base.Features.RangedAnimals = true; Base.ApplyPatches(); } if (!Base.IgnoredMods.Contains(pawn.def.modContentPack.Name)) { foreach (var verb in pawn.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.RaceDef, pawn.TryGetComp <Comp_VerbGiver>()?.PropsFor(verb)); } } if (pawn?.health?.hediffSet?.hediffs != null) { foreach (var hediff in pawn.health.hediffSet.hediffs) { if (Base.IgnoredMods.Contains(hediff.def.modContentPack.Name)) { return; } var comp = hediff.TryGetComp <HediffComp_VerbGiver>(); if (comp == null) { continue; } if (!Base.Features.HediffVerbs && !Base.IgnoredFeatures.HediffVerbs && comp.VerbTracker.AllVerbs.Any(v => !v.IsMeleeAttack) && !Base.IgnoredMods.Contains(hediff.def.modContentPack.Name)) { Log.ErrorOnce( "[MVCF] Found a hediff with a ranged verb while that feature is not enabled. Enabling now. This is not recommend. Contant the author of " + hediff.def.modContentPack.Name + " and ask them to add a MVCF.ModDef.", hediff.def.modContentPack.Name.GetHashCode()); Base.Features.HediffVerbs = true; Base.ApplyPatches(); } var extComp = comp as HediffComp_ExtendedVerbGiver; foreach (var verb in comp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Hediff, extComp?.PropsFor(verb)); } } } if (pawn?.apparel?.WornApparel != null) { foreach (var apparel in pawn.apparel.WornApparel) { if (Base.IgnoredMods.Contains(apparel.def.modContentPack.Name)) { return; } var comp = apparel.TryGetComp <Comp_VerbGiver>(); if (comp == null) { continue; } if (!Base.Features.ApparelVerbs && !Base.IgnoredFeatures.ApparelVerbs && !Base.IgnoredMods.Contains(apparel.def.modContentPack.Name)) { Log.ErrorOnce( "[MVCF] Found apparel with a verb while that feature is not enabled. Enabling now. This is not recommend. Contact the author of " + apparel.def.modContentPack.Name + " and ask them to add a MVCF.ModDef.", apparel.def.modContentPack.Name.GetHashCode()); Base.Features.ApparelVerbs = true; Base.ApplyPatches(); } foreach (var verb in comp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Apparel, comp.PropsFor(verb)); } } } if (pawn?.equipment?.AllEquipmentListForReading != null) { foreach (var eq in pawn.equipment.AllEquipmentListForReading) { if (Base.IgnoredMods.Contains(eq.def.modContentPack.Name)) { return; } var comp = eq.TryGetComp <CompEquippable>(); if (comp == null) { continue; } if (!Base.Features.ExtraEquipmentVerbs && !Base.IgnoredFeatures.ExtraEquipmentVerbs && comp.VerbTracker.AllVerbs.Count(v => !v.IsMeleeAttack) > 1 && !Base.IgnoredMods.Contains(eq.def.modContentPack.Name)) { Log.ErrorOnce( "[MVCF] Found equipment with more than one ranged attack while that feature is not enabled. Enabling now. This is not recommend. Contact the author of " + eq.def.modContentPack.Name + " and ask them to add a MVCF.ModDef.", eq.def.modContentPack.Name.GetHashCode()); Base.Features.ExtraEquipmentVerbs = true; Base.ApplyPatches(); } foreach (var verb in comp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Equipment, (comp.props as CompProperties_VerbProps)?.PropsFor(verb)); } } } }
public static void GetVerbsCommands_Postfix(ref VerbTracker __instance, ref IEnumerable <Command> __result) { }
public AbilityData_Verb() { verbTracker = new VerbTracker(this); }
public Comp_VerbGiver() { verbTracker = new VerbTracker(this); }
public static void GetVerbsCommandsPostfix(ref VerbTracker __instance, ref IEnumerable <Command> __result) { CompEquippable compEquippable = __instance.directOwner as CompEquippable; if (compEquippable == null) { return; } Thing thing = compEquippable.parent; CompRangedWeaponAvali compWeaponAvali = null; //Log.Message("thing: " + thing); if (thing != null) { compWeaponAvali = thing.TryGetComp <CompRangedWeaponAvali>(); } if (compWeaponAvali == null) { return; } string currentBindMode = compWeaponAvali.currentBindMode; //Log.Message("currentBindMode: " + currentBindMode); bool isDisabled = false; string isDisabledReason = "CannotOrderNonControlled".Translate(); Pawn holderPawn = compEquippable.PrimaryVerb.CasterPawn; //Log.Message("ownerPawn: " + ownerPawn); if (holderPawn == null || holderPawn.IsColonist == false) { return; } if (!holderPawn.Awake()) { isDisabled = true; isDisabledReason = string.Format("NotAwake".Translate(), holderPawn.LabelShort.CapitalizeFirst()); } else if (compWeaponAvali.ownerPawn != null && holderPawn != compWeaponAvali.ownerPawn) { if (currentBindMode == CompRangedWeaponAvali.bindMode.OwnerPawnOnly.ToString() || currentBindMode == CompRangedWeaponAvali.bindMode.AnyPawnInFaction.ToString()) { isDisabled = true; isDisabledReason = "OwnerNotCasterPawn".Translate(); } } else if (holderPawn.Drafted) { isDisabled = true; isDisabledReason = string.Format("ShouldBeUndrafted".Translate(), holderPawn.LabelShort.CapitalizeFirst()); } //Log.Message("isDisabled: " + isDisabled); List <Command> result = __result.ToList(); /*result.Add(new Command_Action * { * action = delegate * { * compWeaponAvali.ChangeBindMode(); * }, * disabled = isDisabled, * disabledReason = isDisabledReason, * //defaultLabel = ("BindMode_" + currentBindMode).Translate(), * defaultDesc = ("BindMode_" + currentBindMode + "Desc").Translate(), * icon = ContentFinder<Texture2D>.Get("UI/Commands/" + "BindMode_" + currentBindMode, true), * hotKey = KeyBindingDefOf.Misc4 * });*/ result.Add(new Command_Action { action = delegate { compWeaponAvali.EraseOwnerPawnInfo(); }, disabled = isDisabled, disabledReason = isDisabledReason, //defaultLabel = "EraseOwnerPawnInfo".Translate(), defaultDesc = "EraseOwnerPawnInfoDesc".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/EraseOwnerPawnInfo", true), hotKey = KeyBindingDefOf.Misc5 }); List <Verb> verbs = __instance.AllVerbs; for (int i = 0; i < verbs.Count; i++) { Verb verb = verbs[i]; if (verb.verbProps.hasStandardCommand) { __result = result; } } }
public void Initialize(Pawn pawn) { Pawn = pawn; VerbTracker = new VerbTracker(this); SearchVerb = (Verb_Search)VerbTracker.PrimaryVerb; NeedsTicking = false; debugOpts.ScoreLogging = false; debugOpts.VerbLogging = false; foreach (var verb in pawn.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.RaceDef, pawn.TryGetComp <Comp_VerbGiver>()?.PropsFor(verb)); } if (pawn?.health?.hediffSet?.hediffs != null) { foreach (var hediff in pawn.health.hediffSet.hediffs) { var comp = hediff.TryGetComp <HediffComp_VerbGiver>(); if (comp != null) { var extComp = comp as HediffComp_ExtendedVerbGiver; foreach (var verb in comp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Hediff, extComp?.PropsFor(verb)); } } } } if (pawn?.apparel?.WornApparel != null) { foreach (var apparel in pawn.apparel.WornApparel) { var comp = apparel.TryGetComp <Comp_VerbGiver>(); if (comp == null) { continue; } foreach (var verb in comp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Apparel, comp.PropsFor(verb)); } } } if (pawn?.equipment?.AllEquipmentListForReading != null) { foreach (var eq in pawn.equipment.AllEquipmentListForReading) { var comp = eq.TryGetComp <CompEquippable>(); if (comp == null) { var extComp = eq.TryGetComp <Comp_VerbGiver>(); if (extComp == null) { continue; } foreach (var verb in extComp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Equipment, extComp.PropsFor(verb)); } } else { foreach (var verb in comp.VerbTracker.AllVerbs) { AddVerb(verb, VerbSource.Equipment, null); } } } } }