public void CreateVerb()
 {
     verb_ShootWeaponAbility = new Verb_ShootWeaponAbility
     {
         verbTracker = new VerbTracker(GetPawn()),
         caster      = GetPawn(),
         verbProps   = new VerbProperties
         {
             accuracyTouch      = 1f,
             accuracyShort      = 1f,
             accuracyMedium     = 1f,
             accuracyLong       = 1f,
             verbClass          = typeof(Verb_ShootWeaponAbility),
             hasStandardCommand = true,
             defaultProjectile  = Props.AbilityProjectile,
             warmupTime         = Props.WarmupTime,
             range                  = Props.Range,
             soundCast              = Props.AbilitySound,
             burstShotCount         = Props.BurstShotCount,
             ticksBetweenBurstShots = Props.TicksBetweenBurstShots,
             muzzleFlashScale       = 0,
             forcedMissRadius       = 0f,
         },
         cannotMiss = Props.cannotMiss,
         ammunition = Props.usesAmmunition
     };
     verb_ShootWeaponAbility.verbProps.targetParams = TargetingParameters.ForAttackAny();
     if (Props.targetingParameters != null)
     {
         verb_ShootWeaponAbility.verbProps.targetParams = Props.targetingParameters;
     }
 }
Пример #2
0
        private static Gizmo GetSquadAttackGizmo(Pawn pawn)
        {
            Command_Target command_Target = new Command_Target();

            command_Target.defaultLabel    = "CommandSquadAttack".Translate();
            command_Target.defaultDesc     = "CommandSquadAttackDesc".Translate();
            command_Target.targetingParams = TargetingParameters.ForAttackAny();
            command_Target.hotKey          = KeyBindingDefOf.Misc4;
            command_Target.icon            = TexCommand.SquadAttack;
            string str;

            if (FloatMenuUtility.GetAttackAction(pawn, LocalTargetInfo.Invalid, out str) == null)
            {
                command_Target.Disable(str.CapitalizeFirst() + ".");
            }
            command_Target.action = delegate(Thing target)
            {
                IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                {
                    Pawn pawn3 = x as Pawn;
                    return(pawn3 != null && pawn3.IsColonistPlayerControlled && pawn3.Drafted);
                }).Cast <Pawn>();
                foreach (Pawn pawn2 in enumerable)
                {
                    string text;
                    Action attackAction = FloatMenuUtility.GetAttackAction(pawn2, target, out text);
                    if (attackAction != null)
                    {
                        attackAction();
                    }
                }
            };
            return(command_Target);
        }
Пример #3
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            bool   disabled       = false;
            string disabledReason = "";

            if (GetPawn == null)
            {
                disabled       = true;
                disabledReason = "DisabledNotEquipped".Translate(parent.def.label);
            }
            else if (!GetPawn.equipment.AllEquipmentListForReading.Contains(parent))
            {
                disabled       = true;
                disabledReason = "DisabledNotEquipped".Translate(parent.def.label);
            }
            TargetingParameters targetingParameters = TargetingParameters.ForAttackAny();

            if (stolenTraitDef == null)
            {
                yield return(new Command_Target
                {
                    defaultLabel = Props.AbilityLabelSteal,
                    defaultDesc = Props.AbilityDescSteal,
                    icon = IconAbilitySteal,
                    targetingParams = targetingParameters,
                    action = delegate(Thing target)
                    {
                        IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                        {
                            Pawn pawn3 = x as Pawn;
                            return pawn3 != null && pawn3.IsColonistPlayerControlled && pawn3.Drafted;
                        }).Cast <Pawn>();
                        DoEffectOn(target);
                    },
                    disabled = disabled,
                    disabledReason = disabledReason
                });
            }
            else
            {
                yield return(new Command_Action
                {
                    defaultLabel = Props.AbilityLabelConsume,
                    defaultDesc = "AbilityDescConsumeAura".Translate(stolenTraitDef.label),
                    icon = IconAbilityConsume,
                    action = ConsumeStolenAura,
                    disabled = disabled,
                    disabledReason = disabledReason
                });
            }
        }
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            if (verb_ShootWeaponAbility == null || GetPawn() != verb_ShootWeaponAbility.caster)
            {
                CreateVerb();
            }

            bool   disabled       = false;
            string disabledReason = "";

            if (GetPawn() == null)
            {
                disabled       = true;
                disabledReason = "DisabledNotEquipped".Translate(parent.def.label);
            }
            else if (!GetPawn().equipment.AllEquipmentListForReading.Contains(parent) && !GetPawn().inventory.innerContainer.Contains(parent))
            {
                disabled       = true;
                disabledReason = "DisabledNotEquipped".Translate(parent.def.label);
            }
            else if (Props.usesAmmunition != null && GetPawn().inventory.GetDirectlyHeldThings().ToList().Find(s => s.def == Props.usesAmmunition) == null)
            {
                disabled = true;
                if (GetPawn().story.traits.HasTrait(RWBYDefOf.Semblance_Velvet) && GetPawn().equipment.Primary != null && GetPawn().equipment.Primary.TryGetComp <CompLightCopy>() != null)
                {
                    disabled = false;
                }
                disabledReason = "DisabledNoAmmunition".Translate(Props.usesAmmunition.label).CapitalizeFirst();
            }

            TargetingParameters targetingParameters = TargetingParameters.ForAttackAny();

            if (Props.targetingParameters != null)
            {
                targetingParameters = Props.targetingParameters;
            }

            yield return(new Command_TargetWithRadius
            {
                defaultLabel = Props.AbilityLabel,
                defaultDesc = Props.AbilityDesc,
                icon = IconAbility,
                defaultIconColor = Props.AbilityIconColor,
                disabled = disabled,
                disabledReason = disabledReason,
                verb = verb_ShootWeaponAbility
            });
        }
