// Token: 0x06000065 RID: 101 RVA: 0x00004254 File Offset: 0x00002454
        public override void Draw()
        {
            bool flag = this.flyingThing != null;

            if (flag)
            {
                bool flag2 = this.flyingThing is Pawn;
                if (flag2)
                {
                    Vector3 drawPos = this.DrawPos;
                    bool    flag3   = false;
                    if (flag3)
                    {
                        return;
                    }
                    bool flag4 = !IntVec3Utility.ToIntVec3(this.DrawPos).IsValid;
                    if (flag4)
                    {
                        return;
                    }
                    Pawn pawn = this.flyingThing as Pawn;
                    pawn.Drawer.DrawAt(this.DrawPos);
                }
                else
                {
                    Graphics.DrawMesh(MeshPool.plane10, this.DrawPos, this.ExactRotation, this.flyingThing.def.DrawMatSingle, 0);
                }
                base.Comps_PostDraw();
            }
        }
Esempio n. 2
0
 public static void PushEffect(Thing Caster, Thing target, int distance, bool damageOnCollision = false)
 {
     if (target is Building)
     {
         return;
     }
     LongEventHandler.QueueLongEvent(delegate()
     {
         Pawn pawn;
         if (target != null && (pawn = (target as Pawn)) != null && pawn.Spawned && !pawn.Downed && !pawn.Dead && (pawn?.MapHeld) != null)
         {
             bool drafted   = pawn.Drafted;
             Vector3 vector = Main.PushResult(Caster, target, distance, out bool flag2);
             RRY_FlyingObject flyingObject = (RRY_FlyingObject)GenSpawn.Spawn(ThingDef.Named("JT_FlyingObject"), pawn.PositionHeld, pawn.MapHeld, 0);
             bool flag3 = flag2 & damageOnCollision;
             if (flag3)
             {
                 flyingObject.Launch(Caster, new LocalTargetInfo(IntVec3Utility.ToIntVec3(vector)), target, new DamageInfo?(new DamageInfo(DamageDefOf.Blunt, (float)Rand.Range(8, 10), 0f, -1f, null, null, null, 0, null)));
             }
             else
             {
                 flyingObject.Launch(Caster, new LocalTargetInfo(IntVec3Utility.ToIntVec3(vector)), target);
             }
         }
     }, "PushingCharacter", false, null);
 }
        // Token: 0x06000064 RID: 100 RVA: 0x00004198 File Offset: 0x00002398
        public override void Tick()
        {
            base.Tick();
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;
            bool flag = !GenGrid.InBounds(this.ExactPosition, base.Map);

            if (flag)
            {
                this.ticksToImpact++;
                base.Position = IntVec3Utility.ToIntVec3(this.ExactPosition);
                this.Destroy(0);
            }
            else
            {
                base.Position = IntVec3Utility.ToIntVec3(this.ExactPosition);
                bool flag2 = this.ticksToImpact <= 0;
                if (flag2)
                {
                    bool flag3 = GenGrid.InBounds(this.DestinationCell, base.Map);
                    if (flag3)
                    {
                        base.Position = this.DestinationCell;
                    }
                    this.ImpactSomething();
                }
            }
        }
