示例#1
0
        private void LanuchWithDamageMultiplier(Projectile projectile2, Thing launcher, Vector3 origin, LocalTargetInfo usedTarget, LocalTargetInfo intendedTarget, ProjectileHitFlags hitFlags, Thing equipment = null, ThingDef targetCoverDef = null)
        {
            projectile2.Launch(launcher, origin, usedTarget, intendedTarget, hitFlags, equipment, targetCoverDef);
            if (EquipmentSource == null)
            {
                return;
            }

            //取消掉精度修正,不管有没有反正null一下
            Patch.Methons.adjustedAccuracyFactor = null;
            if (CompShootMode == null)
            {
                return;
            }
            CompShootMode.PostPostProjectileLaunch(projectile2);
        }
示例#2
0
 /// <summary>
 /// 是否可以射出下一发子弹(包括第一发)
 /// </summary>
 /// <param name="__instance"></param>
 /// <param name="burstShotsLeft">剩下可以射出的子弹数量</param>
 /// <returns>返回true则正常射出,可以修改burstShotsLeft,返回false则无法射出子弹,回到Idle状态,修改burstShotsLeft无效</returns>
 public override bool TryCastNextBurstShot(Verb __instance, ref int burstShotsLeft)
 {
     if (CompVoidNetPort == null)
     {
         return(false);
     }
     if (CompVoidNetPort.CostEnergy(EnergyEachShot))
     {
         if (CompShootMode != null && burstShotsLeft == 1)
         {
             CompShootMode.PostPreLastShoot();
         }
         return(true);
     }
     return(false);
 }
示例#3
0
        //public override void Notify_UsedWeapon(Pawn pawn)
        //{

        //    base.Notify_UsedWeapon(pawn);
        //}


        /// <summary>
        /// 尝试瞄准
        /// </summary>
        /// <param name="__instance">Verb实例</param>
        /// <param name="castTarg"></param>
        /// <param name="destTarg"></param>
        /// <param name="surpriseAttack"></param>
        /// <param name="canHitNonTargetPawns"></param>
        /// <returns>是否可以瞄准</returns>
        public virtual bool TryStartCastOn(Verb __instance,
                                           LocalTargetInfo castTarg, LocalTargetInfo destTarg, bool surpriseAttack = false, bool canHitNonTargetPawns = true)
        {
            int  nt    = Find.TickManager.TicksGame;
            Pawn owner = __instance.CasterPawn;

            if (nt > checkNetTick)
            {
                checkNetTick = nt + 30;
                Things.VoidNetTerminal net = Things.VoidNetTerminal.FindTerminal(owner);
                if (net != null)
                {
                    if (voidNetTerminal == null || (voidNetTerminal != null && voidNetTerminal != net))
                    {
                        net.Online(this);
                    }
                }
                else if (voidNetTerminal != null)
                {
                    voidNetTerminal.Offline(this);
                }
            }

            if (voidNetTerminal == null)
            {
                return(false);
            }
            if (!voidNetTerminal.CanCostEnergy(EnergyEachShot))
            {
                if (nt > slientTick)
                {
                    MoteMaker.ThrowText(owner.Position.ToVector3(), owner.Map, "TerminalOutOfEnergy".Translate(), Color.yellow, 2f);
                    slientTick = nt + 1800;
                }
                return(false);
            }
            if (CompShootMode != null)
            {
                CompShootMode.PostPreStartShoot();
            }

            return(true);
        }
示例#4
0
 /// <summary>
 /// 是否可以射出下一发子弹(包括第一发)
 /// </summary>
 /// <param name="__instance"></param>
 /// <param name="burstShotsLeft">剩下可以射出的子弹数量</param>
 /// <returns>返回true则正常射出,可以修改burstShotsLeft,返回false则无法射出子弹,回到Idle状态,修改burstShotsLeft无效</returns>
 public virtual bool TryCastNextBurstShot(Verb __instance, ref int burstShotsLeft)
 {
     if (voidNetTerminal == null)
     {
         return(false);
     }
     if (voidNetTerminal.CostEnergy(EnergyEachShot))
     {
         if (CompShootMode != null && burstShotsLeft == 1)
         {
             CompShootMode.PostPreLastShoot();
         }
         if (compShootMode != null && burstShotsLeft > 1)
         {
             CompShootMode.PostPreNonLastShoot();
         }
         return(true);
     }
     return(false);
 }