Пример #5
0
        public static Gizmo GetGizmo(Pawn pawn)
        {
            Command_Target command_Target = new Command_Target();

            command_Target.defaultLabel = defaultLabel;
            //command_Target.defaultLabel = "CommandMeleeAttack".Translate();
            command_Target.defaultDesc = defaultDesc;
            //command_Target.defaultDesc = "CommandMeleeAttackDesc".Translate();
            command_Target.targetingParams = TargetingParameters.ForAttackAny();
            //command_Target.hotKey = KeyBindingDefOf.Misc2;
            command_Target.icon = TexCommand.AttackMelee;
            if (GetAttackAction(pawn, LocalTargetInfo.Invalid, out string failStr) == null)
            {
                command_Target.Disable(failStr.CapitalizeFirst() + ".");
            }
            command_Target.action = delegate(Thing target)
            {
                foreach (Pawn item in Find.Selector.SelectedObjects.Where(delegate(object x)
                {
                    Pawn pawn2 = x as Pawn;
                    return(pawn2 != null && pawn2.IsColonistPlayerControlled);
                    //if (pawn2 != null && pawn2.IsColonistPlayerControlled)
                    //{
                    //    return pawn2.Drafted;
                    //}
                    //return false;
                }).Cast <Pawn>())
                {
                    string failStr2;
                    Action unarmedAttackAction = GetAttackAction(item, target, out failStr2);
                    if (unarmedAttackAction != null)
                    {
                        unarmedAttackAction();
                    }
                    else if (!failStr2.NullOrEmpty())
                    {
                        Messages.Message(failStr2, target, MessageTypeDefOf.RejectInput, historical: false);
                    }
                }
            };
            return(command_Target);
        }