Esempio n. 4
0
 public override void CompTick()
 {
     base.CompTick();
     if (this.IsMounted)
     {
         if (driver.Dead || driver.Downed || driver.health.InPainShock || driver.InMentalState || //Abnormal
             (!driver.RaceProps.Animal && driver.Faction != Faction.OfPlayer) ||
             ForbidUtility.IsForbidden(parent, Faction.OfPlayer))
         {
             Dismount();
         }
         else
         {
             if (Find.TickManager.TicksGame - tickLastDoorCheck >= TickCooldownDoorCheck &&
                 (driver.Position.GetEdifice() is Building_Door || parent.Position.GetEdifice() is Building_Door))
             {
                 lastPassedDoor = ((driver.Position.GetEdifice() is Building_Door) ?
                                   driver.Position.GetEdifice() : parent.Position.GetEdifice()) as Building_Door;
                 lastPassedDoor.StartManualOpenBy(driver);
                 tickLastDoorCheck = Find.TickManager.TicksGame;
             }
             else if (Find.TickManager.TicksGame - tickLastDoorCheck >= TickCooldownDoorCheck && lastPassedDoor != null)
             {
                 lastPassedDoor.StartManualCloseBy(driver);
                 lastPassedDoor = null;
             }
             parent.Position = IntVec3Utility.ToIntVec3(Position);
             parent.Rotation = driver.Rotation;
         }
     }
 }
        // Token: 0x060000F0 RID: 240 RVA: 0x00008BAC File Offset: 0x00006DAC
        protected virtual void Explode(Thing hitThing, bool destroy = false)
        {
            Map     map    = base.Map;
            IntVec3 intVec = (hitThing != null) ? hitThing.PositionHeld : IntVec3Utility.ToIntVec3(this.destinationInt);

            if (destroy)
            {
                this.Destroy(0);
            }
            bool flag = this.def.projectile.explosionEffect != null;

            if (flag)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(intVec, map, false), new TargetInfo(intVec, map, false));
                effecter.Cleanup();
            }
            IntVec3   intVec2                      = intVec;
            Map       map2                         = map;
            float     explosionRadius              = this.def.projectile.explosionRadius;
            DamageDef damageDef                    = this.def.projectile.damageDef;
            Thing     launcher                     = this.launcher;
            int       damageAmount                 = this.def.projectile.GetDamageAmount(1f, null);
            SoundDef  soundExplode                 = this.def.projectile.soundExplode;
            ThingDef  equipmentDef                 = this.equipmentDef;
            ThingDef  def                          = this.def;
            ThingDef  postExplosionSpawnThingDef   = this.def.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = this.def.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = this.def.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = this.def.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(intVec2, map2, explosionRadius, damageDef, launcher, damageAmount, 0f, soundExplode, equipmentDef, def, null, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
        // Token: 0x0600000B RID: 11 RVA: 0x000024A4 File Offset: 0x000006A4
        public override void TickRare()
        {
            base.TickRare();
            bool shouldSendAlert = this.shouldSendAlert;

            if (shouldSendAlert)
            {
                MoteMaker.ThrowMetaIcon(IntVec3Utility.ToIntVec3(GenThing.TrueCenter(this)), base.Map, ThingDefOf.Mote_IncapIcon);
            }
        }
Esempio n. 7
0
        private void SpawnBeam()
        {
            ChronoBeam cb   = ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("ChronoBeam", true), null) as ChronoBeam;
            bool       flag = cb == null;

            if (!flag)
            {
                cb.Setup(this.caster, this.currentTarget);
                GenSpawn.Spawn(cb, IntVec3Utility.ToIntVec3(this.caster.Position.ToVector3()), this.caster.Map, 0);
            }
        }
Esempio n. 8
0
        // Token: 0x0600004A RID: 74 RVA: 0x0000417C File Offset: 0x0000237C
        public override void Tick()
        {
            this.innerContainer.ThingOwnerTick(true);
            this.ticksToImpact--;
            this.ticksToHeadAche++;
            Vector3 drawLoc = base.DrawPos;

            if (this.ticksToImpact % 3 == 0)
            {
                int numMotes = Math.Min(2, this.def.skyfaller.motesPerCell);
                for (int i = 0; i < numMotes; i++)
                {
                    MoteMaker.ThrowSmoke(drawLoc, base.Map, 2f);
                }
            }
            if (this.ticksToImpact % 25 == 0 && this.JumpSound != null)
            {
                IntVec3 SoundPos = IntVec3Utility.ToIntVec3(drawLoc);
                SoundStarter.PlayOneShot(this.JumpSound, new TargetInfo(SoundPos, base.Map, false));
            }
            if (this.ticksToHeadAche == 3 && Settings.AllowFire)
            {
                this.JPIgnite(IntVec3Utility.ToIntVec3(drawLoc), base.Map);
            }
            if (this.ticksToHeadAche == 10)
            {
                this.JPHitRoof(true);
            }
            if (this.ticksToImpact == 15)
            {
                this.JPHitRoof(false);
            }
            if (!this.anticipationSoundPlayed && this.def.skyfaller.anticipationSound != null && this.ticksToImpact < this.def.skyfaller.anticipationSoundTicks)
            {
                this.anticipationSoundPlayed = true;
                SoundStarter.PlayOneShot(this.def.skyfaller.anticipationSound, new TargetInfo(base.Position, base.Map, false));
            }
            if (this.ticksToImpact == 3)
            {
                this.EjectPilot();
            }
            if (this.ticksToImpact == 0)
            {
                this.JPImpact();
                return;
            }
            if (this.ticksToImpact < 0)
            {
                Log.Error("ticksToImpact < 0. Was there an exception? Destroying skyfaller.", false);
                this.EjectPilot();
                this.Destroy(0);
            }
        }
 public static void ThrowSmokeTrail(Vector3 loc, float size, Map map, string defName)
 {
     if (GenView.ShouldSpawnMotesAt(loc, map) && !map.moteCounter.Saturated)
     {
         MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named(defName), null);
         moteThrown.Scale         = Rand.Range(2f, 3f) * size;
         moteThrown.exactPosition = loc;
         moteThrown.rotationRate  = Rand.Range(-0.5f, 0.5f);
         moteThrown.SetVelocity((float)Rand.Range(30, 40), Rand.Range(0.008f, 0.012f));
         GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish);
     }
 }
