// Clicking functionality.
        private void ItemBoxClick(UIMouseEvent evt, UIElement e)
        {
            // No failsafe. Should maybe be implemented?
            PowerBeam powerBeamTarget = Main.LocalPlayer.inventory[((MetroidMod)MetroidMod.Instance).selectedItem].modItem as PowerBeam;

            if (powerBeamTarget.beamMods[addonSlotType] != null && !powerBeamTarget.beamMods[addonSlotType].IsAir)
            {
                if (Main.mouseItem.IsAir)
                {
                    Main.PlaySound(SoundID.Grab);
                    Main.mouseItem = powerBeamTarget.beamMods[addonSlotType].Clone();

                    powerBeamTarget.beamMods[addonSlotType].TurnToAir();
                }
                else if (condition == null || (condition != null && condition(Main.mouseItem)))
                {
                    Main.PlaySound(SoundID.Grab);

                    Item tempBoxItem   = powerBeamTarget.beamMods[addonSlotType].Clone();
                    Item tempMouseItem = Main.mouseItem.Clone();

                    powerBeamTarget.beamMods[addonSlotType] = tempMouseItem;
                    Main.mouseItem = tempBoxItem;
                }
            }
            else if (!Main.mouseItem.IsAir)
            {
                if (condition == null || (condition != null && condition(Main.mouseItem)))
                {
                    Main.PlaySound(SoundID.Grab);
                    powerBeamTarget.beamMods[addonSlotType] = Main.mouseItem.Clone();
                    Main.mouseItem.TurnToAir();
                }
            }
        }
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            PowerBeam powerBeamTarget = Main.LocalPlayer.inventory[((MetroidMod)MetroidMod.Instance).selectedItem].modItem as PowerBeam;

            spriteBatch.Draw(itemBoxTexture, drawRectangle, Color.White);

            // Item drawing.
            if (powerBeamTarget.beamMods[addonSlotType].IsAir)
            {
                return;
            }

            Color           itemColor       = powerBeamTarget.beamMods[addonSlotType].GetAlpha(Color.White);
            Texture2D       itemTexture     = Main.itemTexture[powerBeamTarget.beamMods[addonSlotType].type];
            CalculatedStyle innerDimensions = base.GetDimensions();

            if (base.IsMouseHovering)
            {
                Main.hoverItemName = powerBeamTarget.beamMods[addonSlotType].Name;
                Main.HoverItem     = powerBeamTarget.beamMods[addonSlotType].Clone();
            }

            var frame = Main.itemAnimations[powerBeamTarget.beamMods[addonSlotType].type] != null
                                                ? Main.itemAnimations[powerBeamTarget.beamMods[addonSlotType].type].GetFrame(itemTexture)
                                                : itemTexture.Frame(1, 1, 0, 0);

            float drawScale = 1f;

            if ((float)frame.Width > innerDimensions.Width || (float)frame.Height > innerDimensions.Width)
            {
                if (frame.Width > frame.Height)
                {
                    drawScale = innerDimensions.Width / (float)frame.Width;
                }
                else
                {
                    drawScale = innerDimensions.Width / (float)frame.Height;
                }
            }

            var unreflectedScale = drawScale;
            var tmpcolor         = Color.White;

            ItemSlot.GetItemLight(ref tmpcolor, ref drawScale, powerBeamTarget.beamMods[addonSlotType].type);

            Vector2 drawPosition = new Vector2(innerDimensions.X, innerDimensions.Y);

            drawPosition.X += (float)innerDimensions.Width * 1f / 2f - (float)frame.Width * drawScale / 2f;
            drawPosition.Y += (float)innerDimensions.Height * 1f / 2f - (float)frame.Height * drawScale / 2f;

            spriteBatch.Draw(itemTexture, drawPosition, new Rectangle?(frame), itemColor, 0f,
                             Vector2.Zero, drawScale, SpriteEffects.None, 0f);

            if (powerBeamTarget.beamMods[addonSlotType].color != default(Color))
            {
                spriteBatch.Draw(itemTexture, drawPosition, new Rectangle?(frame), itemColor, 0f,
                                 Vector2.Zero, drawScale, SpriteEffects.None, 0f);
            }
        }
        public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
        {
            base.Apply(target, dest);

            PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(ThingDefOf.PowerBeam, target.Cell, parent.pawn.Map, WipeMode.Vanish);

            powerBeam.duration   = Props.duration;
            powerBeam.instigator = parent.pawn;
            powerBeam.weaponDef  = null;
            powerBeam.StartStrike();
        }