Пример #6
0
        public void GetVehicleButtonFloatMenu(VehicleHandlerGroup group, bool canLoad)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();
            Map         map             = this.Pawn.Map;
            List <Pawn> tempList        = new List <Pawn>(group.handlers);

            if (canLoad)
            {
                string text = "CompVehicle_Load".Translate(group.role.label);
                //Func<Rect, bool> extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, handler);
                list.Add(new FloatMenuOption(text, delegate
                {
                    SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                    Find.Targeter.BeginTargeting(TargetingParameters.ForAttackAny(), delegate(LocalTargetInfo target)
                    {
                        GiveLoadJob(target.Thing, group);
                    }, null, null, null);
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }
            if (tempList.Count != 0)
            {
                foreach (Pawn handler in tempList)
                {
                    string text = "CompVehicle_Unload".Translate(handler.Name.ToStringFull);
                    List <FloatMenuOption> arg_121_0      = list;
                    Func <Rect, bool>      extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, handler);
                    list.Add(new FloatMenuOption(text, delegate
                    {
                        Eject(handler, group.handlers);
                    }, MenuOptionPriority.Default, null, null, 29f, extraPartOnGUI, null));
                }
            }
            else
            {
                list.Add(new FloatMenuOption("NoPrisoners".Translate(), delegate
                {
                }, MenuOptionPriority.Default));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
        public static Gizmo GetMainAttackGizmoForPawn(this Pawn pawn)
        {
            var verbs = pawn.Manager().ManagedVerbs;
            var gizmo = new Command_Action
            {
                defaultDesc = "Attack",
                hotKey      = KeyBindingDefOf.Misc1,
                icon        = TexCommand.SquadAttack,
                action      = () =>
                {
                    Find.Targeter.BeginTargeting(TargetingParameters.ForAttackAny(), target =>
                    {
                        var manager         = pawn.Manager();
                        manager.CurrentVerb = null;
                        var verb            = pawn.BestVerbForTarget(target, verbs.Where(v => v.Enabled && !v.Verb.IsMeleeAttack),
                                                                     manager);
                        verb.OrderForceTarget(target);
                    }, pawn, null, TexCommand.Attack);
                }
            };

            if (pawn.Faction != Faction.OfPlayer)
            {
                gizmo.Disable("CannotOrderNonControlled".Translate());
            }
            if (pawn.WorkTagIsDisabled(WorkTags.Violent))
            {
                gizmo.Disable("IsIncapableOfViolence".Translate((NamedArgument)pawn.LabelShort, (NamedArgument)pawn));
            }
            else if (!pawn.drafter.Drafted)
            {
                gizmo.Disable("IsNotDrafted".Translate((NamedArgument)pawn.LabelShort, (NamedArgument)pawn));
            }

            return(gizmo);
        }
Пример #8
0
        public IEnumerable <Command_CastPower> GetPsykerVerbsNew()
        {
            //     Log.Message("Found temp powers: " + this.temporaryPowers.Count.ToString() + " while finding Verbs: " + temporaryPowers.Count.ToString());
            //     Log.Message(this.PowerVerbs.Count.ToString());
            List <Verb_CastWarpPower> temp = new List <Verb_CastWarpPower>();

            temp.AddRange(this.PowerVerbs);
            for (int i = 0; i < temp.Count; i++)
            {
                int j = i;
                Verb_CastWarpPower newverb = temp[j];
                newverb.caster    = this.psyker;
                newverb.verbProps = temp[j].verbProps;

                Command_CastPower command_CastPower = new Command_CastPower(this);
                command_CastPower.verb            = newverb;
                command_CastPower.defaultLabel    = allPowers[j].def.LabelCap;
                command_CastPower.defaultDesc     = allPowers[j].def.description;
                command_CastPower.targetingParams = TargetingParameters.ForAttackAny();
                if (newverb.warpverbprops.PsykerPowerCategory == PsykerPowerTargetCategory.TargetSelf || newverb.warpverbprops.PsykerPowerCategory == PsykerPowerTargetCategory.TargetAoE)
                {
                    command_CastPower.targetingParams = TargetingParameters.ForSelf(this.psyker);
                }
                command_CastPower.icon = allPowers[j].def.uiIcon;
                string str;
                if (FloatMenuUtility.GetAttackAction(this.psyker, TargetInfo.Invalid, out str) == null)
                {
                    command_CastPower.Disable(str.CapitalizeFirst() + ".");
                }
                command_CastPower.action = delegate(Thing target)
                {
                    Action attackAction = CompPsyker.TryCastPowerAction(psyker, target, this, newverb, allPowers[j].def as PsykerPowerDef);
                    if (attackAction != null)
                    {
                        attackAction();
                    }
                };
                if (newverb.caster.Faction != Faction.OfPlayer)
                {
                    command_CastPower.Disable("CannotOrderNonControlled".Translate());
                }
                if (newverb.CasterIsPawn)
                {
                    if (newverb.CasterPawn.story.DisabledWorkTags.Contains(WorkTags.Violent))
                    {
                        command_CastPower.Disable("IsIncapableOfViolence".Translate(new object[]
                        {
                            newverb.CasterPawn.NameStringShort
                        }));
                    }
                    else if (!newverb.CasterPawn.drafter.Drafted)
                    {
                        command_CastPower.Disable("IsNotDrafted".Translate(new object[]
                        {
                            newverb.CasterPawn.NameStringShort
                        }));
                    }
                    else if (!this.IsActive)
                    {
                        command_CastPower.Disable("PsykerPowerRecharging".Translate(new object[]
                        {
                            newverb.CasterPawn.NameStringShort
                        }));
                    }
                }
                yield return(command_CastPower);
            }
            yield break;
        }
Пример #9
0
        public static void AddGizmo(Pawn __instance, ref IEnumerable <Gizmo> __result)
        {
            //I want access to the pawn object, and want to modify the original method's result
            var pawn   = __instance;
            var gizmos = __result.ToList();
            // First two flags detect if the pawn is mine, and if it is

            bool flagIsCreatureMine      = pawn.Faction != null && pawn.Faction.IsPlayer;
            bool flagIsCreatureDraftable = (pawn.TryGetComp <CompDraftable>() != null);

            /* I check these flags only inside flagIsCreatureDraftable true to avoid errors due to pawn.TryGetComp<CompDraftable>() being null in most pawns. The code inside
             * the conditional only executes if it isn't*/
            bool flagIsCreatureRageable         = false;
            bool flagIsCreatureExplodable       = false;
            bool flagIsCreatureChickenRimPox    = false;
            bool flagCanCreatureCarryMore       = false;
            bool flagCanCreatureAdrenalineBurst = false;
            bool flagCanCanDoInsectClouds       = false;
            bool flagCanStampede         = false;
            bool flagCanDoPoisonousCloud = false;
            bool flagCanBurrow           = false;
            bool flagCanStamina          = false;
            bool flagCanHorrorize        = false;
            bool flagCanMechaBlast       = false;
            bool flagCanKeenSenses       = false;
            bool flagCanCatReflexes      = false;



            bool flagIsMindControlBuildingPresent = false;

            if (flagIsCreatureDraftable)
            {
                /*Inside here, I check if the Building is present in the map. I only want to do the check for
                 * hybrids, or it will do this iterator for every creature in the map
                 */
                foreach (Thing t in pawn.Map.listerThings.ThingsOfDef(ThingDef.Named("GR_AnimalControlHub")))
                {
                    Thing mindcontrolhub = t as Thing;
                    if (t != null)
                    {
                        flagIsCreatureRageable         = pawn.TryGetComp <CompDraftable>().GetRage;
                        flagIsCreatureExplodable       = pawn.TryGetComp <CompDraftable>().GetExplodable;
                        flagIsCreatureChickenRimPox    = pawn.TryGetComp <CompDraftable>().GetChickenRimPox;
                        flagCanCreatureCarryMore       = pawn.TryGetComp <CompDraftable>().GetCanCarryMore;
                        flagCanCreatureAdrenalineBurst = pawn.TryGetComp <CompDraftable>().GetAdrenalineBurst;
                        flagCanCanDoInsectClouds       = pawn.TryGetComp <CompDraftable>().GetCanDoInsectClouds;
                        flagCanStampede         = pawn.TryGetComp <CompDraftable>().GetCanStampede;
                        flagCanDoPoisonousCloud = pawn.TryGetComp <CompDraftable>().GetCanDoPoisonousCloud;
                        flagCanBurrow           = pawn.TryGetComp <CompDraftable>().GetCanBurrow;
                        flagCanStamina          = pawn.TryGetComp <CompDraftable>().HasDinoStamina;
                        flagCanHorrorize        = pawn.TryGetComp <CompDraftable>().GetHorror;
                        flagCanMechaBlast       = pawn.TryGetComp <CompDraftable>().GetMechablast;
                        flagCanKeenSenses       = pawn.TryGetComp <CompDraftable>().GetKeenSenses;
                        flagCanCatReflexes      = pawn.TryGetComp <CompDraftable>().GetCatReflexes;


                        flagIsMindControlBuildingPresent = true;
                    }
                }
            }


            /*Is the creature part of the colony, and draftable (the custom comp class)? Then display the drafting gizmo, called
             * Mind Control. It's action is just calling on toggle the Drafted method in the pawn's drafter, which
             * we initialized in the first Harmony Postfix
             */
            if ((pawn.drafter != null) && flagIsCreatureMine && flagIsCreatureDraftable && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_MindControl = new Command_Action();
                GR_Gizmo_MindControl.action = delegate
                {
                    pawn.drafter.Drafted = !pawn.drafter.Drafted;
                };
                GR_Gizmo_MindControl.defaultLabel = "GR_CreatureMindControl".Translate();
                GR_Gizmo_MindControl.defaultDesc  = "GR_CreatureMindControlDesc".Translate();
                GR_Gizmo_MindControl.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_ControlAnimal", true);

                gizmos.Insert(0, GR_Gizmo_MindControl);
            }

            /*If the creature is draftable, drafted at the moment and the rage property (which is passed through XML and the custom comp class) is true,
             * we add a second gizmo, which copies the code from melee attacks, and thus allows targeting melee attacks
             */
            if ((pawn.drafter != null) && flagIsCreatureRageable && flagIsCreatureMine && pawn.drafter.Drafted && flagIsMindControlBuildingPresent)
            {
                Command_Target GR_Gizmo_AttackRage = new Command_Target();
                GR_Gizmo_AttackRage.defaultLabel    = "GR_CreatureRageAttack".Translate();
                GR_Gizmo_AttackRage.defaultDesc     = "GR_CreatureRageAttackDesc".Translate();
                GR_Gizmo_AttackRage.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_AttackRage.icon            = ContentFinder <Texture2D> .Get("Things/Item/AnimalPaws", true);

                GR_Gizmo_AttackRage.action = delegate(Thing target)
                {
                    IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                    {
                        Pawn pawn2 = x as Pawn;
                        return(pawn2 != null && pawn2.Drafted);
                    }).Cast <Pawn>();
                    foreach (Pawn current in enumerable)
                    {
                        Job  job   = new Job(JobDefOf.AttackMelee, target);
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            job.killIncappedTarget = pawn2.Downed;
                        }
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_AttackRage);
            }

            /*This adds a gizmo that makes the creature attack once, and then cause a Hediff disease (GR_ChickenRimPox), then cancels the draft. I used a custom Jobdriver class for that
             */
            if ((pawn.drafter != null) && flagIsCreatureChickenRimPox && flagIsCreatureMine && pawn.drafter.Drafted && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Target GR_Gizmo_AttackPox = new Command_Target();
                GR_Gizmo_AttackPox.defaultLabel    = "GR_InflictChickenRimPox".Translate();
                GR_Gizmo_AttackPox.defaultDesc     = "GR_InflictChickenRimPoxDesc".Translate();
                GR_Gizmo_AttackPox.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_AttackPox.icon            = ContentFinder <Texture2D> .Get("ui/commands/GR_ChickenRimPox", true);

                GR_Gizmo_AttackPox.action = delegate(Thing target)
                {
                    IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                    {
                        Pawn pawn2 = x as Pawn;
                        return(pawn2 != null && pawn2.Drafted);
                    }).Cast <Pawn>();
                    foreach (Pawn current in enumerable)
                    {
                        Job  job   = new Job(DefDatabase <JobDef> .GetNamed("GR_AttackMeleeOnceAndChickenRimPox", true), target);
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            job.killIncappedTarget = pawn2.Downed;
                        }
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_AttackPox);
            }

            /*If the creature is explodable, we add this gizmo, which causes a Heddif called "sudden explosion" (GR_Kamikaze), and increases severity to
             * 1 to make the creature die. This only works if the creature also has DeathActionWorker.
             */
            if ((pawn.drafter != null) && flagIsCreatureExplodable && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_Detonate = new Command_Action();
                GR_Gizmo_Detonate.action = delegate
                {
                    pawn.health.AddHediff(HediffDef.Named("GR_Kamikaze"));
                    HealthUtility.AdjustSeverity(pawn, HediffDef.Named("GR_Kamikaze"), 1);
                };
                GR_Gizmo_Detonate.defaultLabel = "GR_DetonateChemfuel".Translate();
                GR_Gizmo_Detonate.defaultDesc  = "GR_DetonateChemfuelDesc".Translate();
                GR_Gizmo_Detonate.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Detonate", true);

                gizmos.Insert(1, GR_Gizmo_Detonate);
            }

            /* This is a dummy gizmo. It only displays, but does nothing on click. The processing is done below in another Harmony patch to MassUtility.Capacity
             */
            if ((pawn.drafter != null) && flagCanCreatureCarryMore && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_Carry = new Command_Action();
                GR_Gizmo_Carry.action = delegate
                {
                };
                GR_Gizmo_Carry.defaultLabel = "GR_CarryMore".Translate();
                GR_Gizmo_Carry.defaultDesc  = "GR_CarryMoreDesc".Translate();
                GR_Gizmo_Carry.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_IncreasedCarry", true);

                gizmos.Insert(1, GR_Gizmo_Carry);
            }

            /*This gizmo applies a Hediff that makes the pawn move faster for a while
             */
            if ((pawn.drafter != null) && flagCanCreatureAdrenalineBurst && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_AdrenalineBurst = new Command_Action();
                GR_Gizmo_AdrenalineBurst.defaultLabel = "GR_StartAdrenalineBurst".Translate();
                GR_Gizmo_AdrenalineBurst.defaultDesc  = "GR_StartAdrenalineBurstDesc".Translate();
                GR_Gizmo_AdrenalineBurst.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_AdrenalineBurst", true);

                GR_Gizmo_AdrenalineBurst.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_AdrenalineBurst")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_AdrenalineBurst"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_AdrenalineBurst);
            }

            /*This gizmo applies a Hediff that makes the pawn release insect clouds for a while
             */
            if ((pawn.drafter != null) && flagCanCanDoInsectClouds && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_InsectClouds = new Command_Action();
                GR_Gizmo_InsectClouds.defaultLabel = "GR_ReleaseInsectClouds".Translate();
                GR_Gizmo_InsectClouds.defaultDesc  = "GR_ReleaseInsectCloudsDesc".Translate();
                GR_Gizmo_InsectClouds.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_Insectclouds", true);

                GR_Gizmo_InsectClouds.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_InsectClouds")))

                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_InsectClouds"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_InsectClouds);
            }

            /*This gizmo applies a Hediff that makes the pawn generate stampede clouds for a while
             */
            if ((pawn.drafter != null) && flagCanStampede && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_Stampede = new Command_Action();
                GR_Gizmo_Stampede.defaultLabel = "GR_StartStampede".Translate();
                GR_Gizmo_Stampede.defaultDesc  = "GR_StartStampedeDesc".Translate();
                GR_Gizmo_Stampede.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_StampedeClouds", true);

                GR_Gizmo_Stampede.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_Stampeding")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_Stampeding"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_Stampede);
            }

            /*This gizmo adds an attack that spawns a poison cloud at a target's location
             */
            if ((pawn.drafter != null) && flagCanDoPoisonousCloud && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Target GR_Gizmo_PoisonCloud = new Command_Target();
                GR_Gizmo_PoisonCloud.defaultLabel    = "GR_CreatePoisonousCloud".Translate();
                GR_Gizmo_PoisonCloud.defaultDesc     = "GR_CreatePoisonousCloudDesc".Translate();
                GR_Gizmo_PoisonCloud.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_PoisonCloud.icon            = ContentFinder <Texture2D> .Get("ui/commands/GR_PoisonousCloud", true);

                GR_Gizmo_PoisonCloud.action = delegate(Thing target)
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CausedPoisonCloud")))
                    {
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            if (pawn.Position.InHorDistOf(pawn2.Position, 10))
                            {
                                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                                for (int i = 0; i < 8; i++)
                                {
                                    IntVec3 c2 = pawn2.Position + list[i];
                                    if (c2.InBounds(pawn2.Map))
                                    {
                                        Thing thing = ThingMaker.MakeThing(ThingDef.Named("GR_Poison_Cloud"), null);

                                        GenSpawn.Spawn(thing, c2, pawn2.Map);
                                    }
                                }
                                pawn.health.AddHediff(HediffDef.Named("GR_CausedPoisonCloud"));
                            }
                            else
                            {
                                Messages.Message("GR_PoisonCloudRange".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                            }
                        }
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_PoisonCloud);
            }

            /*This gizmo puts the creature into burrowing mode
             */
            if ((pawn.drafter != null) && flagCanBurrow && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_Burrowing = new Command_Action();
                GR_Gizmo_Burrowing.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_Burrowing")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_Burrowing"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_Burrowing.defaultLabel = "GR_StartBurrowing".Translate();
                GR_Gizmo_Burrowing.defaultDesc  = "GR_StartBurrowingDesc".Translate();
                GR_Gizmo_Burrowing.icon         = ContentFinder <Texture2D> .Get("Things/Pawn/Animal/Special/GR_Special_Burrowing", true);

                gizmos.Insert(1, GR_Gizmo_Burrowing);
            }

            /*This gizmo makes the animal more resistant for a while
             */
            if ((pawn.drafter != null) && flagCanStamina && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_Stamina = new Command_Action();
                GR_Gizmo_Stamina.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_Stamina")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_Stamina"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_Stamina.defaultLabel = "GR_StartStamina".Translate();
                GR_Gizmo_Stamina.defaultDesc  = "GR_StartStaminaDesc".Translate();
                GR_Gizmo_Stamina.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_Stamina", true);

                gizmos.Insert(1, GR_Gizmo_Stamina);
            }

            /*This gizmo makes the animal more aware (sight and consciousness) for a while
             */
            if ((pawn.drafter != null) && flagCanKeenSenses && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_KeenSenses = new Command_Action();
                GR_Gizmo_KeenSenses.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_KeenSenses")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_KeenSenses"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_KeenSenses.defaultLabel = "GR_StartKeenSenses".Translate();
                GR_Gizmo_KeenSenses.defaultDesc  = "GR_StartKeenSensesDesc".Translate();
                GR_Gizmo_KeenSenses.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_KeenSenses", true);

                gizmos.Insert(1, GR_Gizmo_KeenSenses);
            }

            /*This gizmo activates cat reflexes, improving melee combat
             */
            if ((pawn.drafter != null) && flagCanCatReflexes && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_CatReflexes = new Command_Action();
                GR_Gizmo_CatReflexes.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CatReflexes")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_CatReflexes"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_CatReflexes.defaultLabel = "GR_StartCatReflexes".Translate();
                GR_Gizmo_CatReflexes.defaultDesc  = "GR_StartCatReflexesDesc".Translate();
                GR_Gizmo_CatReflexes.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_CatReflexes", true);

                gizmos.Insert(1, GR_Gizmo_CatReflexes);
            }

            /*This gizmo makes the animal cast a horror ability
             */
            if ((pawn.drafter != null) && flagCanHorrorize && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Target GR_Gizmo_Horror = new Command_Target();
                GR_Gizmo_Horror.defaultLabel    = "GR_StartInvokingInsanity".Translate();
                GR_Gizmo_Horror.defaultDesc     = "GR_StartInvokingInsanityDesc".Translate();
                GR_Gizmo_Horror.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_Horror.icon            = ContentFinder <Texture2D> .Get("Item/Weapon/MiGoCasterWeapon/MiGoCasterWeaponA", true);

                GR_Gizmo_Horror.action = delegate(Thing target)
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CausedHorror")))
                    {
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            if (pawn.Position.InHorDistOf(pawn2.Position, 10))
                            {
                                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                                for (int i = 0; i < 8; i++)
                                {
                                    IntVec3 c2 = pawn2.Position + list[i];
                                    if (c2.InBounds(pawn2.Map))
                                    {
                                        Thing thing = ThingMaker.MakeThing(ThingDef.Named("GR_Insanity_Cloud"), null);

                                        GenSpawn.Spawn(thing, c2, pawn2.Map);
                                    }
                                }
                                pawn.health.AddHediff(HediffDef.Named("GR_CausedHorror"));
                            }
                            else
                            {
                                Messages.Message("GR_InvokingInsanityRange".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                            }
                        }
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_Horror);
            }

            /*This gizmo makes the animal release a burning explosion
             */
            if ((pawn.drafter != null) && flagCanMechaBlast && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_MechaBlast = new Command_Action();
                GR_Gizmo_MechaBlast.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_VentedExhaust")))
                    {
                        foreach (IntVec3 c in GenAdj.CellsAdjacent8Way(pawn))
                        {
                            GenExplosion.DoExplosion(c, pawn.Map, (float)0.25, DamageDefOf.Flame, pawn, 25, 5, null, null, null, null, ThingDef.Named("Filth_Ash"), .7f, 1, false, null, 0f, 1);
                        }


                        pawn.health.AddHediff(HediffDef.Named("GR_VentedExhaust"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_MechaBlast.defaultLabel = "GR_StartMechaBlast".Translate();
                GR_Gizmo_MechaBlast.defaultDesc  = "GR_StartMechaBlastDesc".Translate();
                GR_Gizmo_MechaBlast.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_MechaBlast", true);

                gizmos.Insert(1, GR_Gizmo_MechaBlast);
            }

            /*This gizmo activates the orbital beam
             */
            if ((pawn.drafter != null) && flagIsCreatureMine && pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Target GR_Gizmo_Orbital = new Command_Target();
                GR_Gizmo_Orbital.defaultLabel    = "GR_Orbital".Translate();
                GR_Gizmo_Orbital.defaultDesc     = "GR_OrbitalDesc".Translate();
                GR_Gizmo_Orbital.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_Orbital.icon            = ContentFinder <Texture2D> .Get("ui/commands/GR_Orbital", true);

                GR_Gizmo_Orbital.action = delegate(Thing target)
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CausedPowerBeam")))
                    {
                        if (target.Map == pawn.Map)
                        {
                            PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(ThingDefOf.PowerBeam, target.Position, pawn.Map, WipeMode.Vanish);
                            powerBeam.duration   = 600;
                            powerBeam.instigator = pawn;
                            powerBeam.weaponDef  = null;
                            powerBeam.StartStrike();
                            pawn.health.AddHediff(HediffDef.Named("GR_CausedPowerBeam"));
                        }
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_Orbital);
            }



            __result = gizmos;
        }
            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);
            }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            if (TargetA.Thing is Pawn targetPawn)
            {
                Toil toilGoto = null;
                toilGoto            = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell);
                toilGoto.tickAction = delegate()
                {
                    JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 0.3f, null);
                };
                yield return(toilGoto);
            }
            else
            {
                Toil reserveTargetA = Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null);
                yield return(reserveTargetA);

                Toil toilGoto = null;
                toilGoto            = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnSomeonePhysicallyInteracting(TargetIndex.A);
                toilGoto.tickAction = delegate()
                {
                    JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 0.3f, null);
                };
                yield return(toilGoto);
            }

            Toil takePhoto = new Toil();

            takePhoto.initAction = delegate()
            {
                if (pawn.equipment.Primary == null && pawn.equipment.AllEquipmentListForReading.Find(e => e.def == RWBYDefOf.RWBY_Anesidora_Box) is ThingWithComps thingWithComps)
                {
                    thingWithComps.TryGetComp <CompWeaponTransform>().Transform();
                }
                pawn.needs.joy.GainJoy(0.07f, JoyKindDefOf.Social);

                Verb_ShootWeaponAbility verb_ShootWeaponAbility = new Verb_ShootWeaponAbility
                {
                    verbTracker = new VerbTracker(pawn),
                    caster      = pawn,
                    verbProps   = new VerbProperties
                    {
                        accuracyTouch      = 1f,
                        accuracyShort      = 1f,
                        accuracyMedium     = 1f,
                        accuracyLong       = 1f,
                        verbClass          = typeof(Verb_ShootWeaponAbility),
                        hasStandardCommand = true,
                        defaultProjectile  = RWBYDefOf.Bullet_Velvet_Camera,
                        warmupTime         = 2f,
                        range                  = 10f,
                        soundCast              = RWBYDefOf.Shot_Velvet_Camera,
                        burstShotCount         = 1,
                        ticksBetweenBurstShots = 1,
                        muzzleFlashScale       = 0,
                        forcedMissRadius       = 0f,
                    },
                    cannotMiss = true,
                    ammunition = null
                };
                verb_ShootWeaponAbility.verbProps.targetParams = TargetingParameters.ForAttackAny();
                verb_ShootWeaponAbility.TryStartCastOn(TargetA.Thing);
            };
            yield return(takePhoto);

            job.count = 1;
            yield break;
        }
