コード例 #1
0
        protected override void Impact()
        {
            var projectile = (Projectile)ThingMaker.MakeThing(artilleryShellDef);

            GenSpawn.Spawn(projectile, Position, Map);
            NonPublicMethods.Projectile_ImpactSomething(projectile);
            base.Impact();
        }
        public void TryLaunch(int destinationTile)
        {
            var arrivalAction = CurrentArrivalAction;

            if (arrivalAction != null)
            {
                arrivalAction.source = parent;
            }

            // Play sounds
            var verb = Turret.CurrentEffectiveVerb;

            if (verb.verbProps.soundCast != null)
            {
                verb.verbProps.soundCast.PlayOneShot(new TargetInfo(parent.Position, parent.Map));
            }
            if (verb.verbProps.soundCastTail != null)
            {
                verb.verbProps.soundCastTail.PlayOneShotOnCamera(parent.Map);
            }

            // Make active artillery strike thing
            var activeArtilleryStrike = (ActiveArtilleryStrike)ThingMaker.MakeThing(ThingDefOf.VFES_ActiveArtilleryStrike);

            activeArtilleryStrike.missRadius = ArtilleryStrikeUtility.FinalisedMissRadius(Turret.CurrentEffectiveVerb.verbProps.ForcedMissRadius, Props.maxForcedMissRadiusFactor, parent.Tile, destinationTile, Props.worldTileRange);

            // Simulate an attack
            if (ChangeableProjectile != null)
            {
                activeArtilleryStrike.shellDef   = ChangeableProjectile.Projectile;
                activeArtilleryStrike.shellCount = 1;
                ChangeableProjectile.Notify_ProjectileLaunched();
            }
            else
            {
                activeArtilleryStrike.shellDef = verb.GetProjectile();
                for (int j = 0; j < verb.verbProps.burstShotCount; j++)
                {
                    activeArtilleryStrike.shellCount++;
                    if (verb.verbProps.consumeFuelPerShot > 0 && RefuelableComp != null)
                    {
                        RefuelableComp.ConsumeFuel(verb.verbProps.consumeFuelPerShot);
                    }
                }
            }
            NonPublicMethods.Building_TurretGun_BurstComplete(Turret);

            var artilleryStrikeLeaving = (ArtilleryStrikeLeaving)SkyfallerMaker.MakeSkyfaller(ThingDefOf.VFES_ArtilleryStrikeLeaving, activeArtilleryStrike);

            artilleryStrikeLeaving.startCell       = parent.Position;
            artilleryStrikeLeaving.edgeCell        = FacingEdgeCell;
            artilleryStrikeLeaving.rotation        = CurAngle;
            artilleryStrikeLeaving.destinationTile = destinationTile;
            artilleryStrikeLeaving.arrivalAction   = arrivalAction;
            artilleryStrikeLeaving.groupID         = Find.TickManager.TicksGame;

            GenSpawn.Spawn(artilleryStrikeLeaving, parent.Position, parent.Map);
        }
        public void SetTargetedTile(GlobalTargetInfo t)
        {
            CameraJumper.TryHideWorld();

            var compList = SelectedComps.ToList();

            for (int i = 0; i < compList.Count; i++)
            {
                var comp = compList[i];
                NonPublicMethods.Building_TurretGun_ResetForcedTarget(comp.Turret);
                NonPublicMethods.Building_TurretGun_ResetCurrentTarget(comp.Turret);
                comp.targetedTile = t;
                SoundDefOf.TurretAcquireTarget.PlayOneShot(new TargetInfo(comp.parent.Position, comp.parent.Map, false));
                comp.ResetWarmupTicks();
            }
        }
コード例 #4
0
            public static bool Prefix(Explosion explosion, IntVec3 c)
            {
                bool executeOriginal = true;

                ShieldGeneratorUtility.CheckIntercept(explosion, explosion.Map, explosion.damAmount, explosion.damType, () => new List <IntVec3>()
                {
                    c
                }, () => explosion.damType.AffectsShields(),
                                                      s =>
                {
                    executeOriginal = s.WithinBoundary(explosion.Position, c);
                    return(!s.affectedThings.ContainsKey(explosion));
                },
                                                      s =>
                {
                    var cellsToAffect = (List <IntVec3>)NonPublicFields.Explosion_cellsToAffect.GetValue(explosion);
                    int cacheDuration = cellsToAffect.Select(eC => NonPublicMethods.Explosion_GetCellAffectTick(explosion, eC)).Max();
                    s.affectedThings.Add(explosion, cacheDuration);
                });
                return(executeOriginal);
            }