Пример #1
0
        public void DoStrike()
        {
            bool isAntimatter = CurrentShellDef == ThingDefOf.Shell_AntigrainWarhead;

            if (isAntimatter)
            {
                GenericEventTracker.Fire(AchievementEvent.DroneAntimatter);

                if (LoadedShellCount >= MaxLoadedShellCount)
                {
                    GenericEventTracker.Fire(AchievementEvent.DroneAntimatterFull);
                }
            }

            GenAirstrike.DoStrike(this, CECompat.IsCEActive ? CECompat.GetProjectile(CurrentShellDef) : CurrentShellDef.projectileWhenLoaded, firstPosition.Value, secondPosition.Value, LoadedShellCount, 200, RFDefOf.RF_Sound_Drone);
            ClearLoadedShells();

            isFlying    = true;
            ticksFlying = 0;

            SoundInfo info = SoundInfo.InMap(this);

            RFDefOf.RF_Sound_DroneLaunch.PlayOneShot(info);
        }
Пример #2
0
        public virtual void AttackNow(List <Pawn> pawns)
        {
            if (LinkedTo == null)
            {
                Core.Error("AttackNow called with null LinkedTo. Pawns will be damaged, but effects will not be spawned.");
            }

            // Make electrical arcs.
            if (LinkedTo != null)
            {
                var start = this.TopPos;
                var end   = LinkedTo.TopPos;
                var map   = this.Map;

                const float POINTS_PER_CELL = 3;
                float       dst             = (start - end).WorldToFlat().magnitude;
                int         points          = Mathf.Clamp(Mathf.RoundToInt(dst * POINTS_PER_CELL), 1, 100); // Max out at 100.

                for (int i = 0; i < arcs.Length; i++)
                {
                    var current = arcs[i];
                    current?.Destroy();
                    var arc = new LinearElectricArc(points);
                    arc.Start = start.WorldToFlat();
                    arc.End   = end.WorldToFlat();
                    arc.Spawn(map);
                    arcs[i] = arc;
                }

                arcTicksAlive = 0;
            }

            // Make motes.
            for (int i = 0; i < 4; i++)
            {
#if V13
                FleckMaker.ThrowLightningGlow(TopPos, Map, 1);
#else
                MoteMaker.ThrowLightningGlow(TopPos, Map, 1);
#endif
            }

            if (LinkedTo != null)
            {
                for (int i = 0; i < 4; i++)
                {
#if V13
                    FleckMaker.ThrowLightningGlow(LinkedTo.TopPos, Map, 1);
#else
                    MoteMaker.ThrowLightningGlow(LinkedTo.TopPos, Map, 1);
#endif
                }
            }

            // TODO play sound.

            // Damage pawns.
            foreach (var pawn in pawns)
            {
                try
                {
                    AttackPawn(pawn);
                }
                catch (Exception e)
                {
                    Core.Error($"Exception when trying to data pawn with tesla coil. Pawn: '{pawn.LabelCap}'", e);
                }
            }

            GenericEventTracker.Fire(AchievementEvent.CoilsFire);

            CooldownTicksRemaining = Settings.TeslaCooldown;
        }