Esempio n. 10
0
        public static void ThrowLightningBolt(Vector3 loc, Map map)
        {
            if (!loc.ShouldSpawnMotesAt(map))
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_BlastEMP"), null);

            moteThrown.Scale         = Rand.Range(0.5f, 1f);
            moteThrown.rotationRate  = Rand.Range(-12f, 12f);
            moteThrown.exactPosition = loc;
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
        }
Esempio n. 11
0
        public static void ThrowMoteDef(ThingDef moteDef, Vector3 loc, Map map, float size, float velocity, float angle, float rotation)
        {
            if (!GenView.ShouldSpawnMotesAt(loc, map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(moteDef, null);

            moteThrown.Scale         = Rand.Range(1f, 2f) * size;
            moteThrown.rotationRate  = rotation;
            moteThrown.exactPosition = loc;
            moteThrown.SetVelocity(angle, velocity);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish);
        }
Esempio n. 12
0
        public static void ThrowEMPLightningGlow(Vector3 loc, Map map, float size)
        {
            if (!loc.ShouldSpawnMotesAt(map))
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(PurpleIvyDefOf.EMPGlow, null);

            moteThrown.Scale         = Rand.Range(6f, 8f) * size;
            moteThrown.rotationRate  = Rand.Range(-3f, 3f);
            moteThrown.exactPosition = loc + size * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f);
            moteThrown.SetVelocity((float)Rand.Range(0, 360), 1.2f);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
        }
Esempio n. 13
0
        // Token: 0x06000051 RID: 81 RVA: 0x00004498 File Offset: 0x00002698
        internal void JPHitRoof(bool up)
        {
            if (!this.def.skyfaller.hitRoof)
            {
                return;
            }
            CellRect cr;

            if (up)
            {
                IntVec3 hrpcell   = IntVec3Utility.ToIntVec3(base.DrawPos);
                IntVec2 punchsize = new IntVec2(3, 3);
                cr = GenAdj.OccupiedRect(hrpcell, base.Rotation, punchsize);
            }
            else
            {
                cr = GenAdj.OccupiedRect(this);
            }
            if (cr.Cells.Any((IntVec3 x) => GridsUtility.Roofed(x, this.Map)))
            {
                RoofDef roof = GridsUtility.GetRoof(cr.Cells.First((IntVec3 x) => GridsUtility.Roofed(x, this.Map)), base.Map);
                if (!SoundDefHelper.NullOrUndefined(roof.soundPunchThrough))
                {
                    SoundStarter.PlayOneShot(roof.soundPunchThrough, new TargetInfo(base.Position, base.Map, false));
                }
                RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(base.Map).Cells.Where(delegate(IntVec3 c)
                {
                    if (!GenGrid.InBounds(c, this.Map))
                    {
                        return(false);
                    }
                    if (cr.Contains(c))
                    {
                        return(true);
                    }
                    if (GridsUtility.GetFirstPawn(c, this.Map) != null)
                    {
                        return(false);
                    }
                    Building edifice = GridsUtility.GetEdifice(c, this.Map);
                    return(edifice == null || !edifice.def.holdsRoof);
                }), base.Map, null);
                if (up)
                {
                    this.PilotRoofPunchUp = true;
                    return;
                }
                this.PilotRoofPunchDown = true;
            }
        }
Esempio n. 14
0
        public void SwitchOnLight()
        {
            IntVec3 val = IntVec3Utility.ToIntVec3(this.get_Wearer().get_DrawPos());

            if (!ThingUtility.DestroyedOrNull(light) && val != light.get_Position())
            {
                SwitchOffLight();
            }
            if (ThingUtility.DestroyedOrNull(light) && GridsUtility.GetFirstThing(val, this.get_Wearer().get_Map(), Util_VehicleLights.MiningLightDef) == null)
            {
                light = GenSpawn.Spawn(Util_VehicleLights.VehicleLightDef, val, this.get_Wearer().get_Map(), 0);
            }
            lightIsOn = true;
        }