示例#5
0
        // Token: 0x06002252 RID: 8786 RVA: 0x000D128C File Offset: 0x000CF48C
        protected bool base_TryCastShot()
        {
            if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map)
            {
                return(false);
            }
            ThingDef projectile = this.Projectile;

            if (projectile == null)
            {
                return(false);
            }
            ShootLine shootLine;
            bool      flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine);

            if (this.verbProps.stopBurstWithoutLos && !flag)
            {
                return(false);
            }
            if (base.EquipmentSource != null)
            {
                CompChangeableProjectile comp = base.EquipmentSource.GetComp <CompChangeableProjectile>();
                if (comp != null)
                {
                    comp.Notify_ProjectileLaunched();
                }
                //修改精度
                if (CompShootMode != null)
                {
                    CompShootMode.PostPreEachShoot(this);
                }
            }
            Thing        launcher     = this.caster;
            Thing        equipment    = base.EquipmentSource;
            CompMannable compMannable = this.caster.TryGetComp <CompMannable>();

            if (compMannable != null && compMannable.ManningPawn != null)
            {
                launcher  = compMannable.ManningPawn;
                equipment = this.caster;
            }
            Vector3    drawPos     = this.caster.DrawPos;
            Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map, WipeMode.Vanish);

            //强制误差半径,无视技能等级(原版迫击炮)
            if (this.verbProps.forcedMissRadius > 0.5f)
            {
                float num = VerbUtility.CalculateAdjustedForcedMiss(this.verbProps.forcedMissRadius, this.currentTarget.Cell - this.caster.Position);
                if (num > 0.5f)
                {
                    int max  = GenRadial.NumCellsInRadius(num);
                    int num2 = Rand.Range(0, max);
                    if (num2 > 0)
                    {
                        IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num2];
                        this.ThrowDebugText("ToRadius");
                        this.ThrowDebugText("Rad\nDest", c);
                        ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld;
                        if (Rand.Chance(0.5f))
                        {
                            projectileHitFlags = ProjectileHitFlags.All;
                        }
                        if (!this.canHitNonTargetPawnsNow)
                        {
                            projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns;
                        }
                        LanuchWithDamageMultiplier(projectile2, launcher, drawPos, c, this.currentTarget, projectileHitFlags, equipment, null);

                        return(true);
                    }
                }
            }


            ShotReport shotReport            = ShotReport.HitReportFor(this.caster, this, this.currentTarget);
            Thing      randomCoverToMissInto = shotReport.GetRandomCoverToMissInto();
            ThingDef   targetCoverDef        = (randomCoverToMissInto != null) ? randomCoverToMissInto.def : null;

            if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture))
            {
                shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget);
                this.ThrowDebugText("ToWild" + (this.canHitNonTargetPawnsNow ? "\nchntp" : ""));
                this.ThrowDebugText("Wild\nDest", shootLine.Dest);
                ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld;
                if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow)
                {
                    projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns;
                }
                LanuchWithDamageMultiplier(projectile2, launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags2, equipment, targetCoverDef);
                return(true);
            }
            if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance))
            {
                this.ThrowDebugText("ToCover" + (this.canHitNonTargetPawnsNow ? "\nchntp" : ""));
                this.ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position);
                ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld;
                if (this.canHitNonTargetPawnsNow)
                {
                    projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns;
                }
                LanuchWithDamageMultiplier(projectile2, launcher, drawPos, randomCoverToMissInto, this.currentTarget, projectileHitFlags3, equipment, targetCoverDef);
                return(true);
            }
            ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget;

            if (this.canHitNonTargetPawnsNow)
            {
                projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns;
            }
            if (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full)
            {
                projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld;
            }
            this.ThrowDebugText("ToHit" + (this.canHitNonTargetPawnsNow ? "\nchntp" : ""));
            if (this.currentTarget.Thing != null)
            {
                LanuchWithDamageMultiplier(projectile2, launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef);
                this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell);
            }
            else
            {
                LanuchWithDamageMultiplier(projectile2, launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef);
                this.ThrowDebugText("Hit\nDest", shootLine.Dest);
            }
            return(true);
        }