Пример #12
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (User.IsColonist && !User.Drafted)
            {
                yield break;
            }

            Command command;

            if (User.IsColonist)
            {
                command = new CommandTargetedPsionic {
                    Ability         = this,
                    Caster          = User,
                    defaultLabel    = Def.label,
                    defaultDesc     = Def.GizmoDesc,
                    icon            = ContentFinder <Texture2D> .Get(Def.PathToIcon),
                    targetingParams = TargetingParameters.ForAttackAny(),
                };
            }
            else
            {
                command = new CommandIndicator {
                    Ability      = this,
                    Caster       = User,
                    defaultLabel = Def.label,
                    defaultDesc  = Def.GizmoDesc,
                    icon         = ContentFinder <Texture2D> .Get(Def.PathToIcon)
                };
            }

            if (Tracker.Essence < 1e-4)
            {
                command.Disable(EssenceDisableKey.Translate(User.LabelShort, User.health.hediffSet.CountAddedAndImplantedParts()));
            }
            else if (Tracker.PsychicSensitivity < 1e-4)
            {
                command.Disable(SensitivityDisableKey.Translate(User.LabelShort, Tracker.PsychicSensitivity));
            }
            else if (!Tracker.CanUseActiveAbilities())   // Pawn has projection disabled
            {
                command.Disable(ProjectionDisabledKey.Translate(User.LabelShort));
            }
            else if (CooldownTicker > 0)   // We're on cooldown
            {
                command.Disable(OnCooldownKey.Translate(Def.label, CooldownTicker.TicksToHours().ToString("0.0")));
            }
            else if (!Tracker.CanUseEnergy(Def.EnergyPerUse))   // Not enough energy to cast
            {
                command.Disable(NotEnoughEnergyKey.Translate(Def.label, Tracker.CurrentEnergy.ToString("0.0"), Def.EnergyPerUse));
            }
            else if (command is CommandTargetedPsionic psi) // We've got enough energy and we're off cooldown
            {
                psi.action = target => {
                    if (!User.Position.InHorDistOf(target.Position, Def.Range) || !(target is Pawn pawn) || !Def.TargetValidator.IsValidTarget(User, pawn))
                    {
                        return;
                    }
                    // We're in range and have a valid target
                    var job = JobMaker.MakeJob(PsiTechDefOf.PTSingleTargetPsionic, User, pawn);
                    job.verbToUse = Verb;
                    User.jobs.TryTakeOrderedJob(job);
                };
            }

            yield return(command);
        }
