public ManagedVerb(Verb verb, VerbSource source, AdditionalVerbProps props, VerbManager man) { Verb = verb; Source = source; Props = props; this.man = man; if (Props != null && Props.draw && !Base.Features.Drawing) { Log.Error( "[MVCF] Found a verb marked to draw while that feature is not enabled. Enabling now. This is not recommend."); Base.Features.Drawing = true; Base.ApplyPatches(); } if (Props != null && Props.canFireIndependently && !Base.Features.IndependentFire) { Log.Error( "[MVCF] Found a verb marked to fire independently while that feature is not enabled. Enabling now. This is not recommend."); Base.Features.IndependentFire = true; Base.ApplyPatches(); } if (Props != null && !Props.separateToggle && !Base.Features.IntegratedToggle) { Log.Error( "[MVCF] Found a verb marked for an integrated toggle while that feature is not enabled. Enabling now. This is not recommend."); Base.Features.IntegratedToggle = true; Base.ApplyPatches(); } }
public ManagedVerb(Verb verb, VerbSource source, AdditionalVerbProps props, VerbManager man) { Verb = verb; Source = source; Props = props; this.man = man; }
public void AddVerb(Verb verb, VerbSource source, AdditionalVerbProps props) { ManagedVerb mv; if (props != null && props.canFireIndependently) { var tv = new TurretVerb(verb, source, props, this); if (tickVerbs.Count == 0) { NeedsTicking = true; WorldComponent_MVCF.GetComp().TickManagers.Add(new System.WeakReference <VerbManager>(this)); } tickVerbs.Add(tv); mv = tv; } else { mv = new ManagedVerb(verb, source, props, this); } if (props != null && props.draw) { drawVerbs.Add(mv); } verbs.Add(mv); RecalcSearchVerb(); }
public void AddVerb(Verb verb, VerbSource source, AdditionalVerbProps props) { if (debugOpts.VerbLogging) { Log.Message("Adding " + verb + " from " + source + " with props " + props); } if (AllVerbs.Contains(verb)) { if (debugOpts.VerbLogging) { Log.Warning("Added duplicate verb " + verb); } return; } ManagedVerb mv; if (props != null && props.canFireIndependently) { TurretVerb tv; if (props.managedClass != null) { tv = (TurretVerb)Activator.CreateInstance(props.managedClass, verb, source, props, this); } else { tv = new TurretVerb(verb, source, props, this); } if (tickVerbs.Count == 0) { NeedsTicking = true; WorldComponent_MVCF.GetComp().TickManagers.Add(new System.WeakReference <VerbManager>(this)); } tickVerbs.Add(tv); mv = tv; } else { if (props?.managedClass != null) { mv = (ManagedVerb)Activator.CreateInstance(props.managedClass, verb, source, props, this); } else { mv = new ManagedVerb(verb, source, props, this); } } if (props != null && props.draw) { drawVerbs.Add(mv); } verbs.Add(mv); RecalcSearchVerb(); }
public TurretVerb(Verb verb, VerbSource source, AdditionalVerbProps props, VerbManager man) : base(verb, source, props, man) { dummyCaster = new DummyCaster(man.Pawn, this); dummyCaster.Tick(); dummyCaster.SpawnSetup(man.Pawn.Map, false); verb.caster = dummyCaster; verb.castCompleteCallback = () => cooldownTicksLeft = Verb.verbProps.AdjustedCooldownTicks(Verb, man.Pawn); }
public static Texture2D Icon(this Verb verb, AdditionalVerbProps props, Thing ownerThing) { if (props?.ToggleIcon != null && props.ToggleIcon != BaseContent.BadTex) { return(props.ToggleIcon); } if (verb.UIIcon != null && verb.verbProps.commandIcon != null && verb.UIIcon != BaseContent.BadTex) { return(verb.UIIcon); } if (verb is Verb_LaunchProjectile proj) { return(proj.Projectile.uiIcon); } if (ownerThing != null) { return(ownerThing.def.uiIcon); } return(TexCommand.Attack); }
public static string Label(this Verb verb, AdditionalVerbProps props = null) { return(VerbLabel(verb, props).CapitalizeFirst()); }
private static string VerbLabel(Verb verb, AdditionalVerbProps props = null) { return(FirstNonEmptyString(props?.visualLabel, verb.verbProps.label, (verb as Verb_LaunchProjectile)?.Projectile.LabelCap, verb.caster?.def?.label)); }
public static IEnumerable <Gizmo> GetGizmosForVerb(this Verb verb, ManagedVerb man = null) { AdditionalVerbProps props = null; Thing ownerThing = null; switch (verb.DirectOwner) { case ThingWithComps twc when twc.TryGetComp <Comp_VerbGiver>() is Comp_VerbGiver giver: ownerThing = twc; props = giver.PropsFor(verb); break; case Thing thing: ownerThing = thing; break; case Comp_VerbGiver comp: ownerThing = comp.parent; props = comp.PropsFor(verb); break; case CompEquippable eq: ownerThing = eq.parent; break; case HediffComp_ExtendedVerbGiver hediffGiver: props = hediffGiver.PropsFor(verb); break; } var gizmo = new Command_VerbTarget(); if (ownerThing != null) { gizmo.defaultDesc = FirstNonEmptyString(props?.description, ownerThing.def.LabelCap + ": " + ownerThing .def.description .Truncate(500, __truncateCache) .CapitalizeFirst()); gizmo.icon = verb.Icon(null, ownerThing); } else if (verb.DirectOwner is HediffComp_VerbGiver hediffGiver) { var hediff = hediffGiver.parent; gizmo.defaultDesc = FirstNonEmptyString(props?.description, hediff.def.LabelCap + ": " + hediff.def.description .Truncate(500, __truncateCache) .CapitalizeFirst()); gizmo.icon = verb.Icon(null, null); } gizmo.tutorTag = "VerbTarget"; gizmo.verb = verb; gizmo.defaultLabel = verb.Label(props); if (verb.caster.Faction != Faction.OfPlayer) { gizmo.Disable("CannotOrderNonControlled".Translate()); } else if (verb.CasterIsPawn) { if (verb.CasterPawn.WorkTagIsDisabled(WorkTags.Violent)) { gizmo.Disable("IsIncapableOfViolence".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn)); } else if (!verb.CasterPawn.drafter.Drafted) { gizmo.Disable("IsNotDrafted".Translate(verb.CasterPawn.LabelShort, verb.CasterPawn)); } } yield return(gizmo); if (props != null && props.canBeToggled && man != null && verb.caster.Faction == Faction.OfPlayer && props.separateToggle) { yield return(new Command_ToggleVerbUsage(man)); } }
public TurretVerb(Verb verb, VerbSource source, AdditionalVerbProps props, VerbManager man) : base(verb, source, props, man) { verb.castCompleteCallback = () => cooldownTicksLeft = Verb.verbProps.AdjustedCooldownTicks(Verb, man.Pawn); }