Esempio n. 15
0
        // Token: 0x0600003F RID: 63 RVA: 0x0000370C File Offset: 0x0000190C
        public static void ThrowEMPSmoke(Vector3 loc, Map map, float size)
        {
            if (!GenView.ShouldSpawnMotesAt(loc, map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_EMPSmoke, null);

            moteThrown.Scale         = Rand.Range(1.5f, 2.5f) * size;
            moteThrown.rotationRate  = Rand.Range(-30f, 30f);
            moteThrown.exactPosition = loc;
            moteThrown.SetVelocity((float)Rand.Range(30, 40), Rand.Range(0.5f, 0.7f));
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish);
        }
Esempio n. 16
0
        // Token: 0x0600003E RID: 62 RVA: 0x00003654 File Offset: 0x00001854
        public static void ThrowEMPLightningGlow(Vector3 loc, Map map, float size)
        {
            if (!GenView.ShouldSpawnMotesAt(loc, map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.EMPGlow, null);

            moteThrown.Scale         = Rand.Range(6f, 8f) * size;
            moteThrown.rotationRate  = Rand.Range(-3f, 3f);
            moteThrown.exactPosition = loc + size * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f);
            moteThrown.SetVelocity((float)Rand.Range(0, 360), 1.2f);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish);
        }
Esempio n. 17
0
        public static void ThrowEMPMicroSparks(Vector3 loc, Map map)
        {
            if (!loc.ShouldSpawnMotesAt(map))
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(PurpleIvyDefOf.EMP_Sparks, null);

            moteThrown.Scale          = Rand.Range(5f, 8f);
            moteThrown.rotationRate   = Rand.Range(-12f, 12f);
            moteThrown.exactPosition  = loc;
            moteThrown.exactPosition -= new Vector3(0.5f, 0f, 0.5f);
            moteThrown.exactPosition += new Vector3(Rand.Value, 0f, Rand.Value);
            moteThrown.SetVelocity((float)Rand.Range(35, 45), 1.2f);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
        }
Esempio n. 18
0
        // Token: 0x0600003D RID: 61 RVA: 0x00003580 File Offset: 0x00001780
        public static void ThrowEMPMicroSparks(Vector3 loc, Map map)
        {
            if (!GenView.ShouldSpawnMotesAt(loc, map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.EMP_Sparks, null);

            moteThrown.Scale          = Rand.Range(5f, 8f);
            moteThrown.rotationRate   = Rand.Range(-12f, 12f);
            moteThrown.exactPosition  = loc;
            moteThrown.exactPosition -= new Vector3(0.5f, 0f, 0.5f);
            moteThrown.exactPosition += new Vector3(Rand.Value, 0f, Rand.Value);
            moteThrown.SetVelocity((float)Rand.Range(35, 45), 1.2f);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish);
        }
Esempio n. 19
0
        public static void ThrowMicroSparksRed(Vector3 loc, Map map)
        {
            if (!GenView.ShouldSpawnMotesAt(loc, map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            Rand.PushState();
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("LaserImpactThing"), null);

            moteThrown.Scale          = Rand.Range(1f, 1.2f);
            moteThrown.rotationRate   = Rand.Range(-12f, 12f);
            moteThrown.exactPosition  = loc;
            moteThrown.exactPosition -= new Vector3(0.5f, 0f, 0.5f);
            moteThrown.exactPosition += new Vector3(Rand.Value, 0f, Rand.Value);
            moteThrown.SetVelocity((float)Rand.Range(35, 45), 1.2f);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
            Rand.PopState();
        }
Esempio n. 20
0
        public static void ThrowToxicSmoke(Vector3 loc, Map map)
        {
            if (!loc.ShouldSpawnMotesAt(map))
            {
                return;
            }
            //moteThrown.instanceColor = new ColorInt(43, 56, 54).ToColor; // to investigate
            //moteThrown.Scale = Rand.Range(2.5f, 3.9f); to investigate
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Smoke, null);

            moteThrown.Scale         = Rand.Range(0.5f, 0.9f);
            moteThrown.rotationRate  = Rand.Range(-30f, 30f);
            moteThrown.exactPosition = loc;
            moteThrown.airTimeLeft   = Rand.Range(0.1f, 0.4f);
            moteThrown.Speed         = 0.3f;
            moteThrown.SetVelocity((float)Rand.Range(-20, 20), Rand.Range(0.5f, 0.7f));
            moteThrown.instanceColor = new Color(0f, 0.0862f, 0.094117f);
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish);
        }