Пример #13
0
        public IEnumerable <Command_CastPower> GetPsykerVerbsNewV3()
        {
            //   Log.Message("INIT");
            foreach (PsykerPowerEntry current in this.allpsykerPowers)
            {
                //      Log.Message("A");
                if (PsykerHasEquipment(current))
                {
                    Verb_CastWarpPower newverb = (Verb_CastWarpPower)Activator.CreateInstance(current.psykerPowerDef.MainVerb.verbClass);
                    newverb.caster    = this.psyker;
                    newverb.verbProps = current.psykerPowerDef.MainVerb;
                    //      Log.Message("B");

                    Command_CastPower command_CastPower = new Command_CastPower(this);
                    command_CastPower.verb         = newverb;
                    command_CastPower.defaultLabel = current.psykerPowerDef.LabelCap;
                    command_CastPower.defaultDesc  = current.psykerPowerDef.description;
                    //         Log.Message("C");
                    command_CastPower.targetingParams = TargetingParameters.ForAttackAny();
                    if (newverb.warpverbprops.PsykerPowerCategory == PsykerPowerTargetCategory.TargetSelf || newverb.warpverbprops.PsykerPowerCategory == PsykerPowerTargetCategory.TargetAoE)
                    {
                        command_CastPower.targetingParams = TargetingParameters.ForSelf(this.psyker);
                    }
                    // Log.Message("C2");
                    command_CastPower.icon = current.psykerPowerDef.uiIcon;
                    //         Log.Message("D1");
                    string str;
                    if (FloatMenuUtility.GetAttackAction(this.psyker, LocalTargetInfo.Invalid, out str) == null)
                    {
                        command_CastPower.Disable(str.CapitalizeFirst() + ".");
                    }
                    //         Log.Message("D");
                    command_CastPower.action = delegate(Thing target)
                    {
                        CompPsyker.TryCastPowerAction(psyker, target, this, newverb, current.psykerPowerDef as PsykerPowerDef)?.Invoke();
                    };
                    if (newverb.caster.Faction != Faction.OfPlayer)
                    {
                        command_CastPower.Disable("CannotOrderNonControlled".Translate());
                    }
                    if (newverb.CasterIsPawn)
                    {
                        if (newverb.CasterPawn.story.DisabledWorkTags.Contains(WorkTags.Violent))
                        {
                            command_CastPower.Disable("IsIncapableOfViolence".Translate(new object[]
                            {
                                newverb.CasterPawn.NameStringShort
                            }));
                        }
                        else if (!newverb.CasterPawn.drafter.Drafted)
                        {
                            command_CastPower.Disable("IsNotDrafted".Translate(new object[]
                            {
                                newverb.CasterPawn.NameStringShort
                            }));
                        }
                        else if (!this.IsActive)
                        {
                            command_CastPower.Disable("PsykerPowerRecharging".Translate(new object[]
                            {
                                newverb.CasterPawn.NameStringShort
                            }));
                        }
                    }
                    yield return(command_CastPower);
                }
            }
            yield break;
        }