Exemple #4
0
 protected PowerBeam GetPowerBeam()
 {
     if (mPowerBeam == null)
     {
         GameObject newBeam = GameObject.Instantiate(FXManager.Get.BeamPrefab) as GameObject;
         mPowerBeam                         = newBeam.GetComponent <PowerBeam> ();
         mPowerBeam.WarmUpColor             = Colors.Alpha(Color.white, 0.1f);
         mPowerBeam.FireColor               = Colors.Alpha(Colors.Get.ByName("RawLuminiteLightColor"), 0.1f);
         mPowerBeam.RequiresOriginAndTarget = false;
     }
     return(mPowerBeam);
 }
        public override void Execute(int amount, string boughtBy)
        {
            Map currentMap = Find.CurrentMap;

            CellRect cellRect = CellRect.WholeMap(currentMap).ContractedBy(30);

            if (cellRect.IsEmpty)
            {
                cellRect = CellRect.WholeMap(currentMap);
            }

            IntVec3 location;

            if (CellFinder.TryFindRandomCellInsideWith(cellRect, (IntVec3 x) => true, out location))
            {
                PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(ThingDefOf.PowerBeam, location, currentMap);
                powerBeam.duration = 600;
                powerBeam.StartStrike();
                AlertManager.BadEventNotification("A bombardment from space", location);
            }
        }
        protected override void DrawSelf(SpriteBatch sb)
        {
            PowerBeam powerBeamTarget = Main.LocalPlayer.inventory[((MetroidMod)MetroidMod.Instance).selectedItem].modItem as PowerBeam;

            if (powerBeamTarget != null && (powerBeamTarget.comboError1 || powerBeamTarget.comboError2 || powerBeamTarget.comboError3 || powerBeamTarget.comboError4))
            {
                MPlayer mp = Main.LocalPlayer.GetModPlayer <MPlayer>();

                if (base.IsMouseHovering)
                {
                    string text = "Error: addon version mistmatch detected.\n" +
                                  "The following slots have had their addon effects disabled:";
                    if (powerBeamTarget.comboError1)
                    {
                        text = text + "\nSecondary";
                    }
                    if (powerBeamTarget.comboError2)
                    {
                        text = text + "\nUtility";
                    }
                    if (powerBeamTarget.comboError3)
                    {
                        text = text + "\nPrimary A";
                    }
                    if (powerBeamTarget.comboError4)
                    {
                        text = text + "\nPrimary B";
                    }
                    text = text + "\n \n" +
                           "Note: Addon stat bonuses are still applied.";

                    Main.hoverItemName = text;
                }

                sb.Draw(iconTex, drawRectangle, Color.White);
            }
        }
Exemple #7
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;
        }
