Example #1
0
        protected virtual void Explode()
        {
            this.Destroy(DestroyMode.Vanish);
            ThingDef preExplosionSpawnThingDef = this.def.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(base.Position, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.soundExplode, this.def, this.equipmentDef, this.def.projectile.postExplosionSpawnThingDef, this.def.projectile.explosionSpawnChance, false, preExplosionSpawnThingDef, this.def.projectile.explosionSpawnChance);
            MoteThrower.ThrowLightningGlow(base.Position.ToVector3Shifted(), 10F);
        }
Example #2
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            base.Destroy(mode);

            this.launcher.NotifyTargetIsDestroyedOrMissed(this.target);
            if (mode == DestroyMode.Kill)
            {
                MoteThrower.ThrowLightningGlow(this.DrawPos, 6f);
                for (int smokeIndex = 0; smokeIndex < 3; smokeIndex++)
                {
                    MoteThrower.ThrowSmoke(this.DrawPos + new Vector3(Rand.Range(0, 1), 0, Rand.Range(0, 1)), 3f);
                }
                SoundInfo infos = SoundInfo.InWorld(this);
                SoundDef.Named("Explosion_Bomb").PlayOneShot(infos);
            }
        }
Example #3
0
        protected override bool TryCastShot()
        {
            //Log.Message("Trying open door on "+currentTarget.Thing);
            var door = currentTarget.Thing as Building_Door;

            if (door == null)
            {
                return(false);
            }
            if (CasterPawn.stances.FullBodyBusy)
            {
                return(false);
            }
            if (!CanHitTarget(door))
            {
                Log.Warning(string.Concat(new object[] { CasterPawn, " unlocked ", door, " from out of position." }));
            }
            door.GetType().GetMethod("DoorOpen", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(door, new object[] { 60 });
            door.StartManualOpenBy(CasterPawn);
            door.GetType().GetField("holdOpenInt", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(door, true);

            // Block door, tehehe
            //if (door.Position.GetThingList().All(t => t.def.category != ThingCategory.Item))
            //{
            //    GenSpawn.Spawn(ThingDefOf.ChunkSlagSteel, door.Position);
            //}

            //Log.Message(casterPawn + " set " + door + " to " + casterPawn.Faction);

            unlockDoorSound.PlayOneShot(CasterPawn.Position);
            CasterPawn.drawer.Notify_MeleeAttackOn(door);
            Vector3 loc = door.Position.ToVector3ShiftedWithAltitude(1);

            MoteThrower.ThrowMicroSparks(loc);
            MoteThrower.ThrowLightningGlow(loc, Rand.Range(0.7f, 1.5f));

            CasterPawn.jobs.StopAll();
            return(true);
        }
        public void ComputeDrawingParameters()
        {
            const float fadingOffset   = 0.3f;
            const float fadingVariable = 0.7f;

            if ((this.forceFieldState == ForceFieldState.Charging) ||
                (this.forceFieldState == ForceFieldState.Sustaining) ||
                (this.forceFieldState == ForceFieldState.Discharging))
            {
                // Standard matrix cyan effect.
                for (int matrixIndex = 0; matrixIndex < 5; matrixIndex++)
                {
                    this.matrixFadingCoefficient[matrixIndex] = fadingOffset + fadingVariable * (this.forceFieldCharge / this.forceFieldProperties.forceFieldMaxCharge);
                }

                // Additional lightning effect.
                int effectCellIndex = Rand.RangeInclusive(0, 4);
                if (Rand.Value < (1f / 100))
                {
                    MoteThrower.ThrowLightningGlow(this.effectCells[effectCellIndex] + new Vector3(Rand.Range(-0.1f, 0.1f), 0f, Rand.Range(-0.1f, 0.1f)), 0.2f);
                }
            }

            for (int matrixIndex = 0; matrixIndex < 5; matrixIndex++)
            {
                // Absorbing matrix red effect.
                if (this.matrixIsStartingAbsorbion[matrixIndex])
                {
                    this.matrixAbsorbtionCounterInTicks[matrixIndex] = matrixAbsorbtionDurationInTicks;
                    this.matrixIsStartingAbsorbion[matrixIndex]      = false;
                    MoteThrower.ThrowLightningGlow(this.effectCells[matrixIndex] + new Vector3(Rand.Range(-0.2f, 0.2f), 0f, Rand.Range(-0.2f, 0.2f)), 0.2f);
                }
                if (this.matrixAbsorbtionCounterInTicks[matrixIndex] > 0)
                {
                    this.matrixAbsorbtionCounterInTicks[matrixIndex]--;
                    this.matrixAbsorbtionFadingCoefficient[matrixIndex] = 0.5f * ((float)this.matrixAbsorbtionCounterInTicks[matrixIndex] / (float)matrixAbsorbtionDurationInTicks);
                }
            }
        }
Example #5
0
        public override void Tick()
        {
            MoteThrower.ThrowSmoke(DrawPos, 0.5f);
            MoteThrower.ThrowLightningGlow(DrawPos, 0.5f);

            this.ticksToImpact--;
            if (!this.soundPlayed && this.ticksToImpact < 100)
            {
                this.soundPlayed = true;
                SoundStarter.PlayOneShot(RazorRainIncoming.LandSound, base.Position);
            }
            if (this.ticksToImpact <= 0)
            {
                GenExplosion.DoExplosion(base.Position, 1f, DamageDefOf.Bomb, null, null, null);
                Thing razor = ThingMaker.MakeThing(ThingDef.Named("Steel"));
                razor.SetForbidden(true);
                int num = this.random.Next(1, 8);
                if (num == 5)
                {
                    GenSpawn.Spawn(razor, base.Position, this.Rotation);
                }
                this.Destroy(DestroyMode.Vanish);
            }
        }
Example #6
0
        private void ProtectSquare(IntVec3 square, bool flag_direct, bool flag_indirect, bool IFFcheck)
        {
            if (!GenGrid.InBounds(square) || (!this.shieldBlockIndirect || !flag_indirect) && (!this.shieldBlockDirect || !flag_direct))
            {
                return;
            }
            List <Thing> thingList1 = Find.get_ThingGrid().ThingsListAt(square);
            List <Thing> thingList2 = new List <Thing>();
            int          index1     = 0;

            for (int index2 = ((IEnumerable <Thing>)thingList1).Count <Thing>(); index1 < index2; ++index1)
            {
                if (thingList1[index1] != null && thingList1[index1] is Projectile)
                {
                    Projectile projectile = (Projectile)thingList1[index1];
                    if (!((Thing)projectile).get_Destroyed() && (this.shieldBlockIndirect && flag_indirect && ((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).flyOverhead != null || this.shieldBlockDirect && flag_direct && ((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).flyOverhead == null))
                    {
                        bool flag = true;
                        if (IFFcheck)
                        {
                            Thing instanceField = ReflectionHelper.GetInstanceField(typeof(Projectile), (object)projectile, "launcher") as Thing;
                            if (instanceField != null && instanceField.get_Faction() != null && (instanceField.get_Faction().def != null && instanceField.get_Faction().def == FactionDefOf.Colony))
                            {
                                flag = false;
                            }
                        }
                        if (((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).flyOverhead != null && !this.WillTargetLandInRange(projectile))
                        {
                            flag = false;
                        }
                        if (flag)
                        {
                            Quaternion exactRotation = projectile.get_ExactRotation();
                            Vector3    exactPosition = projectile.get_ExactPosition();
                            exactPosition.y = (__Null)0.0;
                            Vector3 vec = Vectors.IntVecToVec(this.position);
                            vec.y = (__Null)0.0;
                            Quaternion quaternion = Quaternion.LookRotation(Vector3.op_Subtraction(exactPosition, vec));
                            if ((double)Quaternion.Angle(exactRotation, quaternion) > 90.0 || IFFcheck)
                            {
                                MoteThrower.ThrowLightningGlow(projectile.get_ExactPosition(), 0.5f);
                                SoundStarter.PlayOneShot(ShieldField.HitSoundDef, SoundInfo.op_Implicit(((Thing)projectile).get_Position()));
                                this.ProcessDamage((int)((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).damageAmountBase);
                                thingList2.Add((Thing)projectile);
                                if (!this.isOnline())
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            using (List <Thing> .Enumerator enumerator = thingList2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    enumerator.Current.Destroy((DestroyMode)0);
                }
            }
        }