Esempio n. 21
0
        public static void ThrowEMPMicroSparks(Vector3 loc, Map map, Color?color = null)
        {
            if (!loc.ShouldSpawnMotesAt(map))
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("EMP_Sparks"), null);

            moteThrown.Scale          = Rand.Range(5f, 8f);
            moteThrown.rotationRate   = Rand.Range(-12f, 12f);
            moteThrown.exactPosition  = loc;
            moteThrown.exactPosition -= new Vector3(0.5f, 0f, 0.5f);
            moteThrown.exactPosition += new Vector3(Rand.Value, 0f, Rand.Value);
            moteThrown.SetVelocity((float)Rand.Range(35, 45), 1.2f);
            if (color.HasValue)
            {
                moteThrown.instanceColor = color.Value;
            }
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
        }
Esempio n. 22
0
        public static void ThrowEMPLightningGlow(Vector3 loc, Map map, float size, Color?color = null)
        {
            if (!loc.ShouldSpawnMotesAt(map))
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("EMPGlow"), null);

            moteThrown.Scale         = Rand.Range(6f, 8f) * size;
            moteThrown.rotationRate  = Rand.Range(-3f, 3f);
            moteThrown.exactPosition = loc + size * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f);
            moteThrown.SetVelocity((float)Rand.Range(0, 360), 1.2f);
            if (color.HasValue)
            {
                moteThrown.instanceColor = color.Value;
                //    moteThrown.instanceColor = new Color(0.368f, 0f, 1f);
                //    moteThrown.instanceColor = new Color(0f, 0.0862f, 0.094117f);
            }
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
        }
Esempio n. 23
0
        public static void ThrowEMPSmoke(Vector3 loc, Map map, float size, Color?color = null)
        {
            if (!GenView.ShouldSpawnMotesAt(loc, map))
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_EMPSmoke"), null);

            moteThrown.Scale         = Rand.Range(1.5f, 2.5f) * size;
            moteThrown.rotationRate  = Rand.Range(-30f, 30f);
            moteThrown.exactPosition = loc;
            moteThrown.SetVelocity((float)Rand.Range(30, 40), Rand.Range(0.5f, 0.7f));
            if (color.HasValue)
            {
                moteThrown.instanceColor = color.Value;
                //    moteThrown.instanceColor = new Color(0.368f, 0f, 1f);
                //    moteThrown.instanceColor = new Color(0f, 0.0862f, 0.094117f);
            }
            GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, 0);
        }
Esempio n. 24
0
        public static void ThrowEffect(Thing Caster, Thing target, int distance, bool damageOnCollision = false)
        {
            if (target is Building)
            {
                return;
            }
            Pawn pawn;

            if (target != null && (pawn = (target as Pawn)) != null && pawn.Spawned && !pawn.Downed && !pawn.Dead && (pawn?.MapHeld) != null)
            {
                bool    drafted = pawn.Drafted;
                Vector3 vector  = MainHarmonyInstance.ThrowResult(Caster, target, distance, out bool flag2);

                IntVec3 cell  = pawn.Position;
                IntVec3 tcell = IntVec3Utility.ToIntVec3(vector);

                if (ModLister.RoyaltyInstalled)
                {
                    PawnThrown pawnFlyer = PawnThrown.MakeThrown(ThingDef.Named("PawnThrown"), pawn, tcell, new DamageInfo?(new DamageInfo(DamageDefOf.Blunt, (float)Rand.Range(8, 10), 0f, -1f, null, null, null, 0, null)));
                    if (pawnFlyer != null)
                    {
                        GenSpawn.Spawn(pawnFlyer, tcell, Caster.Map, WipeMode.Vanish);
                    }
                }
                else
                {
                    MLB_ThrownObject flyingObject = (MLB_ThrownObject)GenSpawn.Spawn(ThingDef.Named("BETA_GrapplerClassThrown"), pawn.PositionHeld, pawn.MapHeld, 0);
                    bool             flag3        = flag2 & damageOnCollision;
                    if (flag3)
                    {
                        Rand.PushState();
                        flyingObject.Launch(Caster, new LocalTargetInfo(IntVec3Utility.ToIntVec3(vector)), target, new DamageInfo?(new DamageInfo(DamageDefOf.Blunt, (float)Rand.Range(8, 10), 0f, -1f, null, null, null, 0, null)));
                        Rand.PopState();
                    }
                    else
                    {
                        flyingObject.Launch(Caster, new LocalTargetInfo(IntVec3Utility.ToIntVec3(vector)), target);
                    }
                }
            }
        }
