Ejemplo n.º 1
0
        protected override bool TryCastShot()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Items with jump capability are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 550187797);
                return(false);
            }
#pragma warning disable CS0436 // Type conflicts with imported type
            CompReloadable reloadableCompSource = base.ReloadableCompSource;
#pragma warning restore CS0436 // Type conflicts with imported type
            Pawn casterPawn = CasterPawn;
            if (casterPawn == null || reloadableCompSource == null || !reloadableCompSource.CanBeUsed)
            {
                return(false);
            }
            //	Log.Message("reloadableCompSource " + reloadableCompSource.Props.chargeNoun);
            IntVec3            cell           = currentTarget.Cell;
            Map                map            = casterPawn.Map;
            CompReloadableDual reloadableDual = reloadableCompSource as CompReloadableDual;
            if (reloadableDual != null)
            {
                if (this.verbProps.label == reloadableDual.Props.chargeNoun)
                {
                    reloadableDual.UsedOnce();
                    //	Log.Message("reloadableDual UsedOnce " + reloadableDual.RemainingCharges);
                }
                else
                if (this.verbProps.label == reloadableDual.Props.chargeNounSecondry)
                {
                    reloadableDual.UsedOnceSecondry();
                    //	Log.Message("reloadableDual UsedOnceSecondry " + reloadableDual.RemainingChargesSecondry);
                }
            }
            else
            {
                if (this.verbProps.label == reloadableCompSource.Props.chargeNoun)
                {
                    reloadableCompSource.UsedOnce();
                    //	Log.Message("reloadableCompSource UsedOnce " + reloadableCompSource.RemainingCharges);
                }
            }
            PawnFlyer pawnFlyer = PawnFlyer.MakeFlyer(verbProps.defaultProjectile ?? ThingDefOf.PawnJumper, casterPawn, cell);
            if (pawnFlyer != null)
            {
                GenSpawn.Spawn(pawnFlyer, cell, map);
                return(true);
            }
            return(false);
        }
        public override void Cast(LocalTargetInfo target)
        {
            base.Cast(target);

            LongEventHandler.QueueLongEvent(() =>
            {
                IntVec3 destination = target.Cell + ((this.pawn.Position - target.Cell).ToVector3().normalized * 2).ToIntVec3();
                Map map             = this.pawn.Map;

                AbilityPawnFlyer flyer = (AbilityPawnFlyer)PawnFlyer.MakeFlyer(InternalDefOf.GR_StraightFlyer, this.pawn, destination);
                flyer.ability          = this;
                flyer.target           = destination.ToVector3();
                GenSpawn.Spawn(flyer, target.Cell, map);
                target.Thing.TakeDamage(new DamageInfo(DamageDefOf.Cut, this.GetPowerForPawn(), float.MaxValue, instigator: this.pawn));
            }, "chargeAbility", false, null);
        }
Ejemplo n.º 3
0
        protected override bool TryCastShot()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce(
                    "Items with jump capability are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.",
                    550187797);
                return(false);
            }

            var casterPawn = CasterPawn;

            var cell      = currentTarget.Cell;
            var map       = casterPawn.Map;
            var pawnFlyer = PawnFlyer.MakeFlyer(ThingDefOf.PawnJumper, casterPawn, cell);

            if (pawnFlyer != null)
            {
                GenSpawn.Spawn(pawnFlyer, cell, map);
                return(true);
            }

            return(false);
        }