Exemple #8
0
        public override void MapComponentTick()
        {
            base.MapComponentTick();
            if (Find.TickManager.TicksGame % 250 == 0)
            {
                var plants = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy);
                //Log.Message("Checking orbital strike, " + this.OrbitalHelpActive + " - " + plants.Count);
                if (plants != null && ((this.OrbitalHelpActive == true && plants.Count > 0) ||
                                       plants.Count > 2000)) // && Rand.Chance(PurpleIvyData.getFogProgress(plants.Count)))
                {
                    if (this.OrbitalHelpActive == false)
                    {
                        this.OrbitalHelpActive = true;
                        Find.LetterStack.ReceiveLetter("OrbitalHelpFromAncients".Translate(),
                                                       "OrbitalHelpFromAncientsDesc".Translate(),
                                                       LetterDefOf.NeutralEvent, new TargetInfo(plants.RandomElement().Position, map, false));
                    }
                    PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(PurpleIvyDefOf.PI_PowerBeam,
                                                                    plants.RandomElement().Position, this.map, 0);
                    powerBeam.duration   = 200;
                    powerBeam.instigator = null;
                    powerBeam.weaponDef  = null;
                    powerBeam.StartStrike();
                }
                if ((plants.Count <= 0 || plants == null) && this.OrbitalHelpActive == true)
                {
                    Log.Message("Orbital help");
                    this.OrbitalHelpActive = false;
                    List <Pawn> list = new List <Pawn>();

                    var alpha = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha);
                    var beta  = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta);
                    var gamma = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma);
                    var omega = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega);
                    var guard = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard);

                    int pawnCount = alpha.Count;
                    pawnCount += beta.Count;
                    pawnCount += gamma.Count;
                    pawnCount += omega.Count;
                    pawnCount += guard.Count;
                    Predicate <IntVec3> predicate = delegate(IntVec3 c)
                    {
                        return(!GridsUtility.Fogged(c, map) &&
                               !GridsUtility.Roofed(c, map) &&
                               GenGrid.InBounds(c, map) &&
                               GenRadial.RadialCellsAround(c, 10, true).Where(x =>
                                                                              map.thingGrid.ThingsListAt(x).Where(y => y.Faction == PurpleIvyData.AlienFaction)
                                                                              != null) != null);
                    };
                    IntVec3 position = CellFinder.RandomClosewalkCellNear(this.map.Center, this.map, 500,
                                                                          predicate);
                    foreach (var num in Enumerable.Range(1, pawnCount / 2))
                    {
                        Faction faction = FactionUtility.DefaultFactionFrom(PurpleIvyDefOf.KorsolianFaction);
                        Pawn    NewPawn = PawnGenerator.GeneratePawn(PurpleIvyDefOf.KorsolianSoldier, faction);
                        if (faction != null && faction != Faction.OfPlayer)
                        {
                            Lord lord = null;
                            if (this.map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) =>
                                                                                     p != NewPawn))
                            {
                                lord = ((Pawn)GenClosest.ClosestThing_Global(NewPawn.Position,
                                                                             this.map.mapPawns.SpawnedPawnsInFaction(faction), 99999f,
                                                                             (Thing p) => p != NewPawn && ((Pawn)p).GetLord() != null, null)).GetLord();
                            }
                            if (lord == null)
                            {
                                var lordJob = new LordJob_AssistColony(Faction.OfPlayer, position);
                                //LordJob_DefendPoint lordJob = new LordJob_DefendPoint(position);
                                lord = LordMaker.MakeNewLord(faction, lordJob, this.map, null);
                            }
                            lord.AddPawn(NewPawn);
                        }
                        Log.Message(NewPawn?.Faction?.def?.defName);
                        list.Add(NewPawn);
                    }
                    DropPodUtility.DropThingsNear(position, this.map, list, 30, false, true, true, true);
                    Find.LetterStack.ReceiveLetter("AncientsLandOnTheGround".Translate(),
                                                   "AncientsLandOnTheGroundDesc".Translate(),
                                                   LetterDefOf.NeutralEvent, new TargetInfo(position, map, false));
                }
                //Log.Message("Alpha limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName]);
                //Log.Message("Beta limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName]);
                //Log.Message("Gamma limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName]);
                //Log.Message("Omega limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName]);
                int  count = plants.Count;
                bool comeFromOuterSource;
                var  tempComp = new WorldObjectComp_InfectedTile();
                tempComp.infectedTile = map.Tile;
                if (PurpleIvyUtils.getFogProgressWithOuterSources(count, tempComp, out comeFromOuterSource) > 0f &&
                    !map.gameConditionManager.ConditionIsActive(PurpleIvyDefOf.PurpleFogGameCondition))
                {
                    GameCondition_PurpleFog gameCondition =
                        (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent
                            (PurpleIvyDefOf.PurpleFogGameCondition);
                    map.gameConditionManager.RegisterCondition(gameCondition);
                    if (comeFromOuterSource == false)
                    {
                        Find.LetterStack.ReceiveLetter(gameCondition.LabelCap,
                                                       gameCondition.LetterText, gameCondition.def.letterDef,
                                                       new TargetInfo(map.Center, map, false));
                    }
                    else
                    {
                        Find.LetterStack.ReceiveLetter("PurpleFogСomesFromInfectedSites".Translate(),
                                                       "PurpleFogСomesFromInfectedSitesDesc".Translate(),
                                                       LetterDefOf.ThreatBig, new TargetInfo(map.Center, map, false));
                        Log.Message("PurpleFogСomesFromInfectedSites: " + map.ToString()
                                    + " - " + Find.TickManager.TicksGame.ToString());
                    }
                    if (map.Parent.GetComponent <WorldObjectComp_InfectedTile>() == null)
                    {
                        var comp = new WorldObjectComp_InfectedTile();
                        comp.parent = map.Parent;
                        comp.StartInfection();
                        comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition;
                        comp.counter             = count;
                        comp.infectedTile        = map.Tile;
                        comp.radius = comp.GetRadius();
                        PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter);
                        comp.fillRadius();
                        map.Parent.AllComps.Add(comp);
                        Log.Message("Adding comp to: " + map.Parent.ToString());
                    }
                }
            }
            if (Find.TickManager.TicksGame % 60000 == 0)
            {
                int count     = 0;
                var alphaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac);
                var betaEggs  = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta);
                var gammaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma);
                var nestsEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard);
                var omegaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg);

                Log.Message("Total PurpleIvy count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count.ToString(), true);

                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName])
                {
                    foreach (var egg in alphaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in alphaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteAlpha count on the map: " + count.ToString(), true);
                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName])
                {
                    foreach (var egg in betaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in betaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteBeta count on the map: " + count.ToString(), true);
                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName])
                {
                    foreach (var egg in gammaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in gammaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteGamma count on the map: " + count.ToString(), true);
                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName])
                {
                    foreach (var egg in omegaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in omegaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteOmega count on the map: " + count.ToString(), true);
                Log.Message("Total Genny_ParasiteNestGuard count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard).Count.ToString(), true);
                Log.Message("Total EggSac count on the map: " + alphaEggs.Count.ToString(), true);
                Log.Message("Total EggSac beta count on the map: " + betaEggs.Count.ToString(), true);
                Log.Message("Total EggSac gamma count on the map: " + gammaEggs.Count.ToString(), true);
                Log.Message("Total EggSac NestGuard count on the map: " + nestsEggs.Count.ToString(), true);
                Log.Message("Total ParasiteEgg count on the map: " + omegaEggs.Count.ToString(), true);
                Log.Message("Total GasPump count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count.ToString(), true);
                Log.Message("Total GenTurretBase count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count.ToString(), true);
                Log.Message("Total Turret_GenMortarSeed count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count.ToString(), true);
                Log.Message("Total Nest count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count.ToString(), true);
            }
        }
Exemple #9
0
        protected IEnumerator MineResources(bool isMeteor)
        {
            WorldItem thingToGather = null;

            if (isMeteor)
            {
                if (HasMeteorToGather)
                {
                    thingToGather = mMeteorToGather.worlditem;
                }
                else
                {
                    BehaviorState = OrbBehaviorState.ConsideringOptions;
                    yield break;
                }
            }
            else
            {
                if (HasLuminiteToGather)
                {
                    thingToGather = mLuminiteToGather.worlditem;
                }
                else
                {
                    BehaviorState = OrbBehaviorState.ConsideringOptions;
                }
                yield break;
            }

            //Debug.Log ("Starting item mining process");

            double     startEatTime     = WorldClock.AdjustedRealTime;
            double     finishMiningTime = WorldClock.AdjustedRealTime + MeteorEatTime;
            float      damageOnStart    = 0f;
            Damageable itemDamageable   = thingToGather.Get <Damageable> ();

            if (itemDamageable != null)
            {
                damageOnStart = itemDamageable.NormalizedDamage;
            }

            MotileAction waitAction = creature.WatchThingAction(thingToGather);

            waitAction.Expiration = MotileExpiration.TargetOutOfRange;
            waitAction.OutOfRange = 25f;

            OrbSpeak(OrbSpeakUnit.MiningLuminite, worlditem.tr);

            bool keepMining = true;

            while (keepMining)
            {
                if (mPowerBeam == null)
                {
                    mPowerBeam = GetPowerBeam();
                }
                mPowerBeam.AttachTo(LuminiteGemPivot, thingToGather);
                mPowerBeam.WarmUp();
                mPowerBeam.Fire(0.45f);

                if (waitAction.IsFinished || waitAction.LiveTarget != thingToGather)
                {
                    //something has interrupted us
                    //Debug.Log ("Wait action was finished or had a different target, stopping motile action");
                    BehaviorState = OrbBehaviorState.ConsideringOptions;
                }
                else
                {
                    if (itemDamageable != null && itemDamageable.NormalizedDamage > damageOnStart)
                    {
                        //Debug.Log ("Something damaged the meteor, checking out what");
                        mPowerBeam.StopFiring();
                        OrbSpeak(OrbSpeakUnit.TargetBehavingErratically, worlditem.tr);
                        //look at the thing that last hit it
                        ThingToInvestigate = itemDamageable.LastDamageSource;
                        BehaviorState      = OrbBehaviorState.SeekingItemOfInterest;
                    }
                    else if (WorldClock.AdjustedRealTime > finishMiningTime)
                    {
                        //Debug.Log ("Done eating!");
                        //it's toast! kill it
                        //force it to not spawn any items on die
                        FXManager.Get.SpawnExplosionFX(ExplosionType.Base, null, thingToGather.Position);
                        thingToGather.worlditem.RemoveFromGame();
                        if (isMeteor)
                        {
                            NumMeteorsGathered++;
                        }
                        else
                        {
                            NumLuminiteGathered++;
                        }
                    }
                }

                double waitUntil = WorldClock.AdjustedRealTime + 0.125f;
                while (WorldClock.AdjustedRealTime < waitUntil)
                {
                    yield return(null);
                }

                if (isMeteor)
                {
                    keepMining = HasMeteorToGather && thingToGather == MeteorToGather.worlditem && BehaviorState == OrbBehaviorState.EatingMeteor;
                }
                else
                {
                    keepMining = HasLuminiteToGather && thingToGather == MeteorToGather.worlditem && BehaviorState == OrbBehaviorState.EatingLuminite;
                }
            }

            if (mPowerBeam != null)
            {
                mPowerBeam.StopFiring();
            }

            BehaviorState = OrbBehaviorState.ConsideringOptions;
            yield break;
        }