Пример #14
0
        public IEnumerable <Command_CastPower> GetPsykerVerbsNew()
        {
            foreach (KeyValuePair <PsykerPower, Verb_CastWarpPower> entry in this.psykerPowers)
            {
                Verb_CastWarpPower newverb = entry.Value;
                newverb.caster    = this.psyker;
                newverb.verbProps = entry.Value.verbProps;

                Command_CastPower command_CastPower = new Command_CastPower(this);
                command_CastPower.verb            = newverb;
                command_CastPower.defaultLabel    = entry.Key.def.LabelCap;
                command_CastPower.defaultDesc     = entry.Key.def.description;
                command_CastPower.targetingParams = TargetingParameters.ForAttackAny();
                if (newverb.warpverbprops.PsykerPowerCategory == PsykerPowerTargetCategory.TargetSelf || newverb.warpverbprops.PsykerPowerCategory == PsykerPowerTargetCategory.TargetAoE)
                {
                    command_CastPower.targetingParams = TargetingParameters.ForSelf(this.psyker);
                }
                command_CastPower.icon = entry.Key.def.uiIcon;
                string str;
                if (FloatMenuUtility.GetAttackAction(this.psyker, LocalTargetInfo.Invalid, out str) == null)
                {
                    command_CastPower.Disable(str.CapitalizeFirst() + ".");
                }
                command_CastPower.action = delegate(Thing target)
                {
                    Action attackAction = CompPsyker.TryCastPowerAction(psyker, target, this, newverb, entry.Key.def as PsykerPowerDef);
                    if (attackAction != null)
                    {
                        attackAction();
                    }
                };
                if (newverb.caster.Faction != Faction.OfPlayer)
                {
                    command_CastPower.Disable("CannotOrderNonControlled".Translate());
                }
                if (newverb.CasterIsPawn)
                {
                    if (newverb.CasterPawn.story.DisabledWorkTags.Contains(WorkTags.Violent))
                    {
                        command_CastPower.Disable("IsIncapableOfViolence".Translate(new object[]
                        {
                            newverb.CasterPawn.NameStringShort
                        }));
                    }
                    else if (!newverb.CasterPawn.drafter.Drafted)
                    {
                        command_CastPower.Disable("IsNotDrafted".Translate(new object[]
                        {
                            newverb.CasterPawn.NameStringShort
                        }));
                    }
                    else if (!this.IsActive)
                    {
                        command_CastPower.Disable("PsykerPowerRecharging".Translate(new object[]
                        {
                            newverb.CasterPawn.NameStringShort
                        }));
                    }
                }
                yield return(command_CastPower);
            }
            yield break;
        }