Esempio n. 25
0
        /*
         * public static void BaseHeadOffsetAtPostfix(PawnRenderer __instance, ref Vector3 __result)
         * {
         *  Pawn pawn = Traverse.Create(root: __instance).Field(name: "pawn").GetValue<Pawn>();
         *  Vector2 offset = Vector2.zero;
         *  if (pawn.InBed() && pawn.CurrentBed() is Building_XenomorphCocoon cocoonthing)
         *  {
         *      //   Log.Message(string.Format("true"));
         *      if (cocoonthing.Rotation == Rot4.North)
         *      {
         *          __result.z -= 0.5f;
         *      }
         *  }
         *  else
         *  {
         *      //   Log.Message(string.Format("false"));
         *  }
         *  __result.x += offset.x;
         *  __result.z += offset.y;
         * }
         */
        public static Vector3 PushResult(Thing Caster, Thing thingToPush, int pushDist, out bool collision)
        {
            Vector3 vector = GenThing.TrueCenter(thingToPush);
            Vector3 result = vector;
            bool    flag   = false;

            for (int i = 1; i <= pushDist; i++)
            {
                int  num   = i;
                int  num2  = i;
                bool flag2 = vector.x < GenThing.TrueCenter(Caster).x;
                if (flag2)
                {
                    num = -num;
                }
                bool flag3 = vector.z < GenThing.TrueCenter(Caster).z;
                if (flag3)
                {
                    num2 = -num2;
                }
                Vector3 vector2 = new Vector3(vector.x + (float)num, 0f, vector.z + (float)num2);
                bool    flag4   = GenGrid.Standable(IntVec3Utility.ToIntVec3(vector2), Caster.Map);
                if (flag4)
                {
                    result = vector2;
                }
                else
                {
                    bool flag5 = thingToPush is Pawn;
                    if (flag5)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            collision = flag;
            return(result);
        }
Esempio n. 26
0
        public static Mote ThrowBatteryXYZ(ThingDef moteDef, Vector3 loc, Map map, float scale)
        {
            Mote result;

            if (!GenView.ShouldSpawnMotesAt(loc, map) ||
                map.moteCounter.Saturated)
            {
                result = null;
            }
            else
            {
                MoteThrown batteryMote = (MoteThrown)ThingMaker.MakeThing(moteDef, null);
                batteryMote.Scale          = scale;
                batteryMote.rotationRate   = (float)Rand.Range(-1, 1);
                batteryMote.exactPosition  = loc;
                batteryMote.exactPosition += new Vector3(THIRTY_FIVE, 0, THIRTY_FIVE);
                batteryMote.exactPosition += new Vector3(Rand.Value, 0, Rand.Value) * POINT_TEN;
                batteryMote.SetVelocity(Rand.Range(30, 60), Rand.Range(THIRTY_FIVE, FIFTY_FIVE));
                GenSpawn.Spawn(batteryMote, IntVec3Utility.ToIntVec3(loc), map);
                result = batteryMote;
            }
            return(result);
        }
        // Token: 0x060000FA RID: 250 RVA: 0x00009358 File Offset: 0x00007558
        protected void DetermineImpactExactPosition()
        {
            Vector3 a           = this.Destination - this.origin;
            int     num         = (int)a.magnitude;
            Vector3 b           = a / a.magnitude;
            Vector3 destination = this.origin;
            Vector3 vector      = this.origin;
            IntVec3 intVec      = IntVec3Utility.ToIntVec3(vector);

            for (int i = 1; i <= num; i++)
            {
                vector += b;
                intVec  = IntVec3Utility.ToIntVec3(vector);
                bool flag = !GenGrid.InBounds(vector, base.Map);
                if (flag)
                {
                    this.destinationInt = destination;
                    break;
                }
                bool flag2 = !this.def.projectile.flyOverhead && i >= 5;
                if (flag2)
                {
                    List <Thing> list = base.Map.thingGrid.ThingsListAt(base.Position);
                    for (int j = 0; j < list.Count; j++)
                    {
                        Thing thing = list[j];
                        bool  flag3 = thing.def.Fillage == (FillCategory)2;
                        if (flag3)
                        {
                            this.destinationInt = intVec.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
                            this.hitThing       = thing;
                            break;
                        }
                        bool flag4 = thing.def.category == (ThingCategory)1;
                        if (flag4)
                        {
                            Pawn  pawn   = thing as Pawn;
                            float num2   = 0.45f;
                            bool  downed = pawn.Downed;
                            if (downed)
                            {
                                num2 *= 0.1f;
                            }
                            float num3  = GenGeo.MagnitudeHorizontal(this.ExactPosition - this.OriginIV3.ToVector3());
                            bool  flag5 = num3 < 4f;
                            if (flag5)
                            {
                                num2 *= 0f;
                            }
                            else
                            {
                                bool flag6 = num3 < 7f;
                                if (flag6)
                                {
                                    num2 *= 0.5f;
                                }
                                else
                                {
                                    bool flag7 = num3 < 10f;
                                    if (flag7)
                                    {
                                        num2 *= 0.75f;
                                    }
                                }
                            }
                            num2 *= pawn.RaceProps.baseBodySize;
                            bool flag8 = Rand.Value < num2;
                            if (flag8)
                            {
                                this.destinationInt = intVec.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
                                this.hitThing       = pawn;
                                break;
                            }
                        }
                    }
                }
                destination = vector;
            }
        }
        private static void Postfix(IntVec3 c, SteadyEnvironmentEffects __instance, Map ___map)
        {
            if (___map == null)
            {
                return;
            }
            Room room = c.GetRoom(___map, RegionType.Set_Passable);

            if (ReGrowthSettings.ColdFog || ReGrowthSettings.IceLayer)
            {
                Thing thing = (from t in c.GetThingList(___map)
                               where t.def == RGDefOf.RG_IceOverlay
                               select t).FirstOrDefault <Thing>();
                if (room == null && thing != null && ReGrowthSettings.IceLayer)
                {
                    thing.Destroy(DestroyMode.Vanish);
                    if (Rand.Range(1, 100) <= 20)
                    {
                        FilthMaker.TryMakeFilth(c, ___map, RGDefOf.RG_Filth_Water, 1);
                    }
                }
                if (room != null && !room.UsesOutdoorTemperature && !room.Fogged && !room.IsDoorway)
                {
                    float num = 0.8f;
                    if (room.Temperature < (float)ReGrowthSettings.FogTemp)
                    {
                        if (thing == null && ReGrowthSettings.IceLayer)
                        {
                            GenSpawn.Spawn(ThingMaker.MakeThing(RGDefOf.RG_IceOverlay), c, ___map);
                        }
                        if (ReGrowthSettings.ColdFog)
                        {
                            Vector3 vector = c.ToVector3Shifted();
                            bool    flag   = true;
                            if (!GenView.ShouldSpawnMotesAt(vector, ___map) || ___map.moteCounter.SaturatedLowPriority)
                            {
                                flag = false;
                            }
                            vector += num * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f);
                            if (!GenGrid.InBounds(vector, ___map))
                            {
                                flag = false;
                            }
                            if (flag)
                            {
                                MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(RGDefOf.RG_Mote_FrostGlow, null);
                                moteThrown.Scale         = Rand.Range(4f, 6f) * num;
                                moteThrown.rotationRate  = Rand.Range(-3f, 3f);
                                moteThrown.exactPosition = vector;
                                moteThrown.SetVelocity((float)(Rand.Bool ? -90 : 90), (float)((double)ReGrowthSettings.FogVelocity * 0.01));
                                GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(vector), ___map);
                            }
                        }
                    }
                    else if (thing != null)
                    {
                        thing.Destroy(DestroyMode.Vanish);
                        if (Rand.Range(1, 100) <= 20)
                        {
                            FilthMaker.TryMakeFilth(c, ___map, RGDefOf.RG_Filth_Water, 1);
                        }
                    }
                }
            }
            if (!ReGrowthSettings.IceLayer)
            {
                Thing thing2 = (from t in c.GetThingList(___map)
                                where t.def == RGDefOf.RG_IceOverlay
                                select t).FirstOrDefault <Thing>();
                if (thing2 != null)
                {
                    thing2.Destroy(DestroyMode.Vanish);
                }
            }
            if (___map.roofGrid != null && !___map.roofGrid.Roofed(c) && (float)___map.weatherManager.curWeatherAge >= 7500f && (___map.weatherManager.curWeather.rainRate <= 0f ||
                                                                                                                                 ___map.weatherManager.curWeather.snowRate > 0f))
            {
                Thing thing3 = (from t in c.GetThingList(___map)
                                where t.def == RGDefOf.RG_Filth_Water || t.def == RGDefOf.RG_Filth_WaterSpatter
                                select t).FirstOrDefault <Thing>();
                if (thing3 != null && Rand.Value <= 0.2f)
                {
                    ((Filth)thing3).ThinFilth();
                }
            }
        }
        public override void Resolve(ResolveParams rp)
        {
            Map     map  = BaseGen.globalSettings.map;
            IntVec3 root = IntVec3Utility.ToIntVec3(rp.rect.CenterVector3);
            IntVec3 motherVec;

            CellFinder.TryFindRandomCellNear(root, map, 3, (IntVec3 x) => x.Standable(map) && map.fertilityGrid.FertilityAt(x) > ThingDefOf.Plant_Ambrosia.plant.fertilityMin, out motherVec);
            float eventPoints = StorytellerUtility.DefaultThreatPointsNow(Find.World) * 0.6f;

            if (eventPoints > 4000f)
            {
                eventPoints *= 0.9f;
                if (eventPoints > 7000f)
                {
                    eventPoints = 7000f;
                }
            }
            if (eventPoints < 400f)
            {
                eventPoints = 400f;
            }

            foreach (IntVec3 vec in rp.rect)
            {
                if (map.terrainGrid.TerrainAt(vec).fertility < 0.7f)
                {
                    if (Rand.Chance(0.5f))
                    {
                        map.terrainGrid.SetTerrain(vec, TerrainDefOf.Gravel);
                    }
                }
            }

            //spawn mother plant
            MotherAmbrosiaLGE motherAmbrosia = (MotherAmbrosiaLGE)GenSpawn.Spawn(DefsOfLGE.Plant_MotherAmbrosiaLGE, motherVec, map, WipeMode.Vanish);

            motherAmbrosia.Growth = Rand.Range(0.9f, 0.98f);

            PawnKindDef animalKind;

            (from k in map.Biome.AllWildAnimals
             where Find.World.tileTemperatures.SeasonAndOutdoorTemperatureAcceptableFor(map.Tile, k.race)
             select k).TryRandomElement(out animalKind);
            if (animalKind == null)
            {
                animalKind = ThingDefOfVanilla.Warg;
            }
            motherAmbrosia.SpawnAnimals(animalKind, eventPoints);


            int randomInRange = (int)(eventPoints / 80);//SymbolResolver_AmbrosiaAnimalsLGE.CountRange.RandomInRange;

            for (int i = 0; i < randomInRange; i++)
            {
                IntVec3 intVec;
                if (!CellFinder.TryRandomClosewalkCellNear(motherVec, map, SpawnRadius, out intVec, (IntVec3 x) => this.CanSpawnAt(x, map)))
                {
                    break;
                }
                Plant plant = intVec.GetPlant(map);
                if (plant != null)
                {
                    plant.Destroy(DestroyMode.Vanish);
                }
                Plant ambrosia = (Plant)GenSpawn.Spawn(ThingDefOf.Plant_Ambrosia, intVec, map, WipeMode.Vanish);
                ambrosia.Growth = Rand.Range(0.6f, 0.95f);
            }

            //Spawn ambrosia reward
            ResolveParams resolveParamsReward = rp;

            resolveParamsReward.rect = CellRect.CenteredOn(motherVec, SpawnRadius - 2);
            resolveParamsReward.stockpileConcreteContents = RewardGeneratorUtilityLGE.GenerateAmbrosia((int)(eventPoints / 150f));
            BaseGen.symbolStack.Push("spawnStockpileLGE", resolveParamsReward);
        }
Esempio n. 30
0
        protected void DetermineImpactExactPosition()
        {
            Vector3 a           = this.destination - this.origin;
            int     num         = (int)a.magnitude;
            Vector3 b           = a / a.magnitude;
            Vector3 destination = this.origin;
            Vector3 vector      = this.origin;
            IntVec3 intVec      = IntVec3Utility.ToIntVec3(vector);

            for (int i = 1; i <= num; i++)
            {
                vector += b;
                intVec  = IntVec3Utility.ToIntVec3(vector);
                if (!GenGrid.InBounds(vector, base.Map))
                {
                    this.destination = destination;
                    return;
                }
                if (!this.def.projectile.flyOverhead && this.def.projectile.alwaysFreeIntercept && i >= 5)
                {
                    List <Thing> list = base.Map.thingGrid.ThingsListAt(base.Position);
                    for (int j = 0; j < list.Count; j++)
                    {
                        Thing thing = list[j];
                        if (thing.def.Fillage == FillCategory.Full)
                        {
                            this.destination = intVec.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
                            this.hitThing    = thing;
                            break;
                        }
                        if (thing.def.category == ThingCategory.Pawn)
                        {
                            Pawn  pawn = thing as Pawn;
                            float num2 = 0.45f;
                            if (pawn.Downed)
                            {
                                num2 *= 0.1f;
                            }
                            float num3 = GenGeo.MagnitudeHorizontal(this.ExactPosition - this.origin);
                            if (num3 < 4f)
                            {
                                num2 *= 0f;
                            }
                            else if (num3 < 7f)
                            {
                                num2 *= 0.5f;
                            }
                            else if (num3 < 10f)
                            {
                                num2 *= 0.75f;
                            }
                            num2 *= pawn.RaceProps.baseBodySize;
                            if (Rand.Value < num2)
                            {
                                this.destination = intVec.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
                                this.hitThing    = pawn;
                                break;
                            }
                        }
                    }
                }
                destination = vector